fix: stabilize RGB startup and color transitions

This commit is contained in:
way
2026-09-27 15:03:15 +08:00
parent 2f82cc36b4
commit 38362be824
4 changed files with 20 additions and 14 deletions
+13 -7
View File
@@ -493,9 +493,12 @@ def rgb_flash(mode,on):
if not on:
mcu(0x07,0x00)
else:
mcu(0x00,0xff); time.sleep(RGB_WRITE_DELAY_MS/1000.0)
mcu(0x01,channels[0]); time.sleep(RGB_WRITE_DELAY_MS/1000.0)
mcu(0x02,channels[1]); time.sleep(RGB_WRITE_DELAY_MS/1000.0)
# Keep the seller's selector -> R -> G -> B protocol contiguous. A
# visible delay between these writes lets the MCU render stale partial
# channel data, which appears as a brief unrelated color or chase.
mcu(0x00,0xff)
mcu(0x01,channels[0])
mcu(0x02,channels[1])
mcu(0x03,channels[2])
_last_rgb=state
@@ -503,10 +506,10 @@ def rgb_static(channels,state_name):
global _last_rgb
state=(state_name,channels)
if _last_rgb==state: return
mcu(0x07,0x00); time.sleep(RGB_WRITE_DELAY_MS/1000.0)
mcu(0x00,0xff); time.sleep(RGB_WRITE_DELAY_MS/1000.0)
mcu(0x01,channels[0]); time.sleep(RGB_WRITE_DELAY_MS/1000.0)
mcu(0x02,channels[1]); time.sleep(RGB_WRITE_DELAY_MS/1000.0)
mcu(0x07,0x00)
mcu(0x00,0xff)
mcu(0x01,channels[0])
mcu(0x02,channels[1])
mcu(0x03,channels[2])
_last_rgb=state
@@ -818,6 +821,9 @@ latest=(0.0,0.0,0.0,0.0)
display=DisplayController()
try:
bus=SMBus(1)
# Quench the MCU's power-on RGB effect before OLED initialization and all
# other startup work. The display controller remains the sole RGB owner.
rgb_off()
FONT5=Path(FONT_PATH).read_bytes()
display.start(); apply_dark_mode()
log("INFO","START",version=APP_VERSION,uptime=uptime_seconds())