From ffe8d821cdaca0b74bbd601f96f319595555114f Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Tue, 18 Jun 2019 23:28:59 +0200 Subject: [PATCH] Double warnings on USB disconnect --- radio/src/opentx.cpp | 21 ++++++----------- radio/src/opentx.h | 4 ++++ radio/src/pulses/pulses.h | 31 +++++++++++++++++++++----- radio/src/targets/simu/simpgmspace.cpp | 4 ++-- 4 files changed, 38 insertions(+), 22 deletions(-) diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index 6d3fb20a4..62af6d9e6 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -1481,26 +1481,18 @@ void doMixerCalculations() s_mixer_first_run_done = true; } - -#define OPENTX_START_NO_SPLASH 0x01 -#define OPENTX_START_NO_CHECKS 0x02 - #if !defined(OPENTX_START_DEFAULT_ARGS) #define OPENTX_START_DEFAULT_ARGS 0 #endif -void opentxStart(const uint8_t startType = OPENTX_START_DEFAULT_ARGS) +void opentxStart(const uint8_t startOptions = OPENTX_START_DEFAULT_ARGS) { - TRACE("opentxStart(%u)", startType); + TRACE("opentxStart(%u)", startOptions); - if (startType & OPENTX_START_NO_CHECKS) { - return; - } - - uint8_t calibration_needed = (g_eeGeneral.chkSum != evalChkSum()); + uint8_t calibration_needed = !(startOptions & OPENTX_START_NO_CALIBRATION) && (g_eeGeneral.chkSum != evalChkSum()); #if defined(GUI) - if (!calibration_needed && !(startType & OPENTX_START_NO_SPLASH)) { + if (!calibration_needed && !(startOptions & OPENTX_START_NO_SPLASH)) { doSplash(); } #endif @@ -1523,7 +1515,7 @@ void opentxStart(const uint8_t startType = OPENTX_START_DEFAULT_ARGS) if (calibration_needed) { chainMenu(menuFirstCalib); } - else { + else if (!(startOptions & OPENTX_START_NO_CHECKS)) { checkAlarm(); checkAll(); PLAY_MODEL_NAME(); @@ -1601,7 +1593,8 @@ void opentxResume() loadFontCache(); #endif - opentxStart(OPENTX_START_NO_SPLASH); + // removed to avoid the double warnings (throttle, switch, etc.) + // opentxStart(OPENTX_START_NO_SPLASH | OPENTX_START_NO_CALIBRATION | OPENTX_START_NO_CHECKS); referenceSystemAudioFiles(); diff --git a/radio/src/opentx.h b/radio/src/opentx.h index 352bdf86c..e74139609 100644 --- a/radio/src/opentx.h +++ b/radio/src/opentx.h @@ -1076,6 +1076,10 @@ void opentxClose(uint8_t shutdown=true); void opentxInit(); void opentxResume(); +constexpr uint8_t OPENTX_START_NO_SPLASH = 0x01; +constexpr uint8_t OPENTX_START_NO_CALIBRATION = 0x02; +constexpr uint8_t OPENTX_START_NO_CHECKS = 0x04; + #if defined(STATUS_LEDS) #define LED_ERROR_BEGIN() ledRed() #define LED_ERROR_END() ledBlue() diff --git a/radio/src/pulses/pulses.h b/radio/src/pulses/pulses.h index a6a65ce36..d6612b48c 100644 --- a/radio/src/pulses/pulses.h +++ b/radio/src/pulses/pulses.h @@ -353,15 +353,35 @@ enum ChannelsProtocols { PROTOCOL_CHANNELS_PXX2 }; -inline bool pulsesStarted() { return moduleState[0].protocol != PROTOCOL_CHANNELS_UNINITIALIZED; } -inline void pausePulses() { s_pulses_paused = true; } -inline void resumePulses() { s_pulses_paused = false; } +inline void stopPulses() +{ + s_pulses_paused = true; + moduleState[0].protocol = PROTOCOL_CHANNELS_UNINITIALIZED; +} -#define SEND_FAILSAFE_NOW(idx) moduleState[idx].counter = 1 +inline bool pulsesStarted() +{ + return moduleState[0].protocol != PROTOCOL_CHANNELS_UNINITIALIZED; +} + +inline void pausePulses() +{ + s_pulses_paused = true; +} + +inline void resumePulses() +{ + s_pulses_paused = false; +} + +inline void SEND_FAILSAFE_NOW(uint8_t idx) +{ + moduleState[idx].counter = 1; +} inline void SEND_FAILSAFE_1S() { - for (int i=0; i