3djc/rssi poweroff safety (#5126)

Shutdown RSSI Alert
This commit is contained in:
Bertrand Songis
2017-08-01 14:13:25 +02:00
committed by GitHub
parent a7524ba74d
commit 7434e330c8
35 changed files with 1033 additions and 893 deletions
+51 -6
View File
@@ -252,7 +252,7 @@ void generalDefault()
g_eeGeneral.potsConfig = 0x05; // S1 and S2 = pots with detent
g_eeGeneral.slidersConfig = 0x03; // LS and RS = sliders with detent
#endif
#if defined(PCBX7)
g_eeGeneral.switchConfig = 0x000006ff; // 4x3POS, 1x2POS, 1xTOGGLE
#elif defined(PCBTARANIS) || defined(PCBHORUS)
@@ -973,7 +973,7 @@ void doSplash()
drawSecondSplash();
}
#endif
#if defined(PCBSKY9X)
if (curTime < get_tmr10ms()) {
curTime += 10;
@@ -2740,6 +2740,8 @@ uint32_t pwrPressedDuration()
uint32_t pwrCheck()
{
const char * message = NULL;
enum PwrCheckState {
PWR_CHECK_ON,
PWR_CHECK_OFF,
@@ -2752,11 +2754,17 @@ uint32_t pwrCheck()
return e_power_off;
}
else if (pwrPressed()) {
if (TELEMETRY_STREAMING()) {
message = STR_MODEL_STILL_POWERED;
}
if (pwr_check_state == PWR_CHECK_PAUSED) {
// nothing
}
else if (pwr_press_time == 0) {
pwr_press_time = get_tmr10ms();
if (message && g_eeGeneral.rssiPoweroffAlarm) {
audioEvent(AU_MODEL_STILL_POWERED);
}
}
else {
inactivity.counter = 0;
@@ -2783,13 +2791,30 @@ uint32_t pwrCheck()
}
}
#else
while ((TELEMETRY_STREAMING() && g_eeGeneral.rssiPoweroffAlarm)) {
lcdRefreshWait();
lcdClear();
POPUP_CONFIRMATION("Confirm Shutdown");
event_t evt = getEvent(false);
DISPLAY_WARNING(evt);
lcdRefresh();
if (warningResult == true) {
pwr_check_state = PWR_CHECK_OFF;
return e_power_off;
}
else if (!warningText) {
// shutdown has been cancelled
pwr_check_state = PWR_CHECK_PAUSED;
return e_power_on;
}
}
haptic.play(15, 3, PLAY_NOW);
pwr_check_state = PWR_CHECK_OFF;
return e_power_off;
#endif
}
else {
drawShutdownAnimation(pwrPressedDuration());
drawShutdownAnimation(pwrPressedDuration(), message);
return e_power_press;
}
}
@@ -2805,18 +2830,38 @@ uint32_t pwrCheck()
uint32_t pwrCheck()
{
#if defined(SOFT_PWR_CTRL)
if (pwrPressed())
if (pwrPressed()) {
return e_power_on;
}
#endif
if (usbPlugged())
if (usbPlugged()) {
return e_power_usb;
}
#if defined(TRAINER_PWR)
if (TRAINER_CONNECTED())
if (TRAINER_CONNECTED()) {
return e_power_trainer;
}
#endif
if (g_eeGeneral.rssiPoweroffAlarm) {
if (TELEMETRY_STREAMING()) {
RAISE_ALERT(STR_MODEL, STR_MODEL_STILL_POWERED, STR_PRESS_ENTER_TO_CONFIRM, AU_MODEL_STILL_POWERED);
while (TELEMETRY_STREAMING()) {
#if defined(CPUARM)
CoTickDelay(10);
#endif
if (pwrPressed()) {
return e_power_on;
}
else if (readKeys() == (1 << KEY_ENTER)) {
return e_power_off;
}
}
}
}
return e_power_off;
}
#endif