diff --git a/openrtx/include/threads.h b/openrtx/include/threads.h index b4541507..90983b06 100644 --- a/openrtx/include/threads.h +++ b/openrtx/include/threads.h @@ -43,7 +43,7 @@ void create_threads(); /** * Stack size for state update task, in bytes. */ -#define STATE_TASK_STKSIZE 128*4 +#define STATE_TASK_STKSIZE 256*4 /** * Stack size for baseband control task, in bytes. diff --git a/openrtx/src/threads.c b/openrtx/src/threads.c index 2fce3f57..19f80793 100644 --- a/openrtx/src/threads.c +++ b/openrtx/src/threads.c @@ -101,6 +101,11 @@ static void ui_task(void *arg) state_t last_state = state; OSMutexPost(&state_mutex, OS_OPT_POST_NONE, &os_err); + // Initial GUI draw + ui_updateGUI(last_state); + gfx_render(); + while(gfx_renderingInProgress()); + while(1) { // Read from the keyboard queue (returns 0 if no message is present) @@ -175,6 +180,7 @@ static void state_task(void *arg) while(1) { + // Lock mutex and update internal state OSMutexPend(&state_mutex, 0u, OS_OPT_PEND_BLOCKING, 0u, &os_err); state.time = rtc_getTime(); @@ -182,6 +188,13 @@ static void state_task(void *arg) OSMutexPost(&state_mutex, OS_OPT_POST_NONE, &os_err); + // Signal state update to UI thread + event_t dev_msg; + dev_msg.type = EVENT_STATUS; + dev_msg.payload = 0; + OSQPost(&ui_queue, (void *)dev_msg.value, sizeof(event_t), + OS_OPT_POST_FIFO + OS_OPT_POST_NO_SCHED, &os_err); + // Execute state update thread every 1s OSTimeDlyHMSM(0u, 0u, 1u, 0u, OS_OPT_TIME_HMSM_STRICT, &os_err); } diff --git a/openrtx/src/ui.c b/openrtx/src/ui.c index e14072a1..6a0eb65c 100644 --- a/openrtx/src/ui.c +++ b/openrtx/src/ui.c @@ -296,7 +296,7 @@ void ui_updateFSM(state_t last_state, event_t event) (void) last_state; // Process pressed keys - if(event.type = EVENT_KBD) + if(event.type == EVENT_KBD) { keyboard_t keys = event.payload; // Temporary VFO controls