Finish LED pattern before low-power sleep

Wait until no LEDs are blinking anymore before going to sleep.
Decrement LED blink counter before acting on the value, otherwise LED
state will always lag behind.
This commit is contained in:
Embedded Innovation
2016-11-08 20:06:53 +01:00
parent 9254b45150
commit 7f0e23b728
3 changed files with 44 additions and 28 deletions
+7
View File
@@ -520,6 +520,13 @@ int8_t _sleep(const uint32_t sleepingMS, const bool smartSleep, const uint8_t in
transportPowerDown();
#endif
#if defined (MY_DEFAULT_TX_LED_PIN) || defined(MY_DEFAULT_RX_LED_PIN) || defined(MY_DEFAULT_ERR_LED_PIN)
// Wait until leds finish their blinking pattern
while (ledsBlinking()) {
doYield();
}
#endif
setIndication(INDICATION_SLEEP);
int8_t result = MY_SLEEP_NOT_POSSIBLE; // default