fix: add leds+midi to WebServerDeps, runtime apply for brightness (LED set_brightness) and channel_mode (pipeline routing_mode)

This commit is contained in:
2026-06-14 12:50:53 -04:00
parent be9b3e4b35
commit 6a14884063
2 changed files with 26 additions and 0 deletions
+24
View File
@@ -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 ───────────────────────────────