Check model is off before changing model - Fixes #7715 (#7719)

Check model is off before changing model
This commit is contained in:
DanielGeA
2020-07-31 16:27:31 +02:00
committed by GitHub
parent 06d3110d7c
commit ac9f510005
5 changed files with 37 additions and 0 deletions
+4
View File
@@ -36,6 +36,10 @@ void onModelSelectMenu(const char * result)
int8_t sub = menuVerticalPosition;
if (result == STR_SELECT_MODEL || result == STR_CREATE_MODEL) {
if (!g_eeGeneral.disableRssiPoweroffAlarm) {
if (!confirmModelChange())
return;
}
selectModel(sub);
}
else if (result == STR_COPY_MODEL) {
+4
View File
@@ -28,6 +28,10 @@ void onModelSelectMenu(const char * result)
int8_t sub = menuVerticalPosition;
if (result == STR_SELECT_MODEL || result == STR_CREATE_MODEL) {
if (!g_eeGeneral.disableRssiPoweroffAlarm) {
if (!confirmModelChange())
return;
}
selectModel(sub);
}
else if (result == STR_COPY_MODEL) {
+8
View File
@@ -242,6 +242,10 @@ void onDeleteModelConfirm(const char * result)
void onModelSelectMenu(const char * result)
{
if (result == STR_SELECT_MODEL) {
if (!g_eeGeneral.disableRssiPoweroffAlarm) {
if (!confirmModelChange())
return;
}
// we store the latest changes if any
storageFlushCurrentModel();
storageCheck(true);
@@ -259,6 +263,10 @@ void onModelSelectMenu(const char * result)
deleteMode = MODE_DELETE_MODEL;
}
else if (result == STR_CREATE_MODEL) {
if (!g_eeGeneral.disableRssiPoweroffAlarm) {
if (!confirmModelChange())
return;
}
storageCheck(true);
modelslist.addModel(currentCategory, createModel());
selectMode = MODE_SELECT_MODEL;
+19
View File
@@ -805,6 +805,25 @@ bool modelHasNotes()
return false;
}
bool confirmModelChange()
{
if (TELEMETRY_STREAMING()) {
RAISE_ALERT(STR_MODEL, STR_MODEL_STILL_POWERED, STR_PRESS_ENTER_TO_CONFIRM, AU_MODEL_STILL_POWERED);
while (TELEMETRY_STREAMING()) {
RTOS_WAIT_MS(20);
if (readKeys() == (1 << KEY_ENTER)) {
killEvents(KEY_ENTER);
return true;
}
else if (readKeys() == (1 << KEY_EXIT)) {
killEvents(KEY_EXIT);
return false;
}
}
}
return true;
}
int getFirstAvailable(int min, int max, IsValueAvailable isValueAvailable)
{
int retval = 0;
+2
View File
@@ -99,6 +99,8 @@ bool isRssiSensorAvailable(int sensor);
bool modelHasNotes();
bool confirmModelChange();
#if defined(COLORLCD)
bool isSwitch2POSWarningStateAvailable(int state);
#endif