fix(color): popup warning may block UI and key input (#6648)
This commit is contained in:
@@ -88,27 +88,17 @@ void show_ui_popup()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void POPUP_WARNING_ON_UI_TASK(const char* message, const char* info,
|
bool POPUP_WARNING_ON_UI_TASK(const char* message, const char* info)
|
||||||
bool waitForClose)
|
|
||||||
{
|
{
|
||||||
// if already in a popup, and we don't want to wait, ignore call
|
// if already in a popup, ignore call
|
||||||
if (!waitForClose && ui_popup_active) return;
|
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_title = "Warning";
|
||||||
ui_popup_msg = message;
|
ui_popup_msg = message;
|
||||||
ui_popup_info = info;
|
ui_popup_info = info;
|
||||||
ui_popup_active = true;
|
ui_popup_active = true;
|
||||||
|
|
||||||
// Wait until closed
|
return true;
|
||||||
if (waitForClose) {
|
|
||||||
while (ui_popup_active) {
|
|
||||||
sleep_ms(20);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bubble popup style
|
// Bubble popup style
|
||||||
|
|||||||
@@ -40,8 +40,7 @@ typedef std::function<void(const char *, const char *, int, int)>
|
|||||||
|
|
||||||
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,
|
bool POPUP_WARNING_ON_UI_TASK(const char *message, const char *info = nullptr);
|
||||||
bool waitForClose = true);
|
|
||||||
void POPUP_BUBBLE(const char *message, uint32_t timeout, coord_t width = LCD_W - 100);
|
void POPUP_BUBBLE(const char *message, uint32_t timeout, coord_t width = LCD_W - 100);
|
||||||
|
|
||||||
void show_ui_popup();
|
void show_ui_popup();
|
||||||
|
|||||||
@@ -267,10 +267,8 @@ void POPUP_INFORMATION(const char * s)
|
|||||||
popupFunc = runPopupWarning;
|
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;
|
warningText = message;
|
||||||
warningInfoText = info;
|
warningInfoText = info;
|
||||||
warningInfoLength = info ? strlen(info) : 0;
|
warningInfoLength = info ? strlen(info) : 0;
|
||||||
@@ -279,6 +277,12 @@ void POPUP_WARNING(const char * message, const char * info, bool waitForClose)
|
|||||||
popupFunc = runPopupWarning;
|
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)
|
void SET_WARNING_INFO(const char * info, uint8_t length, uint8_t flags)
|
||||||
{
|
{
|
||||||
warningInfoText = info;
|
warningInfoText = info;
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ enum WarningType
|
|||||||
#if !defined(GUI)
|
#if !defined(GUI)
|
||||||
#define DISPLAY_WARNING(...)
|
#define DISPLAY_WARNING(...)
|
||||||
inline void POPUP_WAIT(const char * s) { }
|
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_CONFIRMATION(const char * s, PopupMenuHandler handler) { }
|
||||||
inline void POPUP_INPUT(const char * s, PopupFunc func) { }
|
inline void POPUP_INPUT(const char * s, PopupFunc func) { }
|
||||||
inline void SET_WARNING_INFO(const char * info, uint8_t length, uint8_t flags) { }
|
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 CLEAR_POPUP();
|
||||||
extern void POPUP_WAIT(const char * s);
|
extern void POPUP_WAIT(const char * s);
|
||||||
extern void POPUP_INFORMATION(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 SET_WARNING_INFO(const char * info, uint8_t length, uint8_t flags);
|
||||||
extern void POPUP_CONFIRMATION(const char * s, PopupMenuHandler handler);
|
extern void POPUP_CONFIRMATION(const char * s, PopupMenuHandler handler);
|
||||||
extern void POPUP_INPUT(const char * s, PopupFunc func);
|
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, ...);
|
extern void POPUP_MENU_START(PopupMenuHandler handler, int count, ...);
|
||||||
|
|
||||||
// For compatability with color LCD code base, not (currently) required for B&W
|
// 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
@@ -249,7 +249,7 @@ void logsWrite()
|
|||||||
if (result) {
|
if (result) {
|
||||||
if (result != error_displayed) {
|
if (result != error_displayed) {
|
||||||
error_displayed = result;
|
error_displayed = result;
|
||||||
POPUP_WARNING_ON_UI_TASK(result, nullptr, false);
|
POPUP_WARNING_ON_UI_TASK(result, nullptr);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -354,7 +354,7 @@ void logsWrite()
|
|||||||
|
|
||||||
if (result<0 && !error_displayed) {
|
if (result<0 && !error_displayed) {
|
||||||
error_displayed = STR_SDCARD_ERROR;
|
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();
|
logsClose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -335,8 +335,8 @@ void telemetryWakeup()
|
|||||||
#if defined(PXX1) || defined(PXX2)
|
#if defined(PXX1) || defined(PXX2)
|
||||||
if (isBadAntennaDetected()) {
|
if (isBadAntennaDetected()) {
|
||||||
AUDIO_RAS_RED();
|
AUDIO_RAS_RED();
|
||||||
POPUP_WARNING_ON_UI_TASK(STR_WARNING, STR_ANTENNAPROBLEM);
|
if (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