feat(led-driver): add preset clear command and runtime debug
This commit is contained in:
@@ -24,6 +24,8 @@ def process_data(payload, settings, presets, controller_ip=None):
|
||||
apply_brightness(data, settings, presets)
|
||||
if "presets" in data:
|
||||
apply_presets(data, settings, presets)
|
||||
if "clear_presets" in data:
|
||||
apply_clear_presets(data, presets)
|
||||
if "select" in data:
|
||||
apply_select(data, settings, presets)
|
||||
if "default" in data:
|
||||
@@ -32,6 +34,8 @@ def process_data(payload, settings, presets, controller_ip=None):
|
||||
apply_patterns_ota(data, presets, controller_ip=controller_ip)
|
||||
if "save" in data and ("presets" in data or "default" in data):
|
||||
presets.save()
|
||||
if "save" in data and "clear_presets" in data:
|
||||
presets.save()
|
||||
|
||||
|
||||
def apply_brightness(data, settings, presets):
|
||||
@@ -70,6 +74,22 @@ def apply_select(data, settings, presets):
|
||||
presets.select(preset_name, step=step)
|
||||
|
||||
|
||||
def apply_clear_presets(data, presets):
|
||||
clear_value = data.get("clear_presets")
|
||||
if isinstance(clear_value, bool):
|
||||
should_clear = clear_value
|
||||
elif isinstance(clear_value, int):
|
||||
should_clear = bool(clear_value)
|
||||
elif isinstance(clear_value, str):
|
||||
should_clear = clear_value.lower() in ("true", "1", "yes", "on")
|
||||
else:
|
||||
should_clear = False
|
||||
if not should_clear:
|
||||
return
|
||||
presets.delete_all()
|
||||
print("Cleared all presets.")
|
||||
|
||||
|
||||
def apply_default(data, settings, presets):
|
||||
targets = data.get("targets") or []
|
||||
default_name = data["default"]
|
||||
|
||||
Reference in New Issue
Block a user