alternating_phase: compact per-bar overrides to stay <230 bytes; swap grouping flip; avoid pure white by sending 254,254,254 to work around strip edge-cases; add API logging improvements
This commit is contained in:
@@ -15,11 +15,6 @@
|
|||||||
"g": 0,
|
"g": 0,
|
||||||
"b": 255
|
"b": 255
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"r": 128,
|
|
||||||
"g": 0,
|
|
||||||
"b": 128
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"r": 255,
|
"r": 255,
|
||||||
"g": 255,
|
"g": 255,
|
||||||
@@ -31,19 +26,24 @@
|
|||||||
"b": 255
|
"b": 255
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"r": 255,
|
"r": 0,
|
||||||
"g": 255,
|
"g": 255,
|
||||||
"b": 255
|
"b": 255
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"r": 255,
|
"r": 255,
|
||||||
"g": 128,
|
"g": 0,
|
||||||
"b": 128
|
"b": 255
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"r": 108,
|
||||||
|
"g": 255,
|
||||||
|
"b": 255
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"selected_color_indices": [
|
"selected_color_indices": [
|
||||||
4,
|
5,
|
||||||
3
|
2
|
||||||
],
|
],
|
||||||
"pattern_parameters": {
|
"pattern_parameters": {
|
||||||
"alternating": {
|
"alternating": {
|
||||||
@@ -127,6 +127,13 @@
|
|||||||
"delay": 100,
|
"delay": 100,
|
||||||
"n1": 21,
|
"n1": 21,
|
||||||
"n2": 60,
|
"n2": 60,
|
||||||
|
"n3": 28,
|
||||||
|
"n4": 1
|
||||||
|
},
|
||||||
|
"ap": {
|
||||||
|
"delay": 100,
|
||||||
|
"n1": 10,
|
||||||
|
"n2": 10,
|
||||||
"n3": 1,
|
"n3": 1,
|
||||||
"n4": 1
|
"n4": 1
|
||||||
}
|
}
|
||||||
|
@@ -384,29 +384,34 @@ class LightingController:
|
|||||||
color_b = self._palette_color(1)
|
color_b = self._palette_color(1)
|
||||||
phase = self.beat_index % 2
|
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 = {
|
payload = {
|
||||||
"d": {
|
"d": {
|
||||||
"t": "b",
|
"t": "b",
|
||||||
"pt": "a", # alternating
|
"pt": "a", # alternating
|
||||||
"n1": self.n1,
|
"n1": self.n1,
|
||||||
"n2": self.n2,
|
"n2": self.n2,
|
||||||
# Default color for bars not overridden (keeps payload small)
|
# Default color for non-swapped bars changes with phase
|
||||||
"cl": [color_a],
|
"cl": [default_color],
|
||||||
"s": phase,
|
"s": phase,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Bars in this list will have inverted phase and explicit color override
|
# Bars in this list will have inverted phase and explicit color override
|
||||||
swap_bars = ["101", "103", "105", "107"]
|
# Flip grouping so first four bars (100-103) use default color (color_a on even beats)
|
||||||
for bar_name in LED_BAR_NAMES:
|
swap_bars = ["104", "105", "106", "107"]
|
||||||
if bar_name in swap_bars:
|
# Only include overrides for swapped bars to minimize payload size
|
||||||
# Invert phase and explicitly set alternate color
|
for bar_name in swap_bars:
|
||||||
inv_phase = (phase + 1) % 2
|
inv_phase = (phase + 1) % 2
|
||||||
alt_color = color_b if phase == 0 else color_a
|
payload[bar_name] = {"s": inv_phase, "cl": [alt_color_for_swap]}
|
||||||
payload[bar_name] = {"s": inv_phase, "cl": [alt_color]}
|
|
||||||
else:
|
|
||||||
# Keep default (no extra fields) to save bytes
|
|
||||||
payload[bar_name] = {}
|
|
||||||
|
|
||||||
await self.led_controller.send_data(payload)
|
await self.led_controller.send_data(payload)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user