Interrupt issue with FastLed circumvented
This commit is contained in:
16
gauge.py
16
gauge.py
@@ -224,12 +224,15 @@ def set_status_led(gauge_idx, led_type, on):
|
||||
|
||||
|
||||
def _apply_blink_or_led(gauge_idx, led_idx, color, effect):
|
||||
"""Set LED to color; if effect is a known blink preset, start blinking."""
|
||||
"""Set LED to color, optionally starting a blink effect.
|
||||
When blinking, color is passed inside the BLINK command so only one
|
||||
serial command is needed — avoids a FastLED.show() race on the Arduino."""
|
||||
r, g, b = color
|
||||
arduino_send(f"LED {gauge_idx} {led_idx} {r} {g} {b}")
|
||||
if effect in _BLINK_PRESETS:
|
||||
on_ms, off_ms = _BLINK_PRESETS[effect]
|
||||
arduino_send(f"BLINK {gauge_idx} {led_idx} {on_ms} {off_ms}")
|
||||
arduino_send(f"BLINK {gauge_idx} {led_idx} {on_ms} {off_ms} {r} {g} {b}")
|
||||
else:
|
||||
arduino_send(f"LED {gauge_idx} {led_idx} {r} {g} {b}")
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -553,12 +556,13 @@ def on_message(topic, payload):
|
||||
return
|
||||
_bl_effect[i] = effect
|
||||
if effect:
|
||||
set_backlight(i, r, g, b, brightness)
|
||||
scale = brightness / 100
|
||||
rs = int(r * scale); gs = int(g * scale); bs_ = int(b * scale)
|
||||
on_ms, off_ms = _BLINK_PRESETS[effect]
|
||||
arduino_send(f"BLINK {i} {_LED_BACKLIGHT_RANGE} {on_ms} {off_ms} {rs} {gs} {bs_}")
|
||||
backlight_color[i] = (r, g, b)
|
||||
backlight_brightness[i] = brightness
|
||||
backlight_on[i] = True
|
||||
on_ms, off_ms = _BLINK_PRESETS[effect]
|
||||
arduino_send(f"BLINK {i} {_LED_BACKLIGHT_RANGE} {on_ms} {off_ms}")
|
||||
_mark_bl_dirty()
|
||||
else:
|
||||
set_backlight_color(i, r, g, b, brightness)
|
||||
|
||||
Reference in New Issue
Block a user