57 lines
1.0 KiB
C++
57 lines
1.0 KiB
C++
#include "led.h"
|
|
|
|
CRGB leds[NUM_LEDS];
|
|
|
|
bool ledstate = false;
|
|
uint32_t lastLedTime = 0;
|
|
|
|
void initLed(void)
|
|
{
|
|
FastLED.addLeds<SK6812, LED_PIN, GRB>(leds, NUM_LEDS); // GRB ordering is typical
|
|
FastLED.setBrightness(80);
|
|
}
|
|
|
|
void handleLed(void)
|
|
{
|
|
uint32_t timeNow = millis();
|
|
if (timeNow - lastLedTime > LEDTIMEOUT)
|
|
{
|
|
if (ledstate)
|
|
{
|
|
if (getPowerState() == POWERSTATES::on)
|
|
{
|
|
if(getAudioState())
|
|
{
|
|
leds[0] = CRGB::Purple;
|
|
}
|
|
else if( getRFIDlastUID() != "")
|
|
{
|
|
leds[0] = CRGB::Yellow;
|
|
}
|
|
else
|
|
{
|
|
leds[0] = CRGB::Green;
|
|
}
|
|
}
|
|
else if (getPowerState() == POWERSTATES::poweringOn2)
|
|
{
|
|
leds[0] = CRGB::Blue;
|
|
}
|
|
else if (getPowerState() == POWERSTATES::poweringOff2)
|
|
{
|
|
leds[0] = CRGB::Orange;
|
|
}
|
|
else
|
|
{
|
|
leds[0] = CRGB::Red;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
leds[0] = CRGB::Black;
|
|
}
|
|
FastLED.show();
|
|
ledstate = !ledstate;
|
|
lastLedTime = timeNow;
|
|
}
|
|
} |