led flash not working ma vabbeh
This commit is contained in:
@@ -31,23 +31,27 @@ namespace drivers
|
||||
void Led::flashHandle(TimerHandle_t th)
|
||||
{
|
||||
Led *led = (Led *)pvTimerGetTimerID(th);
|
||||
std::lock_guard<std::mutex> lock(led->m_ledMutex);
|
||||
rgbLedWrite(led->c_ledPin, led->m_colorDefault.g, led->m_colorDefault.r, led->m_colorDefault.b); // reset color to saved color
|
||||
LOG_DEBUG("Led Flash timer expired");
|
||||
xTimerDelete(th, 0);
|
||||
led->m_flashTimer = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
void Led::flashColor(const uint16_t tOn, const color_t color)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_ledMutex);
|
||||
rgbLedWrite(c_ledPin, color.g, color.r, color.b); // set color to flash
|
||||
if (m_flashTimer == NULL)
|
||||
{
|
||||
blinkStop();
|
||||
rgbLedWrite(c_ledPin, color.g, color.r, color.b); // set color to flash
|
||||
m_flashTimer = xTimerCreate("flasher", pdMS_TO_TICKS(tOn), pdFALSE, this, flashHandle);
|
||||
m_flashTimer = xTimerCreate("flasher", pdMS_TO_TICKS(tOn), pdFALSE, NULL, flashHandle);
|
||||
xTimerStart(m_flashTimer, 0);
|
||||
LOG_DEBUG("Led Flash timer created");
|
||||
LOG_INFO("Led Flash timer created");
|
||||
return;
|
||||
}
|
||||
xTimerStop(m_flashTimer, 0);
|
||||
if (!xTimerChangePeriod(m_flashTimer, pdMS_TO_TICKS(tOn), pdMS_TO_TICKS(1)) || !xTimerReset(m_flashTimer, pdMS_TO_TICKS(1)))
|
||||
{
|
||||
LOG_ERROR("Led Flash timer failed reset");
|
||||
xTimerDelete(m_flashTimer, 0);
|
||||
m_flashTimer = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user