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

pull/103/head
Silvano Seva 2022-08-10 13:59:46 +02:00
rodzic 57349cba80
commit 84d66ca1b3
3 zmienionych plików z 11 dodań i 11 usunięć

Wyświetl plik

@ -249,10 +249,11 @@ void ui_updateGUI();
/** /**
* Push an event to the UI event queue. * 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. * @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. * This function terminates the User Interface.

Wyświetl plik

@ -49,7 +49,6 @@ void *ui_task(void *arg)
{ {
(void) arg; (void) arg;
event_t kbd_event = {{EVENT_KBD, 0}};
kbd_msg_t kbd_msg; kbd_msg_t kbd_msg;
rtxStatus_t rtx_cfg; rtxStatus_t rtx_cfg;
bool sync_rtx = true; bool sync_rtx = true;
@ -66,8 +65,7 @@ void *ui_task(void *arg)
if(input_scanKeyboard(&kbd_msg)) if(input_scanKeyboard(&kbd_msg))
{ {
kbd_event.payload = kbd_msg.value; ui_pushEvent(EVENT_KBD, kbd_msg.value);
ui_pushEvent(kbd_event);
} }
pthread_mutex_lock(&state_mutex); // Lock r/w access to radio state 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) if((tick_5ms % 20) == 0)
{ {
state_update(); state_update();
ui_pushEvent(EVENT_STATUS, 0);
event_t dev_msg;
dev_msg.type = EVENT_STATUS;
dev_msg.payload = 0;
ui_pushEvent(dev_msg);
} }
// Run this loop once every 5ms // Run this loop once every 5ms

Wyświetl plik

@ -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; uint8_t newHead = (evQueue_wrPos + 1) % MAX_NUM_EVENTS;
// Queue is full // Queue is full
if(newHead == evQueue_rdPos) return false; 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[evQueue_wrPos] = event;
evQueue_wrPos = newHead; evQueue_wrPos = newHead;