diff --git a/openrtx/include/ui.h b/openrtx/include/ui.h index 2f904fc5..ac555c46 100644 --- a/openrtx/include/ui.h +++ b/openrtx/include/ui.h @@ -32,12 +32,18 @@ void ui_init(); /** * This function advances the User Interface FSM, basing on the - * current radio state and the keys pressed and redraws the GUI. + * current radio state and the keys pressed. * @param last_state: A local copy of the previous radio state * @param keys: A bitmap containing the currently pressed keys + */ +void ui_updateFSM(state_t last_state, uint32_t keys); + +/** + * This function redraws the GUI based on the last radio state. + * @param last_state: A local copy of the previous radio state * @return true if a screen refresh is needed after the update */ -bool ui_update(state_t last_state, uint32_t keys); +bool ui_updateGUI(state_t last_state); /** * This function writes the OpenRTX splash screen image into the framebuffer. diff --git a/openrtx/src/threads.c b/openrtx/src/threads.c index 275e1b42..fd649004 100644 --- a/openrtx/src/threads.c +++ b/openrtx/src/threads.c @@ -77,17 +77,26 @@ static void ui_task(void *arg) // Unlock the mutex OSMutexPost(&state_mutex, OS_OPT_POST_NONE, &os_err); + uint32_t last_keys = 0; + while(1) { uint32_t keys = kbd_getKeys(); - // React to keypresses and redraw GUI - bool renderNeeded = ui_update(last_state, keys); + if(keys != last_keys) + { + printf("Keys changed!\n"); + last_keys = keys; + } // Wait for unlocked mutex and lock it OSMutexPend(&state_mutex, 0u, OS_OPT_PEND_BLOCKING, 0u, &os_err); + // React to keypresses and update FSM inside state + ui_updateFSM(last_state, keys); // Update state local copy last_state = state; // Unlock the mutex OSMutexPost(&state_mutex, OS_OPT_POST_NONE, &os_err); + // Redraw GUI + bool renderNeeded = ui_updateGUI(last_state); if(renderNeeded) { diff --git a/openrtx/src/ui.c b/openrtx/src/ui.c index 9ef9d0db..a2eb9179 100644 --- a/openrtx/src/ui.c +++ b/openrtx/src/ui.c @@ -291,16 +291,32 @@ void ui_drawSplashScreen2() yellow_fab413); } -bool ui_update(state_t last_state, uint32_t keys) +void ui_updateFSM(state_t last_state, uint32_t keys) { - (void) keys; + // Temporary VFO controls + if(keys && KEY_UP) + { + printf("Frequency UP\n"); + // Advance TX and RX frequency of 12.5KHz + state.channel.rx_frequency += 12500; + state.channel.tx_frequency += 12500; + } + if(keys && KEY_DOWN) + { + printf("Frequency DOWN\n"); + // Advance TX and RX frequency of 12.5KHz + state.channel.rx_frequency -= 12500; + state.channel.tx_frequency -= 12500; + } +} +bool ui_updateGUI(state_t last_state) +{ if(!layout_ready) { layout = _ui_calculateLayout(); layout_ready = true; } - bool screen_update = ui_drawMainScreen(last_state); return screen_update; }