feature: blinking LEDS
This commit is contained in:
72
src/led.cpp
72
src/led.cpp
@@ -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 #
|
//# leds functions #
|
||||||
//#############################################
|
//#############################################
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
#include "vector"
|
#include "vector"
|
||||||
#include "board.h"
|
#include "board.h"
|
||||||
|
|
||||||
|
#define BLINKINTERVAL 200
|
||||||
|
|
||||||
enum e_ledcolor
|
enum e_ledcolor
|
||||||
{
|
{
|
||||||
YELLOW,
|
YELLOW,
|
||||||
@@ -97,6 +99,8 @@ void turnOnLed(uint16_t index);
|
|||||||
void turnOffAllLed(void);
|
void turnOffAllLed(void);
|
||||||
void turnOnAllLed(void);
|
void turnOnAllLed(void);
|
||||||
void setAllLeds( bool state);
|
void setAllLeds( bool state);
|
||||||
|
void blinkAllLeds(void);
|
||||||
|
void blinkLed(e_ledcolor blinkled);
|
||||||
|
|
||||||
|
|
||||||
#endif //LEDH
|
#endif //LEDH
|
||||||
|
|||||||
Reference in New Issue
Block a user