feat: Warn on shutdown if trainer is connected (#4212)

Co-authored-by: Peter Feerick <peter.feerick@gmail.com>
This commit is contained in:
3djc
2023-10-23 19:27:53 +10:00
committed by GitHub
co-authored by Peter Feerick
parent 1af8b78256
commit 16b9d72aba
19 changed files with 33 additions and 3 deletions
+15 -3
View File
@@ -1782,12 +1782,15 @@ uint32_t pwrCheck()
#if defined(COLORLCD)
bool usbConfirmed = !usbPlugged() || getSelectedUsbMode() == USB_UNSELECTED_MODE;
bool modelConnectedConfirmed = !TELEMETRY_STREAMING() || g_eeGeneral.disableRssiPoweroffAlarm;
bool trainerConfirmed = !isTrainerConnected();
#endif
#if defined(SHUTDOWN_CONFIRMATION)
while (1)
#else
while ((usbPlugged() && getSelectedUsbMode() != USB_UNSELECTED_MODE) ||
(TELEMETRY_STREAMING() && !g_eeGeneral.disableRssiPoweroffAlarm))
while (
(usbPlugged() && getSelectedUsbMode() != USB_UNSELECTED_MODE) ||
(TELEMETRY_STREAMING() && !g_eeGeneral.disableRssiPoweroffAlarm) ||
isTrainerConnected())
#endif
{
@@ -1804,7 +1807,10 @@ uint32_t pwrCheck()
msg = STR_USB_STILL_CONNECTED;
msg_len = sizeof(TR_USB_STILL_CONNECTED);
}
else if (isTrainerConnected()) {
msg = STR_TRAINER_STILL_CONNECTED;
msg_len = sizeof(TR_TRAINER_STILL_CONNECTED);
}
event_t evt = getEvent();
SET_WARNING_INFO(msg, msg_len, 0);
DISPLAY_WARNING(evt);
@@ -1843,6 +1849,12 @@ uint32_t pwrCheck()
return !TELEMETRY_STREAMING() || g_eeGeneral.disableRssiPoweroffAlarm;
};
}
else if (!trainerConfirmed) {
message = STR_TRAINER_STILL_CONNECTED;
closeCondition = [](){
return !isTrainerConnected();
};
}
// TODO: abort dialog condition (here, RSSI lost / USB connected)
if (confirmationDialog(STR_MODEL_SHUTDOWN, message, false, closeCondition)) {