diff --git a/src/settings.py b/src/settings.py index 410ed97..cd12526 100644 --- a/src/settings.py +++ b/src/settings.py @@ -9,8 +9,21 @@ class Settings(dict): def __init__(self): super().__init__() self.load() # Load settings from file during initialization - if self["color_order"] == "rbg": self.color_order = (1, 5, 3) - else: self.color_order = (1, 3, 5) + self.color_order = self._get_color_order(self.get("color_order", "rgb")) + + def _get_color_order(self, order): + """Convert color order string to tuple of hex string indices. + Hex string format: #RRGGBB where indices are 1, 3, 5 (0-indexed). + Returns tuple (R_index, G_index, B_index) for hex string parsing.""" + color_orders = { + "rgb": (1, 3, 5), # Red at 1, Green at 3, Blue at 5 + "rbg": (1, 5, 3), # Red at 1, Blue at 5, Green at 3 + "grb": (3, 1, 5), # Green at 3, Red at 1, Blue at 5 + "gbr": (3, 5, 1), # Green at 3, Blue at 5, Red at 1 + "brg": (5, 1, 3), # Blue at 5, Red at 1, Green at 3 + "bgr": (5, 3, 1), # Blue at 5, Green at 3, Red at 1 + } + return color_orders.get(order.lower(), (1, 3, 5)) # Default to RGB def set_defaults(self): self["led_pin"] = 10 @@ -84,8 +97,7 @@ class Settings(dict): self.save() machine.reset() elif key == "color_order": - if value == "rbg": self.color_order = (1, 5, 3) - else: self.color_order = (1, 3, 5) + self.color_order = self._get_color_order(value) pass elif key == "id": pass diff --git a/src/templates/index.html b/src/templates/index.html index 4e1a112..263fe19 100644 --- a/src/templates/index.html +++ b/src/templates/index.html @@ -1,4 +1,4 @@ -{% args settings, patterns, mac %} +{% args settings, patterns %}
@@ -111,13 +111,20 @@ - -Mac address: {{mac}}