Avoid repeated writes into the shift register

May reduce flickering of LEDs on some boards
pull/135/head
D.R.racer 2021-10-22 13:46:01 +02:00 committed by DRracer
parent 22522c253f
commit 6294e39746
2 changed files with 7 additions and 2 deletions

View File

@ -49,8 +49,10 @@ void LEDs::Step() {
result <<= 1; result <<= 1;
result |= leds[i].Step(oddPeriod); result |= leds[i].Step(oddPeriod);
} }
if (result != cachedState) {
hal::shr16::shr16.SetLED(result); hal::shr16::shr16.SetLED(result);
cachedState = result;
}
} }
} // namespace leds } // namespace leds

View File

@ -130,6 +130,9 @@ private:
/// [8] - green LED slot 4 /// [8] - green LED slot 4
/// [9] - red LED slot 4 /// [9] - red LED slot 4
LED leds[ledPairs * 2]; 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 /// The one and only instance of FINDA in the FW