ota update first version, with led management
This commit is contained in:
@@ -12,6 +12,7 @@ namespace drivers
|
||||
pinMode(c_ledPin, OUTPUT);
|
||||
m_blinkTask = NULL;
|
||||
m_flashTimer = NULL;
|
||||
m_enforce = false;
|
||||
}
|
||||
|
||||
Led::~Led()
|
||||
@@ -20,9 +21,16 @@ namespace drivers
|
||||
pinMode(c_ledPin, INPUT);
|
||||
}
|
||||
|
||||
void Led::setEnforce(const bool enf)
|
||||
{
|
||||
m_enforce = enf;
|
||||
}
|
||||
|
||||
void Led::setColor(const color_t color)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_ledMutex);
|
||||
if (m_enforce)
|
||||
return;
|
||||
blinkStop();
|
||||
m_colorDefault = color;
|
||||
rgbLedWrite(c_ledPin, color.g, color.r, color.b);
|
||||
@@ -58,6 +66,8 @@ namespace drivers
|
||||
void Led::blinkColor(const uint16_t tOn, const uint16_t tOff, const color_t color)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_ledMutex);
|
||||
if (m_enforce)
|
||||
return;
|
||||
blinkStop();
|
||||
m_color1 = color;
|
||||
m_color2 = {0, 0, 0};
|
||||
@@ -69,6 +79,8 @@ namespace drivers
|
||||
void Led::blinkAlternate(const uint16_t tOn, const uint16_t tOff, const color_t color1, const color_t color2)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_ledMutex);
|
||||
if (m_enforce)
|
||||
return;
|
||||
blinkStop();
|
||||
m_color1 = color1;
|
||||
m_color2 = color2;
|
||||
|
||||
@@ -21,6 +21,7 @@ namespace drivers
|
||||
uint8_t b;
|
||||
} color_t;
|
||||
|
||||
const color_t COLOR_OFF = {0, 0, 0};
|
||||
const color_t COLOR_RED = {255, 0, 0};
|
||||
const color_t COLOR_ORANGE = {255, 127, 0};
|
||||
const color_t COLOR_YELLOW = {255, 255, 0};
|
||||
@@ -36,6 +37,7 @@ namespace drivers
|
||||
Led();
|
||||
~Led();
|
||||
|
||||
void setEnforce(const bool enf);
|
||||
void setColor(const color_t color);
|
||||
void flashColor(const uint16_t tOn, const color_t color);
|
||||
void blinkColor(const uint16_t tOn, const uint16_t tOff, const color_t color);
|
||||
@@ -60,6 +62,7 @@ namespace drivers
|
||||
TimerHandle_t m_flashTimer;
|
||||
|
||||
bool m_flashing;
|
||||
bool m_enforce;
|
||||
|
||||
std::mutex m_ledMutex;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user