fix(color): Popup telemetry warning can crash radio (#3439)
Also fixes issue where simulator does not close cleanly if popup showing.
This commit is contained in:
@@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include "popups.h"
|
#include "popups.h"
|
||||||
#include "libopenui.h"
|
#include "libopenui.h"
|
||||||
|
#include "pwr.h"
|
||||||
|
|
||||||
static void _run_popup_dialog(const char* title, const char* msg,
|
static void _run_popup_dialog(const char* title, const char* msg,
|
||||||
const char* info = nullptr)
|
const char* info = nullptr)
|
||||||
@@ -37,6 +38,19 @@ static void _run_popup_dialog(const char* title, const char* msg,
|
|||||||
md->setInfoText(std::string(info));
|
md->setInfoText(std::string(info));
|
||||||
}
|
}
|
||||||
while (running) {
|
while (running) {
|
||||||
|
// Allow power off while showing popup
|
||||||
|
auto check = pwrCheck();
|
||||||
|
if (check == e_power_off) {
|
||||||
|
boardOff();
|
||||||
|
#if defined(SIMU)
|
||||||
|
// Required so simulator exits cleanly when window closed
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
|
} else if (check == e_power_press) {
|
||||||
|
WDG_RESET();
|
||||||
|
RTOS_WAIT_MS(1);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
WDG_RESET();
|
WDG_RESET();
|
||||||
MainWindow::instance()->run();
|
MainWindow::instance()->run();
|
||||||
LvglWrapper::runNested();
|
LvglWrapper::runNested();
|
||||||
@@ -53,3 +67,33 @@ void POPUP_WARNING(const char * message, const char * info)
|
|||||||
{
|
{
|
||||||
_run_popup_dialog("Warning", message, info);
|
_run_popup_dialog("Warning", message, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char* ui_popup_title = nullptr;
|
||||||
|
static const char* ui_popup_msg = nullptr;
|
||||||
|
static const char* ui_popup_info = nullptr;
|
||||||
|
static bool ui_popup_active = false;
|
||||||
|
|
||||||
|
// Allow UI task to show a popup deferred from another task.
|
||||||
|
void show_ui_popup()
|
||||||
|
{
|
||||||
|
if (ui_popup_active) {
|
||||||
|
_run_popup_dialog(ui_popup_title, ui_popup_msg, ui_popup_info);
|
||||||
|
ui_popup_active = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
ui_popup_title = "Warning";
|
||||||
|
ui_popup_msg = message;
|
||||||
|
ui_popup_info = info;
|
||||||
|
ui_popup_active = true;
|
||||||
|
// Wait until closed
|
||||||
|
while (ui_popup_active) {
|
||||||
|
RTOS_WAIT_MS(20);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -27,3 +27,6 @@ typedef std::function<void(const char *, const char *, int, int)> ProgressHandle
|
|||||||
|
|
||||||
void POPUP_INFORMATION(const char * message);
|
void POPUP_INFORMATION(const char * message);
|
||||||
void POPUP_WARNING(const char * message, const char * info = nullptr);
|
void POPUP_WARNING(const char * message, const char * info = nullptr);
|
||||||
|
void POPUP_WARNING_ON_UI_TASK(const char * message, const char * info = nullptr);
|
||||||
|
|
||||||
|
void show_ui_popup();
|
||||||
|
|||||||
@@ -187,4 +187,7 @@ inline void POPUP_MENU_START(PopupMenuHandler handler)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For compatability with color LCD code base, not (currently) required for B&W
|
||||||
|
#define POPUP_WARNING_ON_UI_TASK POPUP_WARNING
|
||||||
|
|
||||||
#endif // _STDLCD_POPUPS_H_
|
#endif // _STDLCD_POPUPS_H_
|
||||||
|
|||||||
@@ -580,6 +580,8 @@ void perMain()
|
|||||||
DEBUG_TIMER_START(debugTimerGuiMain);
|
DEBUG_TIMER_START(debugTimerGuiMain);
|
||||||
#if defined(LIBOPENUI)
|
#if defined(LIBOPENUI)
|
||||||
guiMain(0);
|
guiMain(0);
|
||||||
|
// For color screens show a popup deferred from another task
|
||||||
|
show_ui_popup();
|
||||||
#else
|
#else
|
||||||
guiMain(evt);
|
guiMain(evt);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -269,7 +269,7 @@ void telemetryWakeup()
|
|||||||
#if defined(PCBFRSKY)
|
#if defined(PCBFRSKY)
|
||||||
if (isBadAntennaDetected()) {
|
if (isBadAntennaDetected()) {
|
||||||
AUDIO_RAS_RED();
|
AUDIO_RAS_RED();
|
||||||
POPUP_WARNING(STR_WARNING, STR_ANTENNAPROBLEM);
|
POPUP_WARNING_ON_UI_TASK(STR_WARNING, STR_ANTENNAPROBLEM);
|
||||||
SCHEDULE_NEXT_ALARMS_CHECK(10/*seconds*/);
|
SCHEDULE_NEXT_ALARMS_CHECK(10/*seconds*/);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user