Events: More events changes

replace/e6166f5981e1e38f35f6ab0a8c1b7e62f32a65cd
Federico Amedeo Izzo 2020-12-05 18:40:08 +01:00
rodzic 3e461e6b80
commit 94b37d9137
5 zmienionych plików z 32 dodań i 26 usunięć

Wyświetl plik

@ -42,8 +42,8 @@ enum eventType_t
*/
typedef struct
{
uint32_t type : 3,
uint32_t payload : 29
uint32_t type : 3;
uint32_t payload : 29;
}event_t;
#endif /* EVENT_H */

Wyświetl plik

@ -58,8 +58,6 @@ enum keys
KEY_F8 = (1 << 26), /* Function button (device specific) */
KEY_F9 = (1 << 27), /* Function button (device specific) */
KEY_F10 = (1 << 28), /* Function button (device specific) */
KEY_F11 = (1 << 29), /* Function button (device specific) */
KEY_F12 = (1 << 30) /* Function button (device specific) */
};
/**

Wyświetl plik

@ -24,6 +24,7 @@
#include <state.h>
#include <keyboard.h>
#include <stdint.h>
#include <event.h>
/**
* This function initialises the User Interface, starting the
@ -35,9 +36,9 @@ void ui_init();
* This function advances the User Interface FSM, basing on the
* 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
* @param event: An event from other threads
*/
void ui_updateFSM(state_t last_state, keyboard_t keys);
void ui_updateFSM(state_t last_state, event_t event);
/**
* This function redraws the GUI based on the last radio state.

Wyświetl plik

@ -26,14 +26,14 @@
#include <graphics.h>
#include <platform.h>
#include <hwconfig.h>
#include <events.h>
#include <event.h>
#include <stdio.h>
/* Mutex for concurrent access to state variable */
static OS_MUTEX state_mutex;
/* Queue for sending and receiving keyboard status */
/* Queue for sending and receiving ui update requests */
static OS_Q ui_queue;
/**************************** IMPORTANT NOTE ***********************************
@ -103,9 +103,8 @@ static void ui_task(void *arg)
while(1)
{
// Read from the keyboard queue (returns 0 if no message is present)
// Copy keyboard_t keys from received void * pointer msg
event_t event = OSQPend(&ui_queue, 0u, OS_OPT_PEND_NON_BLOCKING,
// Wait to receive an event message
event_t event = (event_t)OSQPend(&ui_queue, 0u, OS_OPT_PEND_BLOCKING,
&msg_size, 0u, &os_err);
// Lock mutex, read and write state
OSMutexPend(&state_mutex, 0u, OS_OPT_PEND_BLOCKING, 0u, &os_err);
@ -125,8 +124,10 @@ static void ui_task(void *arg)
while(gfx_renderingInProgress());
}
// We don't need a delay because we lock on incoming events
// TODO: Enable self refresh when a continuous visualization is enabled
// Update UI at ~33 FPS
OSTimeDlyHMSM(0u, 0u, 0u, 30u, OS_OPT_TIME_HMSM_STRICT, &os_err);
//OSTimeDlyHMSM(0u, 0u, 0u, 30u, OS_OPT_TIME_HMSM_STRICT, &os_err);
}
}
@ -151,8 +152,9 @@ static void kbd_task(void *arg)
event_t kbd_msg;
kbd_msg.type = EVENT_KBD;
kbd_msg.payload = keys;
void * msg = (void *) kbd_msg;
// Send keyboard status in queue
OSQPost(&ui_queue, (void *)kbd_msg, sizeof(event_t),
OSQPost(&ui_queue, msg, sizeof(event_t),
OS_OPT_POST_FIFO + OS_OPT_POST_NO_SCHED, &os_err);
}
// Read keyboard state at 5Hz

Wyświetl plik

@ -291,10 +291,14 @@ void ui_drawSplashScreen()
#endif
}
void ui_updateFSM(state_t last_state, keyboard_t keys)
void ui_updateFSM(state_t last_state, event_t event)
{
(void) last_state;
// Process pressed keys
if(event.type = EVENT_KBD)
{
keyboard_t keys = event.payload;
// Temporary VFO controls
if(keys & KEY_UP)
{
@ -310,6 +314,7 @@ void ui_updateFSM(state_t last_state, keyboard_t keys)
state.channel.tx_frequency -= 12500;
}
}
}
bool ui_updateGUI(state_t last_state)
{