kopia lustrzana https://github.com/OpenRTX/OpenRTX
Increased UI task stack size to 1kB, fixed some compiler warnings, code cleanup pass
rodzic
82be1afe17
commit
bf24c31be7
|
@ -31,7 +31,7 @@ void create_threads();
|
|||
/**
|
||||
* Stack size for UI task, in bytes.
|
||||
*/
|
||||
#define UI_TASK_STKSIZE 128
|
||||
#define UI_TASK_STKSIZE 1024
|
||||
|
||||
/**
|
||||
* Stack size for state update task, in bytes.
|
||||
|
|
|
@ -27,27 +27,31 @@
|
|||
#include <platform.h>
|
||||
#include <hwconfig.h>
|
||||
|
||||
// Allocate state mutex
|
||||
#include <stdio.h>
|
||||
|
||||
/* Mutex for concurrent access to state variable */
|
||||
static OS_MUTEX state_mutex;
|
||||
|
||||
// Allocate UI task control block and stack
|
||||
/* UI task control block and stack */
|
||||
static OS_TCB ui_tcb;
|
||||
static CPU_STK ui_stk[UI_TASK_STKSIZE];
|
||||
|
||||
// Allocate state task control block and stack
|
||||
/* State task control block and stack */
|
||||
static OS_TCB state_tcb;
|
||||
static CPU_STK state_stk[STATE_TASK_STKSIZE];
|
||||
|
||||
// Allocate baseband task control block and stack
|
||||
/* Baseband task control block and stack */
|
||||
static OS_TCB rtx_tcb;
|
||||
static CPU_STK rtx_stk[RTX_TASK_STKSIZE];
|
||||
|
||||
// Allocate DMR task control block and stack
|
||||
/* DMR task control block and stack */
|
||||
static OS_TCB dmr_tcb;
|
||||
static CPU_STK dmr_stk[DMR_TASK_STKSIZE];
|
||||
|
||||
|
||||
// UI update task
|
||||
/**
|
||||
* \internal Task function in charge of updating the UI.
|
||||
*/
|
||||
static void ui_task(void *arg)
|
||||
{
|
||||
(void) arg;
|
||||
|
@ -61,20 +65,20 @@ static void ui_task(void *arg)
|
|||
ui_init();
|
||||
|
||||
// Display splash screen
|
||||
ui_drawSplashScreen2();
|
||||
ui_drawSplashScreen();
|
||||
gfx_render();
|
||||
while(gfx_renderingInProgress());
|
||||
// Wait 30ms to hide random pixels on screen
|
||||
|
||||
// Wait 30ms before turning on backlight to hide random pixels on screen
|
||||
OSTimeDlyHMSM(0u, 0u, 0u, 30u, OS_OPT_TIME_HMSM_STRICT, &os_err);
|
||||
platform_setBacklightLevel(255);
|
||||
|
||||
// Keep the splash screen for 1 second
|
||||
OSTimeDlyHMSM(0u, 0u, 1u, 0u, OS_OPT_TIME_HMSM_STRICT, &os_err);
|
||||
|
||||
// Get initial state local copy
|
||||
// Wait for unlocked mutex and lock it
|
||||
OSMutexPend(&state_mutex, 0u, OS_OPT_PEND_BLOCKING, 0u, &os_err);
|
||||
state_t last_state = state;
|
||||
// Unlock the mutex
|
||||
OSMutexPost(&state_mutex, OS_OPT_POST_NONE, &os_err);
|
||||
|
||||
uint32_t last_keys = 0;
|
||||
|
@ -84,17 +88,18 @@ static void ui_task(void *arg)
|
|||
uint32_t keys = kbd_getKeys();
|
||||
if(keys != last_keys)
|
||||
{
|
||||
printf("Keys changed!\n");
|
||||
last_keys = keys;
|
||||
}
|
||||
// Wait for unlocked mutex and lock it
|
||||
|
||||
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
|
||||
last_state = state;
|
||||
// Unlock the mutex
|
||||
|
||||
OSMutexPost(&state_mutex, OS_OPT_POST_NONE, &os_err);
|
||||
|
||||
// Redraw GUI
|
||||
bool renderNeeded = ui_updateGUI(last_state);
|
||||
|
||||
|
@ -109,7 +114,9 @@ static void ui_task(void *arg)
|
|||
}
|
||||
}
|
||||
|
||||
// State update task
|
||||
/**
|
||||
* \internal Task function in charge of updating the radio state.
|
||||
*/
|
||||
static void state_task(void *arg)
|
||||
{
|
||||
(void) arg;
|
||||
|
@ -117,21 +124,21 @@ static void state_task(void *arg)
|
|||
|
||||
while(1)
|
||||
{
|
||||
// Wait for unlocked mutex and lock it
|
||||
OSMutexPend(&state_mutex, 0u, OS_OPT_PEND_BLOCKING, 0u, &os_err);
|
||||
|
||||
state.time = rtc_getTime();
|
||||
state.v_bat = platform_getVbat();
|
||||
|
||||
// Unlock the mutex
|
||||
|
||||
OSMutexPost(&state_mutex, OS_OPT_POST_NONE, &os_err);
|
||||
|
||||
|
||||
// Execute state update thread every 1s
|
||||
OSTimeDlyHMSM(0u, 0u, 1u, 0u, OS_OPT_TIME_HMSM_STRICT, &os_err);
|
||||
}
|
||||
}
|
||||
|
||||
// RTX task
|
||||
/**
|
||||
* \internal Task function for RTX management.
|
||||
*/
|
||||
static void rtx_task(void *arg)
|
||||
{
|
||||
(void) arg;
|
||||
|
@ -146,8 +153,9 @@ static void rtx_task(void *arg)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// DMR task
|
||||
/**
|
||||
* \internal Task function for DMR management.
|
||||
*/
|
||||
static void dmr_task(void *arg)
|
||||
{
|
||||
(void) arg;
|
||||
|
@ -162,6 +170,9 @@ static void dmr_task(void *arg)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \internal This function creates all the system tasks and mutexes.
|
||||
*/
|
||||
void create_threads()
|
||||
{
|
||||
OS_ERR os_err;
|
||||
|
|
|
@ -221,23 +221,24 @@ void _ui_drawVFO(state_t* state)
|
|||
{
|
||||
// Print VFO frequencies
|
||||
char freq_buf[20] = "";
|
||||
snprintf(freq_buf, sizeof(freq_buf), "Rx: %03d.%05d",
|
||||
snprintf(freq_buf, sizeof(freq_buf), "Rx: %03ld.%05ld",
|
||||
state->channel.rx_frequency/1000000,
|
||||
state->channel.rx_frequency%1000000);
|
||||
|
||||
gfx_print(layout.line2_pos, freq_buf, layout.line1_font, TEXT_ALIGN_CENTER,
|
||||
color_white);
|
||||
snprintf(freq_buf, sizeof(freq_buf), "Tx: %03d.%05d",
|
||||
|
||||
snprintf(freq_buf, sizeof(freq_buf), "Tx: %03ld.%05ld",
|
||||
state->channel.tx_frequency/1000000,
|
||||
state->channel.tx_frequency%1000000);
|
||||
|
||||
gfx_print(layout.line3_pos, freq_buf, layout.line2_font, TEXT_ALIGN_CENTER,
|
||||
color_white);
|
||||
}
|
||||
|
||||
void _ui_drawBottomBar()
|
||||
{
|
||||
// Print OpenRTX on bottom bar
|
||||
char bottom_buf[8] = "OpenRTX";
|
||||
gfx_print(layout.bottom_pos, bottom_buf, layout.bottom_font,
|
||||
gfx_print(layout.bottom_pos, "OpenRTX", layout.bottom_font,
|
||||
TEXT_ALIGN_CENTER, color_white);
|
||||
}
|
||||
|
||||
|
@ -277,33 +278,33 @@ void ui_init()
|
|||
|
||||
void ui_drawSplashScreen()
|
||||
{
|
||||
point_t splash_origin = {0, SCREEN_HEIGHT / 2 + 6};
|
||||
gfx_clearScreen();
|
||||
|
||||
#ifdef OLD_SPLASH
|
||||
point_t splash_origin = {0, SCREEN_HEIGHT / 2 + 6};
|
||||
gfx_print(splash_origin, "OpenRTX", FONT_SIZE_12PT, TEXT_ALIGN_CENTER,
|
||||
yellow_fab413);
|
||||
}
|
||||
|
||||
void ui_drawSplashScreen2()
|
||||
{
|
||||
#else
|
||||
point_t splash_origin = {0, SCREEN_HEIGHT / 2 - 6};
|
||||
gfx_clearScreen();
|
||||
gfx_print(splash_origin, "O P N\nR T X", FONT_SIZE_12PT, TEXT_ALIGN_CENTER,
|
||||
yellow_fab413);
|
||||
#endif
|
||||
}
|
||||
|
||||
void ui_updateFSM(state_t last_state, uint32_t keys)
|
||||
{
|
||||
(void) last_state;
|
||||
|
||||
// Temporary VFO controls
|
||||
if(keys && KEY_UP)
|
||||
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)
|
||||
|
||||
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;
|
||||
|
|
Ładowanie…
Reference in New Issue