Avoid repeated writes into the shift register
May reduce flickering of LEDs on some boardspull/135/head
parent
22522c253f
commit
6294e39746
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue