UI: Add VFO frequency change
This commit is contained in:
parent
32bbbfb9de
commit
82be1afe17
|
|
@ -32,12 +32,18 @@ void ui_init();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function advances the User Interface FSM, basing on the
|
* 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 last_state: A local copy of the previous radio state
|
||||||
* @param keys: A bitmap containing the currently pressed keys
|
* @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
|
* @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.
|
* This function writes the OpenRTX splash screen image into the framebuffer.
|
||||||
|
|
|
||||||
|
|
@ -77,17 +77,26 @@ static void ui_task(void *arg)
|
||||||
// Unlock the mutex
|
// Unlock the mutex
|
||||||
OSMutexPost(&state_mutex, OS_OPT_POST_NONE, &os_err);
|
OSMutexPost(&state_mutex, OS_OPT_POST_NONE, &os_err);
|
||||||
|
|
||||||
|
uint32_t last_keys = 0;
|
||||||
|
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
uint32_t keys = kbd_getKeys();
|
uint32_t keys = kbd_getKeys();
|
||||||
// React to keypresses and redraw GUI
|
if(keys != last_keys)
|
||||||
bool renderNeeded = ui_update(last_state, keys);
|
{
|
||||||
|
printf("Keys changed!\n");
|
||||||
|
last_keys = keys;
|
||||||
|
}
|
||||||
// Wait for unlocked mutex and lock it
|
// Wait for unlocked mutex and lock it
|
||||||
OSMutexPend(&state_mutex, 0u, OS_OPT_PEND_BLOCKING, 0u, &os_err);
|
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
|
// Update state local copy
|
||||||
last_state = state;
|
last_state = state;
|
||||||
// Unlock the mutex
|
// Unlock the mutex
|
||||||
OSMutexPost(&state_mutex, OS_OPT_POST_NONE, &os_err);
|
OSMutexPost(&state_mutex, OS_OPT_POST_NONE, &os_err);
|
||||||
|
// Redraw GUI
|
||||||
|
bool renderNeeded = ui_updateGUI(last_state);
|
||||||
|
|
||||||
if(renderNeeded)
|
if(renderNeeded)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -291,16 +291,32 @@ void ui_drawSplashScreen2()
|
||||||
yellow_fab413);
|
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)
|
if(!layout_ready)
|
||||||
{
|
{
|
||||||
layout = _ui_calculateLayout();
|
layout = _ui_calculateLayout();
|
||||||
layout_ready = true;
|
layout_ready = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool screen_update = ui_drawMainScreen(last_state);
|
bool screen_update = ui_drawMainScreen(last_state);
|
||||||
return screen_update;
|
return screen_update;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue