diff --git a/src/modules/leds.cpp b/src/modules/leds.cpp index fc7ac97..5d58415 100644 --- a/src/modules/leds.cpp +++ b/src/modules/leds.cpp @@ -49,8 +49,10 @@ void LEDs::Step() { result <<= 1; result |= leds[i].Step(oddPeriod); } - - hal::shr16::shr16.SetLED(result); + if (result != cachedState) { + hal::shr16::shr16.SetLED(result); + cachedState = result; + } } } // namespace leds diff --git a/src/modules/leds.h b/src/modules/leds.h index 93a2e82..c2afcb0 100644 --- a/src/modules/leds.h +++ b/src/modules/leds.h @@ -130,6 +130,9 @@ private: /// [8] - green LED slot 4 /// [9] - red LED slot 4 LED leds[ledPairs * 2]; + + /// Cache for avoiding duplicit writes into the shift registers (may reduce LED flickering on some boards) + uint16_t cachedState = 0; }; /// The one and only instance of FINDA in the FW