From 06cd8656f99504864a99d3655a8671f4009e51aa Mon Sep 17 00:00:00 2001 From: bsongis Date: Wed, 1 Jul 2015 20:27:54 +0200 Subject: [PATCH] [Taranis X9E] Possibility to shutdown the radio during an ALERT, with the small animation ... --- radio/src/main_arm.cpp | 2 +- radio/src/opentx.cpp | 26 +++++++++++++++++++++++++- radio/src/targets/simu/simpgmspace.cpp | 1 + 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/radio/src/main_arm.cpp b/radio/src/main_arm.cpp index cc733c351..da037c997 100644 --- a/radio/src/main_arm.cpp +++ b/radio/src/main_arm.cpp @@ -176,7 +176,7 @@ void perMain() drawStatusLine(); } -#if defined(REV9E) && !defined(SIMU) +#if defined(REV9E) uint32_t pwr_pressed_duration = pwrPressedDuration(); if (pwr_pressed_duration > 0) { displayShutdownProgress(pwr_pressed_duration); diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index 5ea54d0f2..afeba49fd 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -1169,8 +1169,9 @@ void checkAlarm() // added by Gohst if (g_eeGeneral.disableAlarmWarning) return; - if (IS_SOUND_OFF()) + if (IS_SOUND_OFF()) { ALERT(STR_ALARMSWARN, STR_ALARMSDISABLED, AU_ERROR); + } } void alert(const pm_char * t, const pm_char *s MESSAGE_SOUND_ARG) @@ -1183,6 +1184,13 @@ void alert(const pm_char * t, const pm_char *s MESSAGE_SOUND_ARG) if (pwrCheck() == e_power_off) { // the radio has been powered off during the ALERT +#if defined(TARANIS) && defined(REV9E) + // TODO this is quick & dirty + lcdOff(); + BACKLIGHT_OFF(); + topLcdOff(); + SysTick->CTRL = 0; // turn off systick +#endif pwrOff(); // turn power off now } @@ -1191,6 +1199,22 @@ void alert(const pm_char * t, const pm_char *s MESSAGE_SOUND_ARG) checkBacklight(); wdt_reset(); + +#if defined(REV9E) + static bool refresh = false; + uint32_t pwr_pressed_duration = pwrPressedDuration(); + if (refresh) { + lcdRefresh(); + refresh = false; + if (pwr_pressed_duration == 0) { + MESSAGE(t, s, STR_PRESSANYKEY, AU_NONE); + } + } + if (pwr_pressed_duration > 0) { + displayShutdownProgress(pwr_pressed_duration); + refresh = true; + } +#endif } } diff --git a/radio/src/targets/simu/simpgmspace.cpp b/radio/src/targets/simu/simpgmspace.cpp index bd255d8a4..12bfd96f0 100644 --- a/radio/src/targets/simu/simpgmspace.cpp +++ b/radio/src/targets/simu/simpgmspace.cpp @@ -1179,6 +1179,7 @@ void lcdRefresh() void pwrInit() { } uint32_t pwrCheck() { return true; } void pwrOff() { } +uint32_t pwrPressedDuration() { return 0; } void usbStart() { } int usbPlugged() { return false; } void USART_DeInit(USART_TypeDef* ) { }