blink the comm LED slightly instead of static

This commit is contained in:
Matthew Kennedy 2024-06-27 17:55:02 -07:00
parent 938852e139
commit 45a6b5d134
2 changed files with 12 additions and 3 deletions

View File

@ -108,6 +108,7 @@ private:
void updateCommsLed();
void updateErrorLed();
size_t m_commBlinkCounter = 0;
size_t m_errorBlinkCounter = 0;
};

View File

@ -415,8 +415,8 @@ void onDataArrived() {
}
void LedBlinkingTask::updateCommsLed() {
// USB unplugged -> off (or no USB)
// USB plugged in -> on
// USB unplugged (or no USB) -> off, blink on
// USB plugged in -> on, blink off
// Data transferring -> flashing
if (consoleByteArrived.exchange(false)) {
@ -430,7 +430,15 @@ void LedBlinkingTask::updateCommsLed() {
#endif
;
enginePins.communicationLedPin.setValue(usbReady);
// toggle the state 1/20 of the time so it blinks at you a little
bool ledState = usbReady ^ (m_commBlinkCounter >= 19);
enginePins.communicationLedPin.setValue(ledState);
if (m_commBlinkCounter == 0) {
m_commBlinkCounter = 20;
}
m_commBlinkCounter--;
}
}