diff --git a/lighting_config.json b/lighting_config.json index 12f1328..8c8161c 100644 --- a/lighting_config.json +++ b/lighting_config.json @@ -15,11 +15,6 @@ "g": 0, "b": 255 }, - { - "r": 128, - "g": 0, - "b": 128 - }, { "r": 255, "g": 255, @@ -31,19 +26,24 @@ "b": 255 }, { - "r": 255, + "r": 0, "g": 255, "b": 255 }, { "r": 255, - "g": 128, - "b": 128 + "g": 0, + "b": 255 + }, + { + "r": 108, + "g": 255, + "b": 255 } ], "selected_color_indices": [ - 4, - 3 + 5, + 2 ], "pattern_parameters": { "alternating": { @@ -127,6 +127,13 @@ "delay": 100, "n1": 21, "n2": 60, + "n3": 28, + "n4": 1 + }, + "ap": { + "delay": 100, + "n1": 10, + "n2": 10, "n3": 1, "n4": 1 } diff --git a/src/control_server.py b/src/control_server.py index 51f474b..bafd472 100644 --- a/src/control_server.py +++ b/src/control_server.py @@ -384,29 +384,34 @@ class LightingController: color_b = self._palette_color(1) phase = self.beat_index % 2 + # Set the default color based on phase so both bar groups swap each beat + default_color = color_a if phase == 0 else color_b + alt_color_for_swap = color_b if phase == 0 else color_a + # Avoid pure white edge-case on some bars by slightly reducing to 254 + if default_color == (255, 255, 255): + default_color = (254, 254, 254) + if alt_color_for_swap == (255, 255, 255): + alt_color_for_swap = (254, 254, 254) + payload = { "d": { "t": "b", "pt": "a", # alternating "n1": self.n1, "n2": self.n2, - # Default color for bars not overridden (keeps payload small) - "cl": [color_a], + # Default color for non-swapped bars changes with phase + "cl": [default_color], "s": phase, } } # Bars in this list will have inverted phase and explicit color override - swap_bars = ["101", "103", "105", "107"] - for bar_name in LED_BAR_NAMES: - if bar_name in swap_bars: - # Invert phase and explicitly set alternate color - inv_phase = (phase + 1) % 2 - alt_color = color_b if phase == 0 else color_a - payload[bar_name] = {"s": inv_phase, "cl": [alt_color]} - else: - # Keep default (no extra fields) to save bytes - payload[bar_name] = {} + # Flip grouping so first four bars (100-103) use default color (color_a on even beats) + swap_bars = ["104", "105", "106", "107"] + # Only include overrides for swapped bars to minimize payload size + for bar_name in swap_bars: + inv_phase = (phase + 1) % 2 + payload[bar_name] = {"s": inv_phase, "cl": [alt_color_for_swap]} await self.led_controller.send_data(payload)