feature: blinking LEDS

This commit is contained in:
2021-10-23 12:01:35 +02:00
parent 56c3f749e1
commit 2e5caea417
2 changed files with 76 additions and 0 deletions

View File

@@ -71,6 +71,78 @@ void setAllLeds( bool state)
}
}
uint32_t lasttime = 0;
bool laststate = false;
void blinkAllLeds(void)
{
uint32_t timeNow = millis();
if(timeNow - lasttime > BLINKINTERVAL)
{
if(laststate)
{
turnOnAllLed();
laststate = false;
}
else
{
turnOffAllLed();
laststate = true;
}
lasttime = timeNow;
}
}
void blinkLed(e_ledcolor blinkled)
{
uint32_t timeNow = millis();
if(timeNow - lasttime > BLINKINTERVAL)
{
if(laststate)
{
turnOnLed(blinkled);
laststate = false;
}
else
{
turnOffLed(blinkled);
laststate = true;
}
lasttime = timeNow;
}
}
//e_ledcolor lastLed = e_ledcolor::YELLOW;
// void runningLeds(void)
// {
// uint32_t timeNow = millis();
// if(timeNow - lasttime > BLINKINTERVAL)
// {
// switch (lastLed)
// {
// case e_ledcolor::YELLOW:
// turnOffAllLed();
// turnOnLed(YELLOW);
// lastLed = e_ledcolor::RED;
// break;
// case e_ledcolor::RED:
// turnOffAllLed();
// turnOnLed(RED);
// lastLed = e_ledcolor::GREEN;
// break;
// case e_ledcolor::GREEN:
// turnOffAllLed();
// turnOnLed(GREEN);
// lastLed = e_ledcolor::YELLOW;
// break;
// default:
// break;
// }
// lasttime = timeNow;
// }
// }
//#############################################
//# leds functions #
//#############################################

View File

@@ -5,6 +5,8 @@
#include "vector"
#include "board.h"
#define BLINKINTERVAL 200
enum e_ledcolor
{
YELLOW,
@@ -97,6 +99,8 @@ void turnOnLed(uint16_t index);
void turnOffAllLed(void);
void turnOnAllLed(void);
void setAllLeds( bool state);
void blinkAllLeds(void);
void blinkLed(e_ledcolor blinkled);
#endif //LEDH