mirror of
https://github.com/opentx/opentx.git
synced 2025-07-19 14:25:11 +03:00
[Taranis X9E] Shutdown procedure modified (popup with confirmation
added)
This commit is contained in:
parent
1f0d0433bb
commit
17f465bff5
8 changed files with 197 additions and 74 deletions
|
@ -923,7 +923,7 @@ ifeq ($(PCB), TARANIS)
|
||||||
CPPSRC += bmp.cpp gui/$(GUIDIRECTORY)/view_channels.cpp gui/$(GUIDIRECTORY)/view_about.cpp gui/$(GUIDIRECTORY)/view_text.cpp debug.cpp
|
CPPSRC += bmp.cpp gui/$(GUIDIRECTORY)/view_channels.cpp gui/$(GUIDIRECTORY)/view_about.cpp gui/$(GUIDIRECTORY)/view_text.cpp debug.cpp
|
||||||
CPPSRC += loadboot.cpp
|
CPPSRC += loadboot.cpp
|
||||||
ifeq ($(PCBREV), REV9E)
|
ifeq ($(PCBREV), REV9E)
|
||||||
EXTRABOARDSRC += targets/taranis/top_lcd_driver.cpp
|
CPPSRC += targets/taranis/top_lcd_driver.cpp
|
||||||
SRC += targets/taranis/system_stm32f4xx.c
|
SRC += targets/taranis/system_stm32f4xx.c
|
||||||
SRC += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/src/misc.c
|
SRC += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/src/misc.c
|
||||||
SRC += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_gpio.c
|
SRC += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_gpio.c
|
||||||
|
|
|
@ -176,13 +176,6 @@ void perMain()
|
||||||
drawStatusLine();
|
drawStatusLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(REV9E)
|
|
||||||
uint32_t pwr_pressed_duration = pwrPressedDuration();
|
|
||||||
if (pwr_pressed_duration > 0) {
|
|
||||||
displayShutdownProgress(pwr_pressed_duration);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
lcdRefresh();
|
lcdRefresh();
|
||||||
|
|
||||||
#if defined(REV9E) && !defined(SIMU)
|
#if defined(REV9E) && !defined(SIMU)
|
||||||
|
|
|
@ -977,6 +977,10 @@ bool readonlyUnlocked()
|
||||||
#if defined(SPLASH)
|
#if defined(SPLASH)
|
||||||
void doSplash()
|
void doSplash()
|
||||||
{
|
{
|
||||||
|
#if defined(PCBTARANIS) && defined(REV9E)
|
||||||
|
bool refresh = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (SPLASH_NEEDED()) {
|
if (SPLASH_NEEDED()) {
|
||||||
displaySplash();
|
displaySplash();
|
||||||
|
|
||||||
|
@ -997,7 +1001,8 @@ void doSplash()
|
||||||
inputsMoved();
|
inputsMoved();
|
||||||
|
|
||||||
tmr10ms_t tgtime = get_tmr10ms() + SPLASH_TIMEOUT;
|
tmr10ms_t tgtime = get_tmr10ms() + SPLASH_TIMEOUT;
|
||||||
while (tgtime != get_tmr10ms()) {
|
|
||||||
|
while (tgtime > get_tmr10ms()) {
|
||||||
#if defined(SIMU)
|
#if defined(SIMU)
|
||||||
SIMU_SLEEP(1);
|
SIMU_SLEEP(1);
|
||||||
#elif defined(CPUARM)
|
#elif defined(CPUARM)
|
||||||
|
@ -1017,7 +1022,23 @@ void doSplash()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (pwrCheck()==e_power_off) return;
|
#if defined(PCBTARANIS) && defined(REV9E)
|
||||||
|
uint32_t pwr_check = pwrCheck();
|
||||||
|
if (pwr_check == e_power_off) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (pwr_check == e_power_press) {
|
||||||
|
refresh = true;
|
||||||
|
}
|
||||||
|
else if (pwr_check == e_power_on && refresh) {
|
||||||
|
displaySplash();
|
||||||
|
refresh = false;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
if (pwrCheck() == e_power_off) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !defined(PCBTARANIS) && !defined(PCBSTD)
|
#if !defined(PCBTARANIS) && !defined(PCBSTD)
|
||||||
if (curTime < get_tmr10ms()) {
|
if (curTime < get_tmr10ms()) {
|
||||||
|
@ -1142,16 +1163,26 @@ void checkTHR()
|
||||||
MESSAGE(STR_THROTTLEWARN, STR_THROTTLENOTIDLE, STR_PRESSANYKEYTOSKIP, AU_THROTTLE_ALERT);
|
MESSAGE(STR_THROTTLEWARN, STR_THROTTLENOTIDLE, STR_PRESSANYKEYTOSKIP, AU_THROTTLE_ALERT);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (g_model.disableThrottleWarning) return;
|
if (g_model.disableThrottleWarning) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
getADC();
|
getADC();
|
||||||
|
|
||||||
evalInputs(e_perout_mode_notrainer); // let do evalInputs do the job
|
evalInputs(e_perout_mode_notrainer); // let do evalInputs do the job
|
||||||
|
|
||||||
int16_t v = calibratedStick[thrchn];
|
int16_t v = calibratedStick[thrchn];
|
||||||
if (v<=(THRCHK_DEADBAND-1024)) return; // prevent warning if throttle input OK
|
if (v <= THRCHK_DEADBAND-1024) {
|
||||||
|
return; // prevent warning if throttle input OK
|
||||||
|
}
|
||||||
|
|
||||||
// first - display warning; also deletes inputs if any have been before
|
// first - display warning; also deletes inputs if any have been before
|
||||||
MESSAGE(STR_THROTTLEWARN, STR_THROTTLENOTIDLE, STR_PRESSANYKEYTOSKIP, AU_THROTTLE_ALERT);
|
MESSAGE(STR_THROTTLEWARN, STR_THROTTLENOTIDLE, STR_PRESSANYKEYTOSKIP, AU_THROTTLE_ALERT);
|
||||||
|
|
||||||
|
#if defined(PCBTARANIS) && defined(REV9E)
|
||||||
|
bool refresh = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
|
||||||
SIMU_SLEEP(1);
|
SIMU_SLEEP(1);
|
||||||
|
@ -1159,10 +1190,30 @@ void checkTHR()
|
||||||
getADC();
|
getADC();
|
||||||
|
|
||||||
evalInputs(e_perout_mode_notrainer); // let do evalInputs do the job
|
evalInputs(e_perout_mode_notrainer); // let do evalInputs do the job
|
||||||
|
|
||||||
v = calibratedStick[thrchn];
|
v = calibratedStick[thrchn];
|
||||||
|
|
||||||
if (pwrCheck()==e_power_off || keyDown() || v<=(THRCHK_DEADBAND-1024))
|
#if defined(PCBTARANIS) && defined(REV9E)
|
||||||
|
uint32_t pwr_check = pwrCheck();
|
||||||
|
if (pwr_check == e_power_off) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
else if (pwr_check == e_power_press) {
|
||||||
|
refresh = true;
|
||||||
|
}
|
||||||
|
else if (pwr_check == e_power_on && refresh) {
|
||||||
|
MESSAGE(STR_THROTTLEWARN, STR_THROTTLENOTIDLE, STR_PRESSANYKEYTOSKIP, AU_NONE);
|
||||||
|
refresh = false;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
if (pwrCheck() == e_power_off) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (keyDown() || v <= THRCHK_DEADBAND-1024) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
checkBacklight();
|
checkBacklight();
|
||||||
|
|
||||||
|
@ -1173,8 +1224,9 @@ void checkTHR()
|
||||||
|
|
||||||
void checkAlarm() // added by Gohst
|
void checkAlarm() // added by Gohst
|
||||||
{
|
{
|
||||||
if (g_eeGeneral.disableAlarmWarning)
|
if (g_eeGeneral.disableAlarmWarning) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (IS_SOUND_OFF()) {
|
if (IS_SOUND_OFF()) {
|
||||||
ALERT(STR_ALARMSWARN, STR_ALARMSDISABLED, AU_ERROR);
|
ALERT(STR_ALARMSWARN, STR_ALARMSDISABLED, AU_ERROR);
|
||||||
|
@ -1185,42 +1237,41 @@ void alert(const pm_char * t, const pm_char *s MESSAGE_SOUND_ARG)
|
||||||
{
|
{
|
||||||
MESSAGE(t, s, STR_PRESSANYKEY, sound);
|
MESSAGE(t, s, STR_PRESSANYKEY, sound);
|
||||||
|
|
||||||
|
#if defined(PCBTARANIS) && defined(REV9E)
|
||||||
|
bool refresh = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
SIMU_SLEEP(1);
|
SIMU_SLEEP(1);
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
if (keyDown()) return; // wait for key release
|
if (keyDown()) return; // wait for key release
|
||||||
|
|
||||||
checkBacklight();
|
checkBacklight();
|
||||||
|
|
||||||
wdt_reset();
|
wdt_reset();
|
||||||
|
|
||||||
#if defined(REV9E)
|
#if defined(PCBTARANIS) && defined(REV9E)
|
||||||
static bool refresh = false;
|
uint32_t pwr_check = pwrCheck();
|
||||||
uint32_t pwr_pressed_duration = pwrPressedDuration();
|
if (pwr_check == e_power_off) {
|
||||||
if (refresh) {
|
// TODO this is quick & dirty
|
||||||
lcdRefresh();
|
lcdOff();
|
||||||
refresh = false;
|
BACKLIGHT_OFF();
|
||||||
if (pwr_pressed_duration == 0) {
|
topLcdOff();
|
||||||
MESSAGE(t, s, STR_PRESSANYKEY, AU_NONE);
|
SysTick->CTRL = 0; // turn off systick
|
||||||
}
|
pwrOff();
|
||||||
}
|
}
|
||||||
if (pwr_pressed_duration > 0) {
|
else if (pwr_check == e_power_press) {
|
||||||
displayShutdownProgress(pwr_pressed_duration);
|
|
||||||
refresh = true;
|
refresh = true;
|
||||||
}
|
}
|
||||||
|
else if (pwr_check == e_power_on && refresh) {
|
||||||
|
MESSAGE(t, s, STR_PRESSANYKEY, AU_NONE);
|
||||||
|
refresh = false;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
if (pwrCheck() == e_power_off) {
|
||||||
|
pwrOff(); // turn power off now
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2546,3 +2597,73 @@ int main(void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif // !SIMU
|
#endif // !SIMU
|
||||||
|
|
||||||
|
#if defined(PCBTARANIS) && defined(REV9E)
|
||||||
|
uint32_t pwr_press_time = 0;
|
||||||
|
|
||||||
|
uint32_t pwrPressedDuration()
|
||||||
|
{
|
||||||
|
if (pwr_press_time == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return get_tmr10ms() - pwr_press_time;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t pwrCheck()
|
||||||
|
{
|
||||||
|
enum PwrCheckState {
|
||||||
|
PWR_CHECK_ON,
|
||||||
|
PWR_CHECK_OFF,
|
||||||
|
PWR_CHECK_PAUSED,
|
||||||
|
};
|
||||||
|
|
||||||
|
static uint8_t pwr_check_state = PWR_CHECK_ON;
|
||||||
|
|
||||||
|
if (pwr_check_state == PWR_CHECK_OFF) {
|
||||||
|
return e_power_off;
|
||||||
|
}
|
||||||
|
else if (pwrPressed()) {
|
||||||
|
if (pwr_check_state == PWR_CHECK_PAUSED) {
|
||||||
|
// nothing
|
||||||
|
}
|
||||||
|
else if (pwr_press_time == 0) {
|
||||||
|
pwr_press_time = get_tmr10ms();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (get_tmr10ms() - pwr_press_time > 300) {
|
||||||
|
while (1) {
|
||||||
|
lcdRefreshWait();
|
||||||
|
lcd_clear();
|
||||||
|
POPUP_CONFIRMATION("Confirm Shutdown");
|
||||||
|
uint8_t evt = getEvent(false);
|
||||||
|
DISPLAY_WARNING(evt);
|
||||||
|
lcdRefresh();
|
||||||
|
if (s_warning_result == true) {
|
||||||
|
pwr_check_state = PWR_CHECK_OFF;
|
||||||
|
return e_power_off;
|
||||||
|
}
|
||||||
|
else if (!s_warning) {
|
||||||
|
// shutdown has been cancelled
|
||||||
|
pwr_check_state = PWR_CHECK_PAUSED;
|
||||||
|
return e_power_on;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
lcdRefreshWait();
|
||||||
|
displayShutdownProgress(pwrPressedDuration());
|
||||||
|
lcdRefresh();
|
||||||
|
return e_power_press;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
pwr_check_state = PWR_CHECK_ON;
|
||||||
|
pwr_press_time = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return e_power_on;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -41,7 +41,8 @@ enum PowerState {
|
||||||
e_power_on,
|
e_power_on,
|
||||||
e_power_trainer,
|
e_power_trainer,
|
||||||
e_power_usb,
|
e_power_usb,
|
||||||
e_power_off
|
e_power_off,
|
||||||
|
e_power_press,
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -611,6 +611,10 @@ void checkSwitches()
|
||||||
uint8_t bad_pots = 0, last_bad_pots = 0xff;
|
uint8_t bad_pots = 0, last_bad_pots = 0xff;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(PCBTARANIS) && defined(REV9E)
|
||||||
|
bool refresh = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !defined(MODULE_ALWAYS_SEND_PULSES)
|
#if !defined(MODULE_ALWAYS_SEND_PULSES)
|
||||||
while (1) {
|
while (1) {
|
||||||
|
|
||||||
|
@ -621,8 +625,9 @@ void checkSwitches()
|
||||||
#define GETADC_COUNT 1
|
#define GETADC_COUNT 1
|
||||||
#endif
|
#endif
|
||||||
#ifdef GETADC_COUNT
|
#ifdef GETADC_COUNT
|
||||||
for (int i=0; i<GETADC_COUNT; i++)
|
for (int i=0; i<GETADC_COUNT; i++) {
|
||||||
getADC();
|
getADC();
|
||||||
|
}
|
||||||
#undef GETADC_COUNT
|
#undef GETADC_COUNT
|
||||||
#endif
|
#endif
|
||||||
#endif // !defined(MODULE_ALWAYS_SEND_PULSES)
|
#endif // !defined(MODULE_ALWAYS_SEND_PULSES)
|
||||||
|
@ -752,7 +757,28 @@ void checkSwitches()
|
||||||
last_bad_switches = 0xff;
|
last_bad_switches = 0xff;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (pwrCheck()==e_power_off || keyDown()) return;
|
|
||||||
|
if (keyDown()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(PCBTARANIS) && defined(REV9E)
|
||||||
|
uint32_t pwr_check = pwrCheck();
|
||||||
|
if (pwr_check == e_power_off) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (pwr_check == e_power_press) {
|
||||||
|
refresh = true;
|
||||||
|
}
|
||||||
|
else if (pwr_check == e_power_on && refresh) {
|
||||||
|
last_bad_switches = 0xff;
|
||||||
|
refresh = false;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
if (pwrCheck() == e_power_off) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
checkBacklight();
|
checkBacklight();
|
||||||
|
|
||||||
|
|
|
@ -1177,9 +1177,12 @@ void lcdRefresh()
|
||||||
|
|
||||||
#if defined(PCBTARANIS)
|
#if defined(PCBTARANIS)
|
||||||
void pwrInit() { }
|
void pwrInit() { }
|
||||||
uint32_t pwrCheck() { return true; }
|
|
||||||
void pwrOff() { }
|
void pwrOff() { }
|
||||||
uint32_t pwrPressedDuration() { return 0; }
|
#if defined(REV9E)
|
||||||
|
uint32_t pwrPressed() { return false; }
|
||||||
|
#else
|
||||||
|
uint32_t pwrCheck() { return true; }
|
||||||
|
#endif
|
||||||
void usbStart() { }
|
void usbStart() { }
|
||||||
int usbPlugged() { return false; }
|
int usbPlugged() { return false; }
|
||||||
void USART_DeInit(USART_TypeDef* ) { }
|
void USART_DeInit(USART_TypeDef* ) { }
|
||||||
|
|
|
@ -110,38 +110,6 @@ uint32_t pwrPressed()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(REV9E) && !defined(BOOT)
|
|
||||||
uint32_t pwrPressTime = 0;
|
|
||||||
|
|
||||||
uint32_t pwrPressedDuration()
|
|
||||||
{
|
|
||||||
if (pwrPressTime == 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return get_tmr10ms() - pwrPressTime;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t pwrCheck()
|
|
||||||
{
|
|
||||||
if (pwrPressed()) {
|
|
||||||
if (pwrPressTime == 0) {
|
|
||||||
pwrPressTime = get_tmr10ms();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (get_tmr10ms() - pwrPressTime > 250) {
|
|
||||||
return e_power_off;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
pwrPressTime = 0;
|
|
||||||
}
|
|
||||||
return e_power_on;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(REV9E)
|
#if !defined(REV9E)
|
||||||
uint32_t pwrCheck()
|
uint32_t pwrCheck()
|
||||||
{
|
{
|
||||||
|
|
|
@ -159,7 +159,18 @@ void menusTask(void * pdata)
|
||||||
{
|
{
|
||||||
opentxInit();
|
opentxInit();
|
||||||
|
|
||||||
|
#if defined(PCBTARANIS) && defined(REV9E)
|
||||||
|
while (1) {
|
||||||
|
uint32_t pwr_check = pwrCheck();
|
||||||
|
if (pwr_check == e_power_off) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (pwr_check == e_power_press) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
#else
|
||||||
while (pwrCheck() != e_power_off) {
|
while (pwrCheck() != e_power_off) {
|
||||||
|
#endif
|
||||||
U64 start = CoGetOSTime();
|
U64 start = CoGetOSTime();
|
||||||
perMain();
|
perMain();
|
||||||
// TODO remove completely massstorage from sky9x firmware
|
// TODO remove completely massstorage from sky9x firmware
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue