kopia lustrzana https://github.com/OpenRTX/OpenRTX
Changed parameters of ui_pushEvent(): now it accepts event type and payload instead of a single element, this cleans the code up a little bit
rodzic
57349cba80
commit
84d66ca1b3
|
@ -249,10 +249,11 @@ void ui_updateGUI();
|
|||
/**
|
||||
* Push an event to the UI event queue.
|
||||
*
|
||||
* @param event: event to be pushed.
|
||||
* @param type: event type.
|
||||
* @param data: event data.
|
||||
* @return true on success false on failure.
|
||||
*/
|
||||
bool ui_pushEvent(const event_t event);
|
||||
bool ui_pushEvent(const uint8_t type, const uint32_t data);
|
||||
|
||||
/**
|
||||
* This function terminates the User Interface.
|
||||
|
|
|
@ -49,7 +49,6 @@ void *ui_task(void *arg)
|
|||
{
|
||||
(void) arg;
|
||||
|
||||
event_t kbd_event = {{EVENT_KBD, 0}};
|
||||
kbd_msg_t kbd_msg;
|
||||
rtxStatus_t rtx_cfg;
|
||||
bool sync_rtx = true;
|
||||
|
@ -66,8 +65,7 @@ void *ui_task(void *arg)
|
|||
|
||||
if(input_scanKeyboard(&kbd_msg))
|
||||
{
|
||||
kbd_event.payload = kbd_msg.value;
|
||||
ui_pushEvent(kbd_event);
|
||||
ui_pushEvent(EVENT_KBD, kbd_msg.value);
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&state_mutex); // Lock r/w access to radio state
|
||||
|
@ -172,11 +170,7 @@ void *dev_task(void *arg)
|
|||
if((tick_5ms % 20) == 0)
|
||||
{
|
||||
state_update();
|
||||
|
||||
event_t dev_msg;
|
||||
dev_msg.type = EVENT_STATUS;
|
||||
dev_msg.payload = 0;
|
||||
ui_pushEvent(dev_msg);
|
||||
ui_pushEvent(EVENT_STATUS, 0);
|
||||
}
|
||||
|
||||
// Run this loop once every 5ms
|
||||
|
|
|
@ -1784,13 +1784,18 @@ void ui_updateGUI()
|
|||
}
|
||||
}
|
||||
|
||||
bool ui_pushEvent(const event_t event)
|
||||
bool ui_pushEvent(const uint8_t type, const uint32_t data)
|
||||
{
|
||||
uint8_t newHead = (evQueue_wrPos + 1) % MAX_NUM_EVENTS;
|
||||
|
||||
// Queue is full
|
||||
if(newHead == evQueue_rdPos) return false;
|
||||
|
||||
// Preserve atomicity when writing the new element into the queue.
|
||||
event_t event;
|
||||
event.type = type;
|
||||
event.payload = data;
|
||||
|
||||
evQueue[evQueue_wrPos] = event;
|
||||
evQueue_wrPos = newHead;
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue