fix: add leds+midi to WebServerDeps, runtime apply for brightness (LED set_brightness) and channel_mode (pipeline routing_mode)
This commit is contained in:
@@ -271,6 +271,8 @@ class PedalApp:
|
||||
jack_audio=self.jack_audio,
|
||||
config=self._config,
|
||||
config_path=self._config_path,
|
||||
leds=self.leds,
|
||||
midi=self.midi,
|
||||
),
|
||||
host="0.0.0.0",
|
||||
port=8080,
|
||||
|
||||
@@ -43,6 +43,8 @@ from ..system.tonedownload import (
|
||||
)
|
||||
from ..system.audio import AudioSystem, JackAudioClient, LATENCY_PROFILES
|
||||
from ..system.config import save_config
|
||||
from ..ui.leds import LEDController
|
||||
from ..midi.handler import MIDIHandler
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -212,6 +214,10 @@ class WebServerDeps:
|
||||
config: Optional[dict] = None
|
||||
config_path: Optional[Path] = None
|
||||
|
||||
# Runtime subsystems (for live apply of settings changes)
|
||||
leds: Optional[LEDController] = None
|
||||
midi: Optional[MIDIHandler] = None
|
||||
|
||||
@property
|
||||
def is_connected(self) -> bool:
|
||||
"""True if we're wired to a live pedal instance (any channel)."""
|
||||
@@ -1584,6 +1590,24 @@ class WebServer:
|
||||
save_config(cfg, self.deps.config_path)
|
||||
logger.info("Settings saved: %d keys from %s", n_saved, data)
|
||||
|
||||
# ── Runtime apply for live-updatable settings ──────────
|
||||
if "brightness" in data and self.deps.leds is not None:
|
||||
try:
|
||||
bv = data["brightness"]
|
||||
if isinstance(bv, (int, float)) and bv >= 1:
|
||||
bv = bv / 10.0
|
||||
self.deps.leds.set_brightness(float(bv))
|
||||
except Exception as e:
|
||||
logger.warning("Failed to apply brightness: %s", e)
|
||||
|
||||
if "channel_mode" in data and self.deps.pipeline is not None:
|
||||
try:
|
||||
mode = str(data["channel_mode"])
|
||||
self.deps.pipeline.routing_mode = "4cm" if mode == "stereo_4cm" else "mono"
|
||||
logger.info("Pipeline routing_mode set to %s", self.deps.pipeline.routing_mode)
|
||||
except Exception as e:
|
||||
logger.warning("Failed to apply channel_mode: %s", e)
|
||||
|
||||
return {"ok": True, "saved": n_saved}
|
||||
|
||||
# ── FX block param schemas ───────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user