Fix colorlcd auto power off on cleared shutdown warning trigger (#1164)
This commit is contained in:
@@ -201,12 +201,24 @@ void raiseAlert(const char * title, const char * msg, const char * action, uint8
|
|||||||
}
|
}
|
||||||
|
|
||||||
// POPUP_CONFIRMATION
|
// POPUP_CONFIRMATION
|
||||||
bool confirmationDialog(const char* title, const char* msg, bool checkPwr)
|
bool confirmationDialog(const char* title, const char* msg, bool checkPwr, const std::function<bool(void)>& closeCondition)
|
||||||
{
|
{
|
||||||
bool confirmed = false;
|
bool confirmed = false;
|
||||||
auto dialog = new FullScreenDialog(WARNING_TYPE_CONFIRM, title ? title : "",
|
auto dialog = new FullScreenDialog(WARNING_TYPE_CONFIRM, title ? title : "",
|
||||||
msg ? msg : "", "",
|
msg ? msg : "", "",
|
||||||
[&confirmed]() { confirmed = true; });
|
[&confirmed]() { confirmed = true; });
|
||||||
|
if(closeCondition)
|
||||||
|
{
|
||||||
|
dialog->setCloseCondition([&confirmed,&closeCondition]() {
|
||||||
|
if(closeCondition())
|
||||||
|
{
|
||||||
|
confirmed=true;
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}});
|
||||||
|
}
|
||||||
|
|
||||||
if (checkPwr) {
|
if (checkPwr) {
|
||||||
dialog->runForever();
|
dialog->runForever();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+22
-3
@@ -2044,6 +2044,10 @@ uint32_t pwrCheck()
|
|||||||
BACKLIGHT_ENABLE();
|
BACKLIGHT_ENABLE();
|
||||||
}
|
}
|
||||||
if (get_tmr10ms() - pwr_press_time > PWR_PRESS_SHUTDOWN_DELAY()) {
|
if (get_tmr10ms() - pwr_press_time > PWR_PRESS_SHUTDOWN_DELAY()) {
|
||||||
|
#if defined(COLORLCD)
|
||||||
|
bool usbConfirmed = !usbPlugged() || getSelectedUsbMode() == USB_UNSELECTED_MODE;
|
||||||
|
bool modelConnectedConfirmed = !TELEMETRY_STREAMING() || g_eeGeneral.disableRssiPoweroffAlarm;
|
||||||
|
#endif
|
||||||
#if defined(SHUTDOWN_CONFIRMATION)
|
#if defined(SHUTDOWN_CONFIRMATION)
|
||||||
while (1)
|
while (1)
|
||||||
#else
|
#else
|
||||||
@@ -2087,15 +2091,30 @@ uint32_t pwrCheck()
|
|||||||
#else // COLORLCD
|
#else // COLORLCD
|
||||||
|
|
||||||
const char* message = nullptr;
|
const char* message = nullptr;
|
||||||
if (usbPlugged()) {
|
std::function<bool(void)> closeCondition = nullptr;
|
||||||
|
if (!usbConfirmed) {
|
||||||
message = STR_USB_STILL_CONNECTED;
|
message = STR_USB_STILL_CONNECTED;
|
||||||
|
closeCondition = [](){
|
||||||
|
return !usbPlugged();
|
||||||
|
};
|
||||||
}
|
}
|
||||||
else {
|
else if (!modelConnectedConfirmed) {
|
||||||
message = STR_MODEL_STILL_POWERED;
|
message = STR_MODEL_STILL_POWERED;
|
||||||
|
closeCondition = [](){
|
||||||
|
return !TELEMETRY_STREAMING() || g_eeGeneral.disableRssiPoweroffAlarm;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: abort dialog condition (here, RSSI lost / USB connected)
|
// TODO: abort dialog condition (here, RSSI lost / USB connected)
|
||||||
if (confirmationDialog(STR_MODEL_SHUTDOWN, message, false)) {
|
if (confirmationDialog(STR_MODEL_SHUTDOWN, message, false, closeCondition)) {
|
||||||
|
if( message == STR_USB_STILL_CONNECTED)
|
||||||
|
usbConfirmed=true;
|
||||||
|
if( message == STR_MODEL_STILL_POWERED)
|
||||||
|
modelConnectedConfirmed = true;
|
||||||
|
|
||||||
|
if(!usbConfirmed || !modelConnectedConfirmed)
|
||||||
|
continue;
|
||||||
|
|
||||||
pwr_check_state = PWR_CHECK_OFF;
|
pwr_check_state = PWR_CHECK_OFF;
|
||||||
return e_power_off;
|
return e_power_off;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+1
-1
@@ -471,7 +471,7 @@ void alert(const char * title, const char * msg, uint8_t sound);
|
|||||||
|
|
||||||
#elif defined(COLORLCD)
|
#elif defined(COLORLCD)
|
||||||
|
|
||||||
bool confirmationDialog(const char *title, const char *msg, bool checkPwr = true);
|
bool confirmationDialog(const char *title, const char *msg, bool checkPwr = true, const std::function<bool(void)>& closeCondition = nullptr);
|
||||||
|
|
||||||
void raiseAlert(const char *title, const char *msg, const char *info,
|
void raiseAlert(const char *title, const char *msg, const char *info,
|
||||||
uint8_t sound);
|
uint8_t sound);
|
||||||
|
|||||||
Reference in New Issue
Block a user