Hi all,
I’m building a project (advanced kitchen timer) where code is stuck over time.
I’m curious if I am implementing the timer functions efficiently.
When the user turns the rotary knob I increase/decrease the timer value to the timer_task by sending an event to the lcd queue from the rotary ISR:
...
xQueueSendFromISR( lcd_event_queue, &event, NULL );
This way timer_task sees someone is increment or decrement the time and because I do not want to fight against de decrementing timer I first start a one-shot 3sec software timer and send a notification to the backlight task to light up the LCD:
xTimerStart(LcdTimerHndl3Sec, 0);
if (!backlightison)
{
xTaskNotify( TaskBacklightHandle, 1, eSetValueWithOverwrite );
backlightison = true;
}
The 3sec timer callback starts the 1sec timer that sends decrementing 1sec events to lcd_task:
static void vLcdTimerCallback3SecExpired(TimerHandle_t pxTimer) {
xTimerStart(LcdTimerHndl1Sec, 0);
}
static void vLcdTimerCallback1SecExpired(TimerHandle_t pxTimer) {
lcd_event_t event = { 0 };
event.ucMessageID = 77;
event.ucValue = 3;
//non-blocking here!!
xQueueSend( lcd_event_queue, ( void * ) &event, 0);
}
Eventually my code stuck, not entirely sure if it is because of this, but nesting software timers seems a bit tricky to me.
Can I always be sure timer events arrive and are handled?
Because this way of programming has a lot of assumptions
Is it good practice to do something like this:
static void vLcdTimerCallback3SecExpired(TimerHandle_t pxTimer) {
while( xTimerStart(LcdTimerHndl1Sec, 0) != pdPASS );
}