UI: Add VFO frequency change

replace/0c928ceb4fca652a850195c0dda3e3f530c73655
Federico Amedeo Izzo 2020-11-26 22:44:39 +01:00
rodzic 32bbbfb9de
commit 82be1afe17
3 zmienionych plików z 38 dodań i 7 usunięć

Wyświetl plik

@ -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.

Wyświetl plik

@ -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)
{

Wyświetl plik

@ -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;
}