54 lines
1.0 KiB
C++
54 lines
1.0 KiB
C++
|
#include "leds.h"
|
||
|
|
||
|
void processLEDState()
|
||
|
{
|
||
|
static uint16_t LEDArmedBlinkCount, LEDErrorBlinkCount;
|
||
|
|
||
|
if (LEDState != LED_ARMED) LEDArmedBlinkCount = 0;
|
||
|
if (LEDState != LED_ERROR) LEDErrorBlinkCount = 0;
|
||
|
|
||
|
switch (LEDState) {
|
||
|
case LED_OFF:
|
||
|
greenLEDOff();
|
||
|
redLEDOn();
|
||
|
|
||
|
break;
|
||
|
case LED_ARMED:
|
||
|
LEDArmedBlinkCount++;
|
||
|
|
||
|
if (LEDArmedBlinkCount < LED_ARMED_BLINK_TIME) {
|
||
|
greenLEDOn();
|
||
|
redLEDOn();
|
||
|
} else if (LEDArmedBlinkCount < LED_ARMED_BLINK_TIME * 2) {
|
||
|
greenLEDOff();
|
||
|
redLEDOn();
|
||
|
} else {
|
||
|
LEDArmedBlinkCount = 0;
|
||
|
}
|
||
|
break;
|
||
|
case LED_ON:
|
||
|
greenLEDOn();
|
||
|
redLEDOn();
|
||
|
|
||
|
break;
|
||
|
case LED_ERROR:
|
||
|
LEDErrorBlinkCount++;
|
||
|
|
||
|
if (LEDErrorBlinkCount < LED_ERROR_BLINK_TIME) {
|
||
|
greenLEDOff();
|
||
|
redLEDOff();
|
||
|
} else if (LEDErrorBlinkCount < LED_ERROR_BLINK_TIME * 2) {
|
||
|
greenLEDOff();
|
||
|
redLEDOn();
|
||
|
} else {
|
||
|
LEDErrorBlinkCount = 0;
|
||
|
LEDState = LED_OFF;
|
||
|
}
|
||
|
break;
|
||
|
default:
|
||
|
if (SERIAL_LOGGING) Serial.println("[ERROR] Invalid LED state.");
|
||
|
LEDState = LED_OFF;
|
||
|
break;
|
||
|
}
|
||
|
}
|