kopia lustrzana https://github.com/OpenRTX/OpenRTX
Events: More events changes
rodzic
3e461e6b80
commit
94b37d9137
|
@ -42,8 +42,8 @@ enum eventType_t
|
||||||
*/
|
*/
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
uint32_t type : 3,
|
uint32_t type : 3;
|
||||||
uint32_t payload : 29
|
uint32_t payload : 29;
|
||||||
}event_t;
|
}event_t;
|
||||||
|
|
||||||
#endif /* EVENT_H */
|
#endif /* EVENT_H */
|
||||||
|
|
|
@ -58,8 +58,6 @@ enum keys
|
||||||
KEY_F8 = (1 << 26), /* Function button (device specific) */
|
KEY_F8 = (1 << 26), /* Function button (device specific) */
|
||||||
KEY_F9 = (1 << 27), /* Function button (device specific) */
|
KEY_F9 = (1 << 27), /* Function button (device specific) */
|
||||||
KEY_F10 = (1 << 28), /* 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) */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include <state.h>
|
#include <state.h>
|
||||||
#include <keyboard.h>
|
#include <keyboard.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <event.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function initialises the User Interface, starting the
|
* 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
|
* This function advances the User Interface FSM, basing on the
|
||||||
* current radio state and the keys pressed.
|
* 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 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.
|
* This function redraws the GUI based on the last radio state.
|
||||||
|
|
|
@ -26,14 +26,14 @@
|
||||||
#include <graphics.h>
|
#include <graphics.h>
|
||||||
#include <platform.h>
|
#include <platform.h>
|
||||||
#include <hwconfig.h>
|
#include <hwconfig.h>
|
||||||
#include <events.h>
|
#include <event.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
/* Mutex for concurrent access to state variable */
|
/* Mutex for concurrent access to state variable */
|
||||||
static OS_MUTEX state_mutex;
|
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;
|
static OS_Q ui_queue;
|
||||||
|
|
||||||
/**************************** IMPORTANT NOTE ***********************************
|
/**************************** IMPORTANT NOTE ***********************************
|
||||||
|
@ -103,9 +103,8 @@ static void ui_task(void *arg)
|
||||||
|
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
// Read from the keyboard queue (returns 0 if no message is present)
|
// Wait to receive an event message
|
||||||
// Copy keyboard_t keys from received void * pointer msg
|
event_t event = (event_t)OSQPend(&ui_queue, 0u, OS_OPT_PEND_BLOCKING,
|
||||||
event_t event = OSQPend(&ui_queue, 0u, OS_OPT_PEND_NON_BLOCKING,
|
|
||||||
&msg_size, 0u, &os_err);
|
&msg_size, 0u, &os_err);
|
||||||
// Lock mutex, read and write state
|
// Lock mutex, read and write state
|
||||||
OSMutexPend(&state_mutex, 0u, OS_OPT_PEND_BLOCKING, 0u, &os_err);
|
OSMutexPend(&state_mutex, 0u, OS_OPT_PEND_BLOCKING, 0u, &os_err);
|
||||||
|
@ -125,8 +124,10 @@ static void ui_task(void *arg)
|
||||||
while(gfx_renderingInProgress());
|
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
|
// 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;
|
event_t kbd_msg;
|
||||||
kbd_msg.type = EVENT_KBD;
|
kbd_msg.type = EVENT_KBD;
|
||||||
kbd_msg.payload = keys;
|
kbd_msg.payload = keys;
|
||||||
|
void * msg = (void *) kbd_msg;
|
||||||
// Send keyboard status in queue
|
// 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);
|
OS_OPT_POST_FIFO + OS_OPT_POST_NO_SCHED, &os_err);
|
||||||
}
|
}
|
||||||
// Read keyboard state at 5Hz
|
// Read keyboard state at 5Hz
|
||||||
|
|
|
@ -291,10 +291,14 @@ void ui_drawSplashScreen()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void ui_updateFSM(state_t last_state, keyboard_t keys)
|
void ui_updateFSM(state_t last_state, event_t event)
|
||||||
{
|
{
|
||||||
(void) last_state;
|
(void) last_state;
|
||||||
|
|
||||||
|
// Process pressed keys
|
||||||
|
if(event.type = EVENT_KBD)
|
||||||
|
{
|
||||||
|
keyboard_t keys = event.payload;
|
||||||
// Temporary VFO controls
|
// Temporary VFO controls
|
||||||
if(keys & KEY_UP)
|
if(keys & KEY_UP)
|
||||||
{
|
{
|
||||||
|
@ -309,6 +313,7 @@ void ui_updateFSM(state_t last_state, keyboard_t keys)
|
||||||
state.channel.rx_frequency -= 12500;
|
state.channel.rx_frequency -= 12500;
|
||||||
state.channel.tx_frequency -= 12500;
|
state.channel.tx_frequency -= 12500;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ui_updateGUI(state_t last_state)
|
bool ui_updateGUI(state_t last_state)
|
||||||
|
|
Ładowanie…
Reference in New Issue