fix(color): popup warning may block UI and key input (#6648)

This commit is contained in:
philmoz
2025-10-14 21:09:07 +10:00
committed by GitHub
parent dbffe1b193
commit d66cf1fc0d
6 changed files with 19 additions and 26 deletions
+4 -14
View File
@@ -88,27 +88,17 @@ void show_ui_popup()
}
}
void POPUP_WARNING_ON_UI_TASK(const char* message, const char* info,
bool waitForClose)
bool POPUP_WARNING_ON_UI_TASK(const char* message, const char* info)
{
// if already in a popup, and we don't want to wait, ignore call
if (!waitForClose && ui_popup_active) return;
// if already in a popup, ignore call
if (ui_popup_active) return false;
// Wait in case already in popup.
while (ui_popup_active) {
sleep_ms(20);
}
ui_popup_title = "Warning";
ui_popup_msg = message;
ui_popup_info = info;
ui_popup_active = true;
// Wait until closed
if (waitForClose) {
while (ui_popup_active) {
sleep_ms(20);
}
}
return true;
}
// Bubble popup style
+1 -2
View File
@@ -40,8 +40,7 @@ typedef std::function<void(const char *, const char *, int, int)>
void POPUP_INFORMATION(const char *message);
void POPUP_WARNING(const char *message, const char *info = nullptr);
void POPUP_WARNING_ON_UI_TASK(const char *message, const char *info = nullptr,
bool waitForClose = true);
bool POPUP_WARNING_ON_UI_TASK(const char *message, const char *info = nullptr);
void POPUP_BUBBLE(const char *message, uint32_t timeout, coord_t width = LCD_W - 100);
void show_ui_popup();
+7 -3
View File
@@ -267,10 +267,8 @@ void POPUP_INFORMATION(const char * s)
popupFunc = runPopupWarning;
}
void POPUP_WARNING(const char * message, const char * info, bool waitForClose)
void POPUP_WARNING(const char * message, const char * info)
{
(void)waitForClose;
warningText = message;
warningInfoText = info;
warningInfoLength = info ? strlen(info) : 0;
@@ -279,6 +277,12 @@ void POPUP_WARNING(const char * message, const char * info, bool waitForClose)
popupFunc = runPopupWarning;
}
bool POPUP_WARNING_ON_UI_TASK(const char * message, const char * info)
{
POPUP_WARNING(message, info);
return true;
}
void SET_WARNING_INFO(const char * info, uint8_t length, uint8_t flags)
{
warningInfoText = info;
+3 -3
View File
@@ -74,7 +74,7 @@ enum WarningType
#if !defined(GUI)
#define DISPLAY_WARNING(...)
inline void POPUP_WAIT(const char * s) { }
inline void POPUP_WARNING(const char *, const char * = nullptr, bool waitForClose) { }
inline void POPUP_WARNING(const char *, const char * = nullptr) { }
inline void POPUP_CONFIRMATION(const char * s, PopupMenuHandler handler) { }
inline void POPUP_INPUT(const char * s, PopupFunc func) { }
inline void SET_WARNING_INFO(const char * info, uint8_t length, uint8_t flags) { }
@@ -83,7 +83,7 @@ enum WarningType
extern void CLEAR_POPUP();
extern void POPUP_WAIT(const char * s);
extern void POPUP_INFORMATION(const char * s);
extern void POPUP_WARNING(const char * message, const char * info = nullptr, bool waitForClose = true);
extern void POPUP_WARNING(const char * message, const char * info = nullptr);
extern void SET_WARNING_INFO(const char * info, uint8_t length, uint8_t flags);
extern void POPUP_CONFIRMATION(const char * s, PopupMenuHandler handler);
extern void POPUP_INPUT(const char * s, PopupFunc func);
@@ -100,4 +100,4 @@ extern void POPUP_MENU_START(PopupMenuHandler handler);
extern void POPUP_MENU_START(PopupMenuHandler handler, int count, ...);
// For compatability with color LCD code base, not (currently) required for B&W
#define POPUP_WARNING_ON_UI_TASK POPUP_WARNING
bool POPUP_WARNING_ON_UI_TASK(const char *, const char * = nullptr);
+2 -2
View File
@@ -249,7 +249,7 @@ void logsWrite()
if (result) {
if (result != error_displayed) {
error_displayed = result;
POPUP_WARNING_ON_UI_TASK(result, nullptr, false);
POPUP_WARNING_ON_UI_TASK(result, nullptr);
}
return;
}
@@ -354,7 +354,7 @@ void logsWrite()
if (result<0 && !error_displayed) {
error_displayed = STR_SDCARD_ERROR;
POPUP_WARNING_ON_UI_TASK(STR_SDCARD_ERROR, nullptr, false);
POPUP_WARNING_ON_UI_TASK(STR_SDCARD_ERROR, nullptr);
logsClose();
}
}
+2 -2
View File
@@ -335,8 +335,8 @@ void telemetryWakeup()
#if defined(PXX1) || defined(PXX2)
if (isBadAntennaDetected()) {
AUDIO_RAS_RED();
POPUP_WARNING_ON_UI_TASK(STR_WARNING, STR_ANTENNAPROBLEM);
SCHEDULE_NEXT_ALARMS_CHECK(10 /*seconds*/);
if (POPUP_WARNING_ON_UI_TASK(STR_WARNING, STR_ANTENNAPROBLEM))
SCHEDULE_NEXT_ALARMS_CHECK(10 /*seconds*/);
}
#endif