diff --git a/armsrc/rgb_indicator.c b/armsrc/rgb_indicator.c index a616d32f3..910676922 100644 --- a/armsrc/rgb_indicator.c +++ b/armsrc/rgb_indicator.c @@ -67,12 +67,16 @@ void rgb_indicator_update(void) { if (on_battery == last_state) { return; // edge-triggered: only write RGB when the state changes } - last_state = on_battery; - if (on_battery) { - RgbLedSet(0, 8, 0); // dim green: alive, on battery - } else { - RgbLedSet(0, 0, 0); // on USB: off (cable already signals power) + // Commit last_state only if the controller actually ACKed. On a cold boot the + // I2C RGB controller can still be powering up when the first write fires; if we + // latched last_state regardless, a NAK here would leave the LED dark until the + // next state change (which never comes on battery). Retrying next cycle costs + // one I2C poke and self-heals once the controller is ready. + bool ok = on_battery ? RgbLedSet(0, 8, 0) // dim green: alive, on battery + : RgbLedSet(0, 0, 0); // on USB: off (cable already signals power) + if (ok) { + last_state = on_battery; } }