feat(radio): OS compatibility layer (#5840)
This commit is contained in:
@@ -21,7 +21,9 @@
|
||||
|
||||
#include "edgetx.h"
|
||||
#include "tasks.h"
|
||||
|
||||
#include "mixer_scheduler.h"
|
||||
#include "tasks/mixer_task.h"
|
||||
|
||||
#include "hal/adc_driver.h"
|
||||
|
||||
@@ -169,12 +171,12 @@ void menuStatisticsDebug(event_t event)
|
||||
y += FH;
|
||||
|
||||
lcdDrawTextAlignedLeft(y, STR_FREE_STACK);
|
||||
lcdDrawNumber(MENU_DEBUG_COL1_OFS, y, menusStack.available(), LEFT);
|
||||
lcdDrawNumber(MENU_DEBUG_COL1_OFS, y, task_get_stack_usage(&menusTaskId), LEFT);
|
||||
lcdDrawText(lcdLastRightPos, y, "/");
|
||||
lcdDrawNumber(lcdLastRightPos, y, mixerStack.available(), LEFT);
|
||||
lcdDrawNumber(lcdLastRightPos, y, task_get_stack_usage(&mixerTaskId), LEFT);
|
||||
#if defined(AUDIO)
|
||||
lcdDrawText(lcdLastRightPos, y, "/");
|
||||
lcdDrawNumber(lcdLastRightPos, y, audioStack.available(), LEFT);
|
||||
lcdDrawNumber(lcdLastRightPos, y, task_get_stack_usage(&audioTaskId), LEFT);
|
||||
#endif
|
||||
y += FH;
|
||||
|
||||
|
||||
@@ -21,7 +21,9 @@
|
||||
|
||||
#include "hal/adc_driver.h"
|
||||
#include "edgetx.h"
|
||||
|
||||
#include "tasks.h"
|
||||
#include "tasks/mixer_task.h"
|
||||
|
||||
#define STATS_1ST_COLUMN FW/2
|
||||
#define STATS_2ND_COLUMN 12*FW+FW/2
|
||||
@@ -188,12 +190,12 @@ void menuStatisticsDebug(event_t event)
|
||||
|
||||
lcdDrawTextAlignedLeft(y, STR_FREE_STACK);
|
||||
lcdDrawText(MENU_DEBUG_COL1_OFS, y+1, "[M]", SMLSIZE);
|
||||
lcdDrawNumber(lcdLastRightPos, y, menusStack.available(), LEFT);
|
||||
lcdDrawNumber(lcdLastRightPos, y, task_get_stack_usage(&menusTaskId), LEFT);
|
||||
lcdDrawText(lcdLastRightPos+2, y+1, "[X]", SMLSIZE);
|
||||
lcdDrawNumber(lcdLastRightPos, y, mixerStack.available(), LEFT);
|
||||
lcdDrawNumber(lcdLastRightPos, y, task_get_stack_usage(&mixerTaskId), LEFT);
|
||||
#if defined(AUDIO)
|
||||
lcdDrawText(lcdLastRightPos+2, y+1, "[A]", SMLSIZE);
|
||||
lcdDrawNumber(lcdLastRightPos, y, audioStack.available(), LEFT);
|
||||
lcdDrawNumber(lcdLastRightPos, y, task_get_stack_usage(&audioTaskId), LEFT);
|
||||
#endif
|
||||
lcdDrawText(lcdLastRightPos+2, y+1, "[I]", SMLSIZE);
|
||||
lcdDrawNumber(lcdLastRightPos, y, mainStackAvailable(), LEFT);
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
#include "edgetx.h"
|
||||
#include "hal/rotary_encoder.h"
|
||||
#include "os/time.h"
|
||||
|
||||
#include "LvglWrapper.h"
|
||||
#include "etx_lv_theme.h"
|
||||
@@ -359,9 +360,10 @@ LvglWrapper* LvglWrapper::instance()
|
||||
void LvglWrapper::run()
|
||||
{
|
||||
#if defined(SIMU)
|
||||
tmr10ms_t tick = get_tmr10ms();
|
||||
lv_tick_inc((tick - lastTick) * 10);
|
||||
lastTick = tick;
|
||||
static uint32_t last_tick = 0;
|
||||
uint32_t tick = time_get_ms();
|
||||
lv_tick_inc(tick - last_tick);
|
||||
last_tick = tick;
|
||||
#endif
|
||||
lv_timer_handler();
|
||||
}
|
||||
|
||||
@@ -33,9 +33,6 @@ class LvglWrapper
|
||||
static LvglWrapper *_instance;
|
||||
static void pollInputs();
|
||||
|
||||
tmr10ms_t lastTick = 0;
|
||||
// TODO: add driver instances here
|
||||
|
||||
LvglWrapper();
|
||||
~LvglWrapper() {}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "mainwindow.h"
|
||||
#include "edgetx.h"
|
||||
#include "etx_lv_theme.h"
|
||||
#include "os/sleep.h"
|
||||
#include "view_main.h"
|
||||
#include "hal/watchdog_driver.h"
|
||||
|
||||
@@ -186,7 +187,7 @@ static void run_ui_manually()
|
||||
checkBacklight();
|
||||
WDG_RESET();
|
||||
|
||||
RTOS_WAIT_MS(10);
|
||||
sleep_ms(10);
|
||||
LvglWrapper::runNested();
|
||||
MainWindow::instance()->run(false);
|
||||
}
|
||||
@@ -211,7 +212,7 @@ void FullScreenDialog::runForever(bool checkPwr)
|
||||
#endif
|
||||
} else if (check == e_power_press) {
|
||||
WDG_RESET();
|
||||
RTOS_WAIT_MS(1);
|
||||
sleep_ms(1);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
|
||||
#include "libopenui.h"
|
||||
#include "edgetx.h"
|
||||
#include "lvgl/src/hal/lv_hal_tick.h"
|
||||
#include "os/sleep.h"
|
||||
#include "pwr.h"
|
||||
#include "hal/watchdog_driver.h"
|
||||
#include "etx_lv_theme.h"
|
||||
@@ -51,7 +53,7 @@ static void _run_popup_dialog(const char* title, const char* msg,
|
||||
#endif
|
||||
} else if (check == e_power_press) {
|
||||
WDG_RESET();
|
||||
RTOS_WAIT_MS(1);
|
||||
sleep_ms(1);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -59,7 +61,7 @@ static void _run_popup_dialog(const char* title, const char* msg,
|
||||
WDG_RESET();
|
||||
MainWindow::instance()->run();
|
||||
LvglWrapper::runNested();
|
||||
RTOS_WAIT_MS(20);
|
||||
sleep_ms(20);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +97,7 @@ void POPUP_WARNING_ON_UI_TASK(const char* message, const char* info,
|
||||
|
||||
// Wait in case already in popup.
|
||||
while (ui_popup_active) {
|
||||
RTOS_WAIT_MS(20);
|
||||
sleep_ms(20);
|
||||
}
|
||||
ui_popup_title = "Warning";
|
||||
ui_popup_msg = message;
|
||||
@@ -105,7 +107,7 @@ void POPUP_WARNING_ON_UI_TASK(const char* message, const char* info,
|
||||
// Wait until closed
|
||||
if (waitForClose) {
|
||||
while (ui_popup_active) {
|
||||
RTOS_WAIT_MS(20);
|
||||
sleep_ms(20);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -151,7 +153,8 @@ class BubbleDialog : public Window
|
||||
public:
|
||||
BubbleDialog(const char* message, int timeout, coord_t width) :
|
||||
Window(MainWindow::instance(), rect_t{(LCD_W - width) / 2, LCD_H - 100, width, 50},
|
||||
bubble_popup_create)
|
||||
bubble_popup_create),
|
||||
startTime(lv_tick_get()), timeout(timeout)
|
||||
{
|
||||
setWindowFlag(OPAQUE);
|
||||
|
||||
@@ -163,21 +166,20 @@ class BubbleDialog : public Window
|
||||
lv_obj_set_width(label, lv_pct(100));
|
||||
etx_obj_add_style(label, styles->text_align_center, LV_PART_MAIN);
|
||||
lv_label_set_long_mode(label, LV_LABEL_LONG_WRAP);
|
||||
|
||||
endTime = RTOS_GET_MS() + timeout;
|
||||
}
|
||||
|
||||
bool isBubblePopup() override { return true; }
|
||||
|
||||
void checkEvents() override
|
||||
{
|
||||
if (RTOS_GET_MS() >= endTime) {
|
||||
if (lv_tick_elaps(startTime) >= timeout) {
|
||||
deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
uint32_t endTime;
|
||||
uint32_t startTime;
|
||||
uint32_t timeout;
|
||||
};
|
||||
|
||||
void POPUP_BUBBLE(const char* message, uint32_t timeout, coord_t width)
|
||||
|
||||
@@ -37,13 +37,13 @@ static bool timepg = false;
|
||||
static void on_draw_begin(lv_event_t* e)
|
||||
{
|
||||
if (timepg) {
|
||||
dsms = RTOS_GET_MS();
|
||||
dsms = lv_tick_get();
|
||||
}
|
||||
}
|
||||
static void on_draw_end(lv_event_t* e)
|
||||
{
|
||||
timepg = false;
|
||||
dems = RTOS_GET_MS();
|
||||
dems = lv_tick_get();
|
||||
TRACE("tab time: build %ld layout %ld draw %ld total %ld",
|
||||
end_ms - start_ms, dsms - end_ms, dems - dsms, dems - start_ms);
|
||||
}
|
||||
@@ -301,7 +301,7 @@ void TabsGroup::setCurrentTab(unsigned index)
|
||||
currentTab = tab;
|
||||
|
||||
#if defined(DEBUG)
|
||||
start_ms = RTOS_GET_MS();
|
||||
start_ms = lv_tick_get();
|
||||
timepg = true;
|
||||
#endif
|
||||
|
||||
@@ -321,7 +321,7 @@ void TabsGroup::setCurrentTab(unsigned index)
|
||||
lv_obj_refresh_style(body->getLvObj(), LV_PART_ANY, LV_STYLE_PROP_ANY);
|
||||
|
||||
#if defined(DEBUG)
|
||||
end_ms = RTOS_GET_MS();
|
||||
end_ms = lv_tick_get();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ coord_t TopBar::getVisibleHeight(float visible) const // 0.0 -> 1.0
|
||||
|
||||
void TopBar::checkEvents()
|
||||
{
|
||||
uint32_t now = RTOS_GET_MS();
|
||||
uint32_t now = lv_tick_get();
|
||||
if (now - lastRefresh >= TOPBAR_REFRESH) {
|
||||
lastRefresh = now;
|
||||
TopBarBase::checkEvents();
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
*/
|
||||
|
||||
#include "view_statistics.h"
|
||||
#include "os/task.h"
|
||||
|
||||
#include "edgetx.h"
|
||||
#include "tasks.h"
|
||||
@@ -333,14 +334,14 @@ void DebugViewPage::build(Window* window)
|
||||
#endif
|
||||
new DebugInfoNumber<uint32_t>(
|
||||
line, rect_t{0, 0, DBG_B_WIDTH, DBG_B_HEIGHT},
|
||||
[] { return menusStack.available(); }, STR_STACK_MENU);
|
||||
[] { return task_get_stack_usage(&menusTaskId); }, STR_STACK_MENU);
|
||||
new DebugInfoNumber<uint32_t>(
|
||||
line, rect_t{0, 0, DBG_B_WIDTH, DBG_B_HEIGHT},
|
||||
[] { return mixerStack.available(); }, STR_STACK_MIX);
|
||||
[] { return task_get_stack_usage(&mixerTaskId); }, STR_STACK_MIX);
|
||||
#if defined(AUDIO)
|
||||
new DebugInfoNumber<uint32_t>(
|
||||
line, rect_t{0, 0, DBG_B_WIDTH, DBG_B_HEIGHT},
|
||||
[] { return audioStack.available(); }, STR_STACK_AUDIO);
|
||||
[] { return task_get_stack_usage(&audioTaskId); }, STR_STACK_AUDIO);
|
||||
#endif
|
||||
|
||||
#if defined(DEBUG_LATENCY)
|
||||
|
||||
@@ -367,7 +367,7 @@ class SensorButton : public ListLineButton
|
||||
else
|
||||
lv_obj_add_flag(fresh, LV_OBJ_FLAG_HIDDEN);
|
||||
|
||||
uint32_t now = RTOS_GET_MS();
|
||||
uint32_t now = lv_tick_get();
|
||||
TelemetryItem& telemetryItem = telemetryItems[index];
|
||||
|
||||
// Update value
|
||||
@@ -479,7 +479,7 @@ class SensorEditWindow : public SubPage
|
||||
|
||||
void checkEvents() override
|
||||
{
|
||||
uint32_t now = RTOS_GET_MS();
|
||||
uint32_t now = lv_tick_get();
|
||||
TelemetryItem& telemetryItem = telemetryItems[index];
|
||||
|
||||
if ((now - lastRefresh >= 200) || telemetryItem.isFresh()) {
|
||||
|
||||
@@ -609,8 +609,8 @@ class ModuleSubTypeChoice : public Choice
|
||||
MultiModuleStatus& status = getMultiModuleStatus(moduleIdx);
|
||||
status.invalidate();
|
||||
|
||||
uint32_t startUpdate = RTOS_GET_MS();
|
||||
while (!status.isValid() && (RTOS_GET_MS() - startUpdate < 250))
|
||||
uint32_t startUpdate = lv_tick_get();
|
||||
while (!status.isValid() && (lv_tick_elaps(startUpdate) < 250))
|
||||
;
|
||||
SET_DIRTY();
|
||||
#endif
|
||||
|
||||
@@ -44,9 +44,9 @@ void RfScanDialog::checkEvents()
|
||||
{
|
||||
if (!protos->isScanning()) {
|
||||
closeDialog();
|
||||
} else if (RTOS_GET_MS() - lastUpdate >= 200) {
|
||||
} else if (lv_tick_elaps(lastUpdate) >= 200) {
|
||||
showProgress();
|
||||
lastUpdate = RTOS_GET_MS();
|
||||
lastUpdate = lv_tick_get();
|
||||
}
|
||||
|
||||
ProgressDialog::checkEvents();
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "edgetx.h"
|
||||
#include "telemetry/ghost.h"
|
||||
#include "telemetry/ghost_menu.h"
|
||||
#include "os/sleep.h"
|
||||
|
||||
class GhostModuleConfigWindow : public Window
|
||||
{
|
||||
@@ -166,7 +167,7 @@ void RadioGhostModuleConfig::onLongPressRTN()
|
||||
reusableBuffer.ghostMenu.buttonAction = GHST_BTN_NONE;
|
||||
reusableBuffer.ghostMenu.menuAction = GHST_MENU_CTRL_CLOSE;
|
||||
moduleState[EXTERNAL_MODULE].counter = GHST_MENU_CONTROL;
|
||||
RTOS_WAIT_MS(10);
|
||||
sleep_ms(10);
|
||||
#if defined(TRIMS_EMULATE_BUTTONS)
|
||||
setHatsAsKeys(false); // switch trims back to normal
|
||||
#endif
|
||||
@@ -183,7 +184,7 @@ void RadioGhostModuleConfig::checkEvents()
|
||||
reusableBuffer.ghostMenu.menuAction = GHST_MENU_CTRL_OPEN;
|
||||
moduleState[EXTERNAL_MODULE].counter = GHST_MENU_CONTROL;
|
||||
} else if (reusableBuffer.ghostMenu.menuStatus == GHST_MENU_STATUS_CLOSING) {
|
||||
RTOS_WAIT_MS(10);
|
||||
sleep_ms(10);
|
||||
deleteLater();
|
||||
#if defined(TRIMS_EMULATE_BUTTONS)
|
||||
setHatsAsKeys(false); // switch trims back to normal
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "hal/abnormal_reboot.h"
|
||||
#include "inactivity_timer.h"
|
||||
#include "edgetx.h"
|
||||
#include "os/sleep.h"
|
||||
#include "stamp.h"
|
||||
#include "theme_manager.h"
|
||||
|
||||
@@ -123,7 +124,7 @@ void waitSplash()
|
||||
if (splashStartTime) {
|
||||
#if defined(SIMU)
|
||||
// Simulator - inputsMoved() returns true immediately without this!
|
||||
RTOS_WAIT_TICKS(30);
|
||||
sleep_ms(30);
|
||||
#endif // defined(SIMU)
|
||||
|
||||
splashStartTime += SPLASH_TIMEOUT;
|
||||
@@ -133,7 +134,7 @@ void waitSplash()
|
||||
WDG_RESET();
|
||||
checkSpeakerVolume();
|
||||
checkBacklight();
|
||||
RTOS_WAIT_TICKS(10);
|
||||
sleep_ms(10);
|
||||
auto evt = getEvent();
|
||||
if (evt || inactivityCheckInputs()) {
|
||||
if (evt) killEvents(evt);
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
*/
|
||||
|
||||
#include "edgetx.h"
|
||||
#include "os/sleep.h"
|
||||
|
||||
#if defined(GHOST) && defined(HARDWARE_EXTERNAL_MODULE)
|
||||
|
||||
@@ -84,7 +85,7 @@ void menuGhostModuleConfig(event_t event)
|
||||
reusableBuffer.ghostMenu.buttonAction = GHST_BTN_NONE;
|
||||
reusableBuffer.ghostMenu.menuAction = GHST_MENU_CTRL_CLOSE;
|
||||
moduleState[EXTERNAL_MODULE].counter = GHST_MENU_CONTROL;
|
||||
RTOS_WAIT_MS(10);
|
||||
sleep_ms(10);
|
||||
popMenu();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
*/
|
||||
|
||||
#include "edgetx.h"
|
||||
#include "os/sleep.h"
|
||||
#include "timers_driver.h"
|
||||
|
||||
extern uint8_t g_moduleIdx;
|
||||
@@ -52,7 +53,7 @@ void menuRadioPowerMeter(event_t event)
|
||||
moduleState[g_moduleIdx].readModuleInformation(&reusableBuffer.moduleSetup.pxx2.moduleInformation, PXX2_HW_INFO_TX_ID, PXX2_HW_INFO_TX_ID);
|
||||
/* wait 1s to resume normal operation before leaving */
|
||||
watchdogSuspend(500 /*5s*/);
|
||||
RTOS_WAIT_MS(1000);
|
||||
sleep_ms(1000);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
*/
|
||||
|
||||
#include "edgetx.h"
|
||||
#include "os/sleep.h"
|
||||
#include "timers_driver.h"
|
||||
|
||||
extern uint8_t g_moduleIdx;
|
||||
@@ -49,7 +50,7 @@ void menuRadioSpectrumAnalyser(event_t event)
|
||||
#endif
|
||||
/* wait 1s to resume normal operation before leaving */
|
||||
watchdogSuspend(500 /*5s*/);
|
||||
RTOS_WAIT_MS(1000);
|
||||
sleep_ms(1000);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
#include "edgetx.h"
|
||||
#include "inactivity_timer.h"
|
||||
#include "os/sleep.h"
|
||||
|
||||
static bool splashStarted = false;
|
||||
|
||||
@@ -53,7 +54,7 @@ void waitSplash()
|
||||
tmr10ms_t tgtime = get_tmr10ms() + SPLASH_TIMEOUT;
|
||||
|
||||
while (tgtime > get_tmr10ms()) {
|
||||
RTOS_WAIT_TICKS(1);
|
||||
sleep_ms(1);
|
||||
|
||||
getADC();
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "edgetx.h"
|
||||
#include "switches.h"
|
||||
#include "mixes.h"
|
||||
#include "os/sleep.h"
|
||||
|
||||
#undef CPN
|
||||
#include "MultiSubtypeDefs.h"
|
||||
@@ -756,7 +757,7 @@ static void runAntennaSelectionMenu()
|
||||
WDG_RESET();
|
||||
MainWindow::instance()->run();
|
||||
LvglWrapper::runNested();
|
||||
RTOS_WAIT_MS(20);
|
||||
sleep_ms(20);
|
||||
}
|
||||
}
|
||||
#else
|
||||
@@ -1229,7 +1230,7 @@ bool confirmModelChange()
|
||||
if (TELEMETRY_STREAMING()) {
|
||||
RAISE_ALERT(STR_MODEL, STR_MODEL_STILL_POWERED, STR_PRESS_ENTER_TO_CONFIRM, AU_MODEL_STILL_POWERED);
|
||||
while (TELEMETRY_STREAMING()) {
|
||||
RTOS_WAIT_MS(20);
|
||||
sleep_ms(20);
|
||||
if (readKeys() == (1 << KEY_ENTER)) {
|
||||
killEvents(KEY_ENTER);
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user