Align controller backend and data with new presets

Update palettes, profiles, tabs, preset sending, and ESPNow message format to match the new preset defaults and driver short-field schema.
This commit is contained in:
2026-01-29 00:04:23 +13:00
parent fd37183400
commit cf1d831b5a
11 changed files with 305 additions and 67 deletions

View File

@@ -6,22 +6,30 @@ class Palette(Model):
def create(self, name="", colors=None):
next_id = self.get_next_id()
self[next_id] = {
"name": name,
"colors": colors if colors else []
}
# Store palette as a simple list of colors; name is ignored.
self[next_id] = list(colors) if colors else []
self.save()
return next_id
def read(self, id):
id_str = str(id)
return self.get(id_str, None)
value = self.get(id_str, None)
# Backwards compatibility: if stored as {"colors": [...]}, unwrap.
if isinstance(value, dict) and "colors" in value:
return value.get("colors") or []
# Otherwise, expect a list of colors.
return value or []
def update(self, id, data):
id_str = str(id)
if id_str not in self:
return False
self[id_str].update(data)
# Accept either {"colors": [...]} or a raw list.
if isinstance(data, dict):
colors = data.get("colors", [])
else:
colors = data
self[id_str] = list(colors) if colors else []
self.save()
return True