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
|
||||
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;
|
||||
auto dialog = new FullScreenDialog(WARNING_TYPE_CONFIRM, title ? title : "",
|
||||
msg ? msg : "", "",
|
||||
[&confirmed]() { confirmed = true; });
|
||||
if(closeCondition)
|
||||
{
|
||||
dialog->setCloseCondition([&confirmed,&closeCondition]() {
|
||||
if(closeCondition())
|
||||
{
|
||||
confirmed=true;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}});
|
||||
}
|
||||
|
||||
if (checkPwr) {
|
||||
dialog->runForever();
|
||||
} else {
|
||||
|
||||
+22
-3
@@ -2044,6 +2044,10 @@ uint32_t pwrCheck()
|
||||
BACKLIGHT_ENABLE();
|
||||
}
|
||||
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)
|
||||
while (1)
|
||||
#else
|
||||
@@ -2087,15 +2091,30 @@ uint32_t pwrCheck()
|
||||
#else // COLORLCD
|
||||
|
||||
const char* message = nullptr;
|
||||
if (usbPlugged()) {
|
||||
std::function<bool(void)> closeCondition = nullptr;
|
||||
if (!usbConfirmed) {
|
||||
message = STR_USB_STILL_CONNECTED;
|
||||
closeCondition = [](){
|
||||
return !usbPlugged();
|
||||
};
|
||||
}
|
||||
else {
|
||||
else if (!modelConnectedConfirmed) {
|
||||
message = STR_MODEL_STILL_POWERED;
|
||||
closeCondition = [](){
|
||||
return !TELEMETRY_STREAMING() || g_eeGeneral.disableRssiPoweroffAlarm;
|
||||
};
|
||||
}
|
||||
|
||||
// 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;
|
||||
return e_power_off;
|
||||
} else {
|
||||
|
||||
+1
-1
@@ -471,7 +471,7 @@ void alert(const char * title, const char * msg, uint8_t sound);
|
||||
|
||||
#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,
|
||||
uint8_t sound);
|
||||
|
||||
Reference in New Issue
Block a user