From e16b48db30b6bd8463a5d4402b3086459282c785 Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Wed, 16 Aug 2017 06:47:45 +0200 Subject: [PATCH] Reduce RF_PROTO_OFF logic, disable R9M Sport out when internal telemetry is on (#5159) * Remove most of the special logic associated with RF_PROTO_OFF This simplifies code in many areas since the internal module does not require special handling and also fixes a few bugs with INTERNAL_PPM * Disable R9M sport option if internal module has telemetry * Fix X12s build * Use macros instead of direct comparisions * Fix sport bit sent the wrong way. Rename S.port out to Telemetry * Compile fix --- radio/src/dataconstants.h | 8 +++----- radio/src/gui/128x64/model_setup.cpp | 19 +++++++++++-------- radio/src/gui/128x64/model_telemetry.cpp | 2 +- radio/src/gui/212x64/model_setup.cpp | 18 +++++++++++++----- radio/src/gui/212x64/model_telemetry.cpp | 4 ++-- radio/src/gui/480x272/model_setup.cpp | 14 +++++++++++--- radio/src/gui/gui_common.h | 3 ++- radio/src/gui/gui_common_arm.cpp | 6 +++--- radio/src/myeeprom.h | 4 +--- radio/src/opentx.h | 3 +-- radio/src/pulses/pulses_arm.cpp | 6 ++---- radio/src/pulses/pxx_arm.cpp | 4 +++- radio/src/storage/storage_common.cpp | 12 ++++++++++++ radio/src/targets/taranis/trainer_driver.cpp | 4 ++-- radio/src/telemetry/telemetry.cpp | 8 +------- radio/src/telemetry/telemetry.h | 6 ++++++ radio/src/translations.cpp | 2 +- radio/src/translations.h | 2 +- radio/src/translations/cz.h.txt | 2 +- radio/src/translations/de.h.txt | 2 +- radio/src/translations/en.h.txt | 2 +- radio/src/translations/es.h.txt | 2 +- radio/src/translations/fi.h.txt | 2 +- radio/src/translations/fr.h.txt | 2 +- radio/src/translations/it.h.txt | 2 +- radio/src/translations/nl.h.txt | 2 +- radio/src/translations/pl.h.txt | 2 +- radio/src/translations/pt.h.txt | 2 +- radio/src/translations/se.h.txt | 2 +- 29 files changed, 87 insertions(+), 60 deletions(-) diff --git a/radio/src/dataconstants.h b/radio/src/dataconstants.h index dd6a98b8fae..4a9077387f6 100644 --- a/radio/src/dataconstants.h +++ b/radio/src/dataconstants.h @@ -309,14 +309,12 @@ enum BeeperMode { #endif #if defined(PCBTARANIS) || defined(PCBHORUS) -#if defined(TARANIS_INTERNAL_PPM) - #define IS_INTERNAL_MODULE_ENABLED() (!(g_model.moduleData[INTERNAL_MODULE].rfProtocol == RF_PROTO_OFF && g_model.moduleData[INTERNAL_MODULE].type == MODULE_TYPE_XJT) && (g_model.moduleData[INTERNAL_MODULE].type != MODULE_TYPE_NONE)) -#else - #define IS_INTERNAL_MODULE_ENABLED() (g_model.moduleData[INTERNAL_MODULE].rfProtocol != RF_PROTO_OFF) -#endif +#define IS_INTERNAL_MODULE_ENABLED() (g_model.moduleData[INTERNAL_MODULE].type != MODULE_TYPE_NONE) #elif defined(PCBSKY9X) #define IS_INTERNAL_MODULE_ENABLED() (false) #endif +#define IS_EXTERNAL_MODULE_ENABLED() (g_model.moduleData[EXTERNAL_MODULE].type != MODULE_TYPE_NONE) + enum UartModes { #if defined(CLI) || defined(DEBUG) diff --git a/radio/src/gui/128x64/model_setup.cpp b/radio/src/gui/128x64/model_setup.cpp index f22e1504533..d76a42b272f 100644 --- a/radio/src/gui/128x64/model_setup.cpp +++ b/radio/src/gui/128x64/model_setup.cpp @@ -127,13 +127,8 @@ enum MenuModelSetupItems { #else #define INTERNAL_MODULE_MODE_ROWS (IS_MODULE_XJT(INTERNAL_MODULE) ? (uint8_t)1 : (uint8_t)0) // Module type + RF protocols #endif -#if defined(TARANIS_INTERNAL_PPM) - #define IF_INTERNAL_MODULE_ON(x) (g_model.moduleData[INTERNAL_MODULE].type == MODULE_TYPE_NONE ? HIDDEN_ROW : (uint8_t)(x)) -#else - #define IF_INTERNAL_MODULE_ON(x) (g_model.moduleData[INTERNAL_MODULE].rfProtocol == RF_PROTO_OFF ? HIDDEN_ROW : (uint8_t)(x)) -#endif - - #define IF_EXTERNAL_MODULE_ON(x) (g_model.moduleData[EXTERNAL_MODULE].type == MODULE_TYPE_NONE ? HIDDEN_ROW : (uint8_t)(x)) + #define IF_INTERNAL_MODULE_ON(x) (IS_INTERNAL_MODULE_ENABLED()? (uint8_t)(x) : HIDDEN_ROW ) + #define IF_EXTERNAL_MODULE_ON(x) (IS_EXTERNAL_MODULE_ENABLED()? (uint8_t)(x) : HIDDEN_ROW) #define INTERNAL_MODULE_CHANNELS_ROWS IF_INTERNAL_MODULE_ON(1) #define EXTERNAL_MODULE_BIND_ROWS() (IS_MODULE_XJT(EXTERNAL_MODULE) && IS_D8_RX(EXTERNAL_MODULE)) ? (uint8_t)1 : (IS_MODULE_PPM(EXTERNAL_MODULE) || IS_MODULE_PXX(EXTERNAL_MODULE) || IS_MODULE_DSM2(EXTERNAL_MODULE) || IS_MODULE_MULTIMODULE(EXTERNAL_MODULE)) ? (uint8_t)2 : HIDDEN_ROW @@ -684,6 +679,8 @@ void menuModelSetup(event_t event) g_model.moduleData[0].type = MODULE_TYPE_XJT; g_model.moduleData[0].channelsStart = 0; g_model.moduleData[0].channelsCount = DEFAULT_CHANNELS(INTERNAL_MODULE); + if (g_model.moduleData[INTERNAL_MODULE].rfProtocol == RF_PROTO_OFF) + g_model.moduleData[INTERNAL_MODULE].type = MODULE_TYPE_NONE; } } break; @@ -1082,7 +1079,13 @@ void menuModelSetup(event_t event) } #endif if (IS_MODULE_R9M(moduleIdx)) { - g_model.moduleData[moduleIdx].pxx.sport_out = editCheckBox(g_model.moduleData[EXTERNAL_MODULE].pxx.sport_out, MODEL_SETUP_2ND_COLUMN, y, STR_SPORT_OUT, attr, event); + if (IS_TELEMETRY_INTERNAL_MODULE) { + lcdDrawTextAlignedLeft(y, STR_SPORT_OUT); + lcdDrawText(MODEL_SETUP_2ND_COLUMN, y, STR_DISABLE_INTERNAL); + } + else { + g_model.moduleData[moduleIdx].pxx.sport_out = editCheckBox(g_model.moduleData[EXTERNAL_MODULE].pxx.sport_out, MODEL_SETUP_2ND_COLUMN, y, STR_SPORT_OUT, attr, event); + } } break; } diff --git a/radio/src/gui/128x64/model_telemetry.cpp b/radio/src/gui/128x64/model_telemetry.cpp index 954352855d1..2f7f5790b11 100644 --- a/radio/src/gui/128x64/model_telemetry.cpp +++ b/radio/src/gui/128x64/model_telemetry.cpp @@ -173,7 +173,7 @@ enum MenuModelTelemetryFrskyItems { #if defined (PCBTARANIS) - #define TELEMETRY_TYPE_SHOW_TELEMETRY (g_model.moduleData[INTERNAL_MODULE].rfProtocol == RF_PROTO_OFF && g_model.moduleData[EXTERNAL_MODULE].type == MODULE_TYPE_PPM) ? (uint8_t)0 : HIDDEN_ROW + #define TELEMETRY_TYPE_SHOW_TELEMETRY (! IS_INTERNAL_MODULE_ENABLED() && g_model.moduleData[EXTERNAL_MODULE].type == MODULE_TYPE_PPM) ? (uint8_t)0 : HIDDEN_ROW #elif defined (CPUARM) #define TELEMETRY_TYPE_SHOW_TELEMETRY (g_model.moduleData[EXTERNAL_MODULE].type == MODULE_TYPE_PPM) ? (uint8_t)0 : HIDDEN_ROW #endif diff --git a/radio/src/gui/212x64/model_setup.cpp b/radio/src/gui/212x64/model_setup.cpp index a5b59ec484e..5f06587f06d 100644 --- a/radio/src/gui/212x64/model_setup.cpp +++ b/radio/src/gui/212x64/model_setup.cpp @@ -231,14 +231,13 @@ int getSwitchWarningsCount() return count; } +#define IF_INTERNAL_MODULE_ON(x) (IS_INTERNAL_MODULE_ENABLED() ? (uint8_t)(x) : HIDDEN_ROW) #if defined(TARANIS_INTERNAL_PPM) - #define IF_INTERNAL_MODULE_ON(x) (g_model.moduleData[INTERNAL_MODULE].type == MODULE_TYPE_NONE ? HIDDEN_ROW : (uint8_t)(x)) #define INTERNAL_MODULE_MODE_ROWS (IS_MODULE_XJT(INTERNAL_MODULE) ? (uint8_t)1 : (uint8_t)0) // Module type + RF protocols #else - #define IF_INTERNAL_MODULE_ON(x) (g_model.moduleData[INTERNAL_MODULE].rfProtocol == RF_PROTO_OFF ? HIDDEN_ROW : (uint8_t)(x)) #define INTERNAL_MODULE_MODE_ROWS 0 // (OFF / RF protocols) #endif -#define IF_EXTERNAL_MODULE_ON(x) (g_model.moduleData[EXTERNAL_MODULE].type == MODULE_TYPE_NONE ? HIDDEN_ROW : (uint8_t)(x)) +#define IF_EXTERNAL_MODULE_ON(x) (IS_EXTERNAL_MODULE_ENABLED() ? (uint8_t)(x) : HIDDEN_ROW) #define INTERNAL_MODULE_CHANNELS_ROWS IF_INTERNAL_MODULE_ON(1) #define PORT_CHANNELS_ROWS(x) (x==INTERNAL_MODULE ? INTERNAL_MODULE_CHANNELS_ROWS : (x==EXTERNAL_MODULE ? EXTERNAL_MODULE_CHANNELS_ROWS : 1)) @@ -704,11 +703,14 @@ void menuModelSetup(event_t event) lcdDrawTextAlignedLeft(y, STR_MODE); lcdDrawTextAtIndex(MODEL_SETUP_2ND_COLUMN, y, STR_XJT_PROTOCOLS, 1+g_model.moduleData[0].rfProtocol, attr); if (attr) { - g_model.moduleData[INTERNAL_MODULE].rfProtocol = checkIncDec(event, g_model.moduleData[INTERNAL_MODULE].rfProtocol, RF_PROTO_OFF, RF_PROTO_LAST, EE_MODEL, isRfProtocolAvailable); + g_model.moduleData[INTERNAL_MODULE].rfProtocol = checkIncDec(event, g_model.moduleData[INTERNAL_MODULE].rfProtocol, -1, RF_PROTO_LAST, EE_MODEL, isRfProtocolAvailable); + if (checkIncDec_Ret) { g_model.moduleData[INTERNAL_MODULE].type = MODULE_TYPE_XJT; g_model.moduleData[INTERNAL_MODULE].channelsStart = 0; g_model.moduleData[INTERNAL_MODULE].channelsCount = DEFAULT_CHANNELS(INTERNAL_MODULE); + if (g_model.moduleData[INTERNAL_MODULE].rfProtocol == RF_PROTO_OFF) + g_model.moduleData[INTERNAL_MODULE].type = MODULE_TYPE_NONE; } } break; @@ -1079,7 +1081,13 @@ void menuModelSetup(event_t event) } #endif if (IS_MODULE_R9M(moduleIdx)) { - g_model.moduleData[moduleIdx].pxx.sport_out = editCheckBox(g_model.moduleData[EXTERNAL_MODULE].pxx.sport_out, MODEL_SETUP_2ND_COLUMN, y, STR_SPORT_OUT, attr, event); + if (IS_TELEMETRY_INTERNAL_MODULE) { + lcdDrawTextAlignedLeft(y, STR_SPORT_OUT); + lcdDrawText(MODEL_SETUP_2ND_COLUMN, y, STR_DISABLE_INTERNAL); + } + else { + g_model.moduleData[moduleIdx].pxx.sport_out = editCheckBox(g_model.moduleData[EXTERNAL_MODULE].pxx.sport_out, MODEL_SETUP_2ND_COLUMN, y, STR_SPORT_OUT, attr, event); + } } } break; diff --git a/radio/src/gui/212x64/model_telemetry.cpp b/radio/src/gui/212x64/model_telemetry.cpp index d7d9fa9843a..a15d5c03cc1 100644 --- a/radio/src/gui/212x64/model_telemetry.cpp +++ b/radio/src/gui/212x64/model_telemetry.cpp @@ -88,7 +88,7 @@ enum MenuModelTelemetryFrskyItems { #endif #define RSSI_ROWS LABEL(RSSI), 0, 0, 0, #define VARIO_RANGE_ROWS 3 -#define TELEMETRY_TYPE_ROWS (g_model.moduleData[INTERNAL_MODULE].rfProtocol == RF_PROTO_OFF && g_model.moduleData[EXTERNAL_MODULE].type == MODULE_TYPE_PPM) ? (uint8_t)0 : HIDDEN_ROW, +#define TELEMETRY_TYPE_ROWS (!IS_INTERNAL_MODULE_ENABLED() && g_model.moduleData[EXTERNAL_MODULE].type == MODULE_TYPE_PPM) ? (uint8_t)0 : HIDDEN_ROW, enum SensorFields { SENSOR_FIELD_NAME, @@ -516,7 +516,7 @@ void menuModelTelemetryFrsky(event_t event) case ITEM_TELEMETRY_RSSI_LABEL: #if defined(MULTIMODULE) - if (g_model.moduleData[INTERNAL_MODULE].rfProtocol == RF_PROTO_OFF && + if (g_model.moduleData[INTERNAL_MODULE].type != MODULE_TYPE_XJT && g_model.moduleData[EXTERNAL_MODULE].type == MODULE_TYPE_MULTIMODULE && g_model.moduleData[EXTERNAL_MODULE].getMultiProtocol(false) == MM_RF_PROTO_FS_AFHDS2A) lcdDrawTextAlignedLeft(y, PSTR("RSNR")); diff --git a/radio/src/gui/480x272/model_setup.cpp b/radio/src/gui/480x272/model_setup.cpp index 272d10ac1dd..1d5dc9876cf 100644 --- a/radio/src/gui/480x272/model_setup.cpp +++ b/radio/src/gui/480x272/model_setup.cpp @@ -209,8 +209,8 @@ int getSwitchWarningsCount() return count; } -#define IF_INTERNAL_MODULE_ON(x) (g_model.moduleData[INTERNAL_MODULE].rfProtocol == RF_PROTO_OFF ? HIDDEN_ROW : (uint8_t)(x)) -#define IF_EXTERNAL_MODULE_ON(x) (g_model.moduleData[EXTERNAL_MODULE].type == MODULE_TYPE_NONE ? HIDDEN_ROW : (uint8_t)(x)) +#define IF_INTERNAL_MODULE_ON(x) (IS_INTERNAL_MODULE_ENABLED() ? (uint8_t)(x) : HIDDEN_ROW) +#define IF_EXTERNAL_MODULE_ON(x) (IS_EXTERNAL_MODULE_ENABLED() ? (uint8_t)(x) : HIDDEN_ROW) #define INTERNAL_MODULE_MODE_ROWS (uint8_t)0 #define INTERNAL_MODULE_CHANNELS_ROWS IF_INTERNAL_MODULE_ON(1) @@ -624,7 +624,10 @@ bool menuModelSetup(event_t event) g_model.moduleData[0].type = MODULE_TYPE_XJT; g_model.moduleData[0].channelsStart = 0; g_model.moduleData[0].channelsCount = DEFAULT_CHANNELS(INTERNAL_MODULE); + if (g_model.moduleData[INTERNAL_MODULE].rfProtocol == RF_PROTO_OFF) + g_model.moduleData[INTERNAL_MODULE].type = MODULE_TYPE_NONE; } + } break; @@ -978,8 +981,13 @@ bool menuModelSetup(event_t event) #endif if (IS_MODULE_R9M(moduleIdx)) { lcdDrawText(MENUS_MARGIN_LEFT, y, STR_SPORT_OUT); - g_model.moduleData[moduleIdx].pxx.sport_out = editCheckBox(g_model.moduleData[EXTERNAL_MODULE].pxx.sport_out, MODEL_SETUP_2ND_COLUMN, y, attr, event); + if (IS_TELEMETRY_INTERNAL_MODULE) { + lcdDrawText(MODEL_SETUP_2ND_COLUMN, y, STR_DISABLE_INTERNAL); + } + else { + g_model.moduleData[moduleIdx].pxx.sport_out = editCheckBox(g_model.moduleData[EXTERNAL_MODULE].pxx.sport_out, MODEL_SETUP_2ND_COLUMN, y, attr, event); } + } } break; case ITEM_MODEL_EXTERNAL_MODULE_POWER: { diff --git a/radio/src/gui/gui_common.h b/radio/src/gui/gui_common.h index 6a713497329..e8aada2b1a4 100644 --- a/radio/src/gui/gui_common.h +++ b/radio/src/gui/gui_common.h @@ -158,7 +158,8 @@ const mm_protocol_definition *getMultiProtocolDefinition (uint8_t protocol); #define IS_R9M_OR_XJTD16(x) ((IS_MODULE_XJT(x) && g_model.moduleData[x].rfProtocol== RF_PROTO_X16) || IS_MODULE_R9M(x)) #define FAILSAFE_ROWS(x) ((IS_MODULE_XJT(x) && HAS_RF_PROTOCOL_FAILSAFE(g_model.moduleData[x].rfProtocol)) || MULTIMODULE_HASFAILSAFE(x) || IS_MODULE_R9M(x)) ? (g_model.moduleData[x].failsafeMode==FAILSAFE_CUSTOM ? (uint8_t)1 : (uint8_t)0) : HIDDEN_ROW -#define EXTERNAL_MODULE_OPTION_ROW (IS_MODULE_R9M(EXTERNAL_MODULE) ? (uint8_t) 0 : MULTIMODULE_OPTIONS_ROW) +#define R9M_OPTION_ROW (IS_TELEMETRY_INTERNAL_MODULE ? TITLE_ROW : (uint8_t) 0) +#define EXTERNAL_MODULE_OPTION_ROW (IS_MODULE_R9M(EXTERNAL_MODULE) ? R9M_OPTION_ROW : MULTIMODULE_OPTIONS_ROW) #define EXTERNAL_MODULE_POWER_ROW (IS_MODULE_MULTIMODULE(EXTERNAL_MODULE) || IS_MODULE_R9M(EXTERNAL_MODULE)) ? (uint8_t) 0 : HIDDEN_ROW void editStickHardwareSettings(coord_t x, coord_t y, int idx, event_t event, LcdFlags flags); diff --git a/radio/src/gui/gui_common_arm.cpp b/radio/src/gui/gui_common_arm.cpp index bd83e3f589a..0b0ab9a85ff 100644 --- a/radio/src/gui/gui_common_arm.cpp +++ b/radio/src/gui/gui_common_arm.cpp @@ -490,7 +490,7 @@ bool isSourceAvailableInResetSpecialFunction(int index) bool isModuleAvailable(int module) { #if defined(CROSSFIRE) && !defined(PCBFLAMENCO) - if (module == MODULE_TYPE_CROSSFIRE && g_model.moduleData[INTERNAL_MODULE].rfProtocol != RF_PROTO_OFF) { + if (module == MODULE_TYPE_CROSSFIRE && g_model.moduleData[INTERNAL_MODULE].type != MODULE_TYPE_NONE) { return false; } #else @@ -563,7 +563,7 @@ bool isTrainerModeAvailable(int mode) #elif defined(PCBX9E) bool isTrainerModeAvailable(int mode) { - if (IS_EXTERNAL_MODULE_PRESENT() && (mode == TRAINER_MODE_MASTER_SBUS_EXTERNAL_MODULE || mode == TRAINER_MODE_MASTER_CPPM_EXTERNAL_MODULE)) + if (IS_EXTERNAL_MODULE_ENABLED() && (mode == TRAINER_MODE_MASTER_SBUS_EXTERNAL_MODULE || mode == TRAINER_MODE_MASTER_CPPM_EXTERNAL_MODULE)) return false; #if defined(DEBUG) else if (mode == TRAINER_MODE_MASTER_BLUETOOTH || mode == TRAINER_MODE_MASTER_BATTERY_COMPARTMENT) @@ -577,7 +577,7 @@ bool isTrainerModeAvailable(int mode) #elif defined(PCBX9) bool isTrainerModeAvailable(int mode) { - if (IS_EXTERNAL_MODULE_PRESENT() && (mode == TRAINER_MODE_MASTER_SBUS_EXTERNAL_MODULE || mode == TRAINER_MODE_MASTER_CPPM_EXTERNAL_MODULE)) + if (IS_EXTERNAL_MODULE_ENABLED() && (mode == TRAINER_MODE_MASTER_SBUS_EXTERNAL_MODULE || mode == TRAINER_MODE_MASTER_CPPM_EXTERNAL_MODULE)) return false; else return true; diff --git a/radio/src/myeeprom.h b/radio/src/myeeprom.h index 712529dde26..6f98e285cee 100644 --- a/radio/src/myeeprom.h +++ b/radio/src/myeeprom.h @@ -491,7 +491,7 @@ enum Protocols { PROTO_NONE }; -enum RFProtocols { +enum XJTRFProtocols { RF_PROTO_OFF = -1, RF_PROTO_X16, RF_PROTO_D8, @@ -578,8 +578,6 @@ enum AntennaTypes { XJT_EXTERNAL_ANTENNA }; -#define IS_EXTERNAL_MODULE_PRESENT() (g_model.moduleData[EXTERNAL_MODULE].type != MODULE_TYPE_NONE) - enum FailsafeModes { FAILSAFE_NOT_SET, FAILSAFE_HOLD, diff --git a/radio/src/opentx.h b/radio/src/opentx.h index 2852271734f..63ca655138d 100644 --- a/radio/src/opentx.h +++ b/radio/src/opentx.h @@ -404,11 +404,10 @@ void memswap(void * a, void * b, uint8_t size); #if defined(PCBTARANIS) || defined(PCBHORUS) #if defined(TARANIS_INTERNAL_PPM) #define IS_MODULE_PPM(idx) (idx==TRAINER_MODULE || (idx==INTERNAL_MODULE && g_model.moduleData[INTERNAL_MODULE].type==MODULE_TYPE_PPM)|| (idx==EXTERNAL_MODULE && g_model.moduleData[EXTERNAL_MODULE].type==MODULE_TYPE_PPM)) - #define IS_MODULE_XJT(idx) (((idx==INTERNAL_MODULE && g_model.moduleData[INTERNAL_MODULE].type==MODULE_TYPE_XJT)|| (idx==EXTERNAL_MODULE && g_model.moduleData[EXTERNAL_MODULE].type==MODULE_TYPE_XJT)) && (g_model.moduleData[idx].rfProtocol != RF_PROTO_OFF)) #else #define IS_MODULE_PPM(idx) (idx==TRAINER_MODULE || (idx==EXTERNAL_MODULE && g_model.moduleData[EXTERNAL_MODULE].type==MODULE_TYPE_PPM)) - #define IS_MODULE_XJT(idx) ((idx==INTERNAL_MODULE || g_model.moduleData[EXTERNAL_MODULE].type==MODULE_TYPE_XJT) && (g_model.moduleData[idx].rfProtocol != RF_PROTO_OFF)) #endif + #define IS_MODULE_XJT(idx) (g_model.moduleData[idx].type==MODULE_TYPE_XJT) #if defined(DSM2) #define IS_MODULE_DSM2(idx) (idx==EXTERNAL_MODULE && g_model.moduleData[EXTERNAL_MODULE].type==MODULE_TYPE_DSM2) #else diff --git a/radio/src/pulses/pulses_arm.cpp b/radio/src/pulses/pulses_arm.cpp index 7eab0ae223e..1c139fdbf6a 100644 --- a/radio/src/pulses/pulses_arm.cpp +++ b/radio/src/pulses/pulses_arm.cpp @@ -39,11 +39,12 @@ uint8_t getRequiredProtocol(uint8_t port) switch (port) { #if defined(PCBTARANIS) || defined(PCBHORUS) case INTERNAL_MODULE: -#if defined(TARANIS_INTERNAL_PPM) switch (g_model.moduleData[INTERNAL_MODULE].type) { +#if defined(TARANIS_INTERNAL_PPM) case MODULE_TYPE_PPM: required_protocol = PROTO_PPM; break; +#endif case MODULE_TYPE_XJT: required_protocol = PROTO_PXX; break; @@ -51,9 +52,6 @@ uint8_t getRequiredProtocol(uint8_t port) required_protocol = PROTO_NONE; break; } -#else - required_protocol = g_model.moduleData[INTERNAL_MODULE].rfProtocol == RF_PROTO_OFF ? PROTO_NONE : PROTO_PXX; -#endif break; #endif diff --git a/radio/src/pulses/pxx_arm.cpp b/radio/src/pulses/pxx_arm.cpp index 02b2b361e2b..32ad8c494ac 100644 --- a/radio/src/pulses/pxx_arm.cpp +++ b/radio/src/pulses/pxx_arm.cpp @@ -387,7 +387,9 @@ void setupPulsesPXX(uint8_t port) #endif if (IS_MODULE_R9M(port)) { extra_flags |= g_model.moduleData[port].pxx.power << 3; - extra_flags |= g_model.moduleData[port].pxx.sport_out << 5; + // Disable s.port if internal module is active + if (IS_TELEMETRY_INTERNAL_MODULE || !g_model.moduleData[port].pxx.sport_out) + extra_flags |= (1<< 5); } putPcmByte(port, extra_flags); diff --git a/radio/src/storage/storage_common.cpp b/radio/src/storage/storage_common.cpp index ac86630abbf..9d6c727a201 100644 --- a/radio/src/storage/storage_common.cpp +++ b/radio/src/storage/storage_common.cpp @@ -55,9 +55,20 @@ void preModelLoad() pauseMixerCalculations(); } +#if defined(PCBTARANIS) || defined(PCBHORUS) +static void fixUpModel() +{ + // Ensure that when rfProtocol is RF_PROTO_OFF the type of the module is MODULE_TYPE_NONE + if (g_model.moduleData[INTERNAL_MODULE].type == MODULE_TYPE_XJT && g_model.moduleData[INTERNAL_MODULE].rfProtocol == RF_PROTO_OFF) + g_model.moduleData[INTERNAL_MODULE].type = MODULE_TYPE_NONE; +} +#endif void postModelLoad(bool alarms) { +#if defined(PCBTARANIS) || defined(PCBHORUS) + fixUpModel(); +#endif AUDIO_FLUSH(); flightReset(false); @@ -70,6 +81,7 @@ void postModelLoad(bool alarms) resumePulses(); } + customFunctionsReset(); restoreTimers(); diff --git a/radio/src/targets/taranis/trainer_driver.cpp b/radio/src/targets/taranis/trainer_driver.cpp index cdd2c9aafc3..7b4c65c2daa 100644 --- a/radio/src/targets/taranis/trainer_driver.cpp +++ b/radio/src/targets/taranis/trainer_driver.cpp @@ -193,7 +193,7 @@ void stop_cppm_on_heartbeat_capture() TRAINER_TIMER->CR1 &= ~TIM_CR1_CEN; // Stop counter NVIC_DisableIRQ(TRAINER_TIMER_IRQn); // Stop Interrupt - if (!IS_EXTERNAL_MODULE_PRESENT()) { + if (!IS_EXTERNAL_MODULE_ENABLED()) { EXTERNAL_MODULE_OFF(); } } @@ -255,7 +255,7 @@ void stop_sbus_on_heartbeat_capture() DMA_DeInit(HEARTBEAT_DMA_Stream); NVIC_DisableIRQ(HEARTBEAT_USART_IRQn); - if (!IS_EXTERNAL_MODULE_PRESENT()) { + if (!IS_EXTERNAL_MODULE_ENABLED()) { EXTERNAL_MODULE_OFF(); } } diff --git a/radio/src/telemetry/telemetry.cpp b/radio/src/telemetry/telemetry.cpp index 12b13369598..a98befd450d 100644 --- a/radio/src/telemetry/telemetry.cpp +++ b/radio/src/telemetry/telemetry.cpp @@ -56,12 +56,6 @@ lcdint_t applyChannelRatio(source_t channel, lcdint_t val) } #endif -#if defined(STM32) -#define IS_TELEMETRY_INTERNAL_MODULE (g_model.moduleData[INTERNAL_MODULE].rfProtocol != RF_PROTO_OFF) -#else -#define IS_TELEMETRY_INTERNAL_MODULE (false) -#endif - void processTelemetryData(uint8_t data) { #if defined(CROSSFIRE) @@ -179,7 +173,7 @@ void telemetryWakeup() } #if defined(PCBTARANIS) || defined(PCBHORUS) - if ((g_model.moduleData[INTERNAL_MODULE].rfProtocol != RF_PROTO_OFF || IS_MODULE_PXX(EXTERNAL_MODULE)) && FRSKY_BAD_ANTENNA()) { + if ((IS_MODULE_PXX(INTERNAL_MODULE) || IS_MODULE_PXX(EXTERNAL_MODULE)) && FRSKY_BAD_ANTENNA()) { AUDIO_SWR_RED(); POPUP_WARNING(STR_WARNING); const char * w = STR_ANTENNAPROBLEM; diff --git a/radio/src/telemetry/telemetry.h b/radio/src/telemetry/telemetry.h index d5e54e532bc..730523ca6ea 100644 --- a/radio/src/telemetry/telemetry.h +++ b/radio/src/telemetry/telemetry.h @@ -197,4 +197,10 @@ inline void telemetryOutputSetTrigger(uint8_t byte) extern Fifo * luaInputTelemetryFifo; #endif +#if defined(STM32) +#define IS_TELEMETRY_INTERNAL_MODULE (g_model.moduleData[INTERNAL_MODULE].type == MODULE_TYPE_XJT) +#else +#define IS_TELEMETRY_INTERNAL_MODULE (false) +#endif + #endif // _TELEMETRY_H_ diff --git a/radio/src/translations.cpp b/radio/src/translations.cpp index ba092e6854e..3b9ddbf3749 100644 --- a/radio/src/translations.cpp +++ b/radio/src/translations.cpp @@ -391,6 +391,7 @@ const pm_char STR_HOLD[] PROGMEM = TR_HOLD; const pm_char STR_NONE[] PROGMEM = TR_NONE; const pm_char STR_MENUSENSOR[] PROGMEM = TR_MENUSENSOR; const pm_char STR_SENSOR[] PROGMEM = TR_SENSOR; +const pm_char STR_DISABLE_INTERNAL[] PROGMEM = TR_DISABLE_INTERNAL; #endif const pm_char STR_INVERT_THR[] PROGMEM = TR_INVERT_THR; @@ -470,7 +471,6 @@ const pm_char STR_MULTI_OPTION[] PROGMEM = TR_MULTI_OPTION; const pm_char STR_MULTI_AUTOBIND[] PROGMEM = TR_MULTI_AUTOBIND; const pm_char STR_MULTI_DSM_AUTODTECT[] PROGMEM = TR_MULTI_DSM_AUTODTECT; const pm_char STR_MULTI_LOWPOWER[] PROGMEM = TR_MULTI_LOWPOWER; -const pm_char STR_DISABLE_INTERNAL[] PROGMEM = TR_DISABLE_INTERNAL; const pm_char STR_MODULE_NO_SERIAL_MODE[] PROGMEM = TR_MODULE_NO_SERIAL_MODE; const pm_char STR_MODULE_NO_INPUT[] PROGMEM = TR_MODULE_NO_INPUT; const pm_char STR_MODULE_NO_TELEMETRY[] PROGMEM = TR_MODULE_NO_TELEMETRY; diff --git a/radio/src/translations.h b/radio/src/translations.h index 4b6897e621f..8344ffc4347 100644 --- a/radio/src/translations.h +++ b/radio/src/translations.h @@ -604,7 +604,6 @@ extern const pm_char STR_MULTI_TELEMETRY[]; extern const pm_char STR_MULTI_AUTOBIND[]; extern const pm_char STR_MULTI_DSM_AUTODTECT[]; extern const pm_char STR_MULTI_LOWPOWER[]; -extern const pm_char STR_DISABLE_INTERNAL[]; extern const pm_char STR_MODULE_NO_SERIAL_MODE[]; extern const pm_char STR_MODULE_NO_INPUT[]; extern const pm_char STR_MODULE_NO_TELEMETRY[]; @@ -633,6 +632,7 @@ extern const pm_char STR_NONE[]; extern const pm_char STR_MENUSENSOR[]; extern const pm_char STR_SENSOR[]; extern const pm_char STR_COUNTRYCODE[]; +extern const pm_char STR_DISABLE_INTERNAL[]; #endif #if defined(TELEMETRY_FRSKY) diff --git a/radio/src/translations/cz.h.txt b/radio/src/translations/cz.h.txt index d923339b670..d87a281f0ed 100644 --- a/radio/src/translations/cz.h.txt +++ b/radio/src/translations/cz.h.txt @@ -855,7 +855,7 @@ #define TR_MULTI_AUTOBIND TR(INDENT "Autobind",INDENT "Bind on powerup") #define TR_MULTI_DSM_AUTODTECT TR(INDENT "Autodetect", INDENT "Autodetect format") #define TR_MULTI_LOWPOWER TR(INDENT "Low power", INDENT "Low power mode") -#define TR_SPORT_OUT INDENT "S.port out" +#define TR_SPORT_OUT INDENT "Telemetry" #define TR_DISABLE_INTERNAL TR("Disable int.", "Disable internal RF") #define TR_MODULE_NO_SERIAL_MODE TR("!serial mode", "Not in serial mode") #define TR_MODULE_NO_INPUT TR("No input", "No serial input") diff --git a/radio/src/translations/de.h.txt b/radio/src/translations/de.h.txt index c3cf6bb732c..5019f185268 100644 --- a/radio/src/translations/de.h.txt +++ b/radio/src/translations/de.h.txt @@ -876,7 +876,7 @@ #define TR_MULTI_AUTOBIND TR(INDENT "Autobind",INDENT "Bind on powerup") #define TR_MULTI_DSM_AUTODTECT TR(INDENT "Autodetect", INDENT "Autodetect format") #define TR_MULTI_LOWPOWER TR(INDENT "Low power", INDENT "Low power mode") -#define TR_SPORT_OUT INDENT "S.port out" +#define TR_SPORT_OUT INDENT "Telemetry" #define TR_DISABLE_INTERNAL TR("Disable int. RF", "Disable internal RF") #define TR_MODULE_NO_SERIAL_MODE TR("!serial mode", "Not in serial mode") #define TR_MODULE_NO_INPUT TR("No input", "No serial input") diff --git a/radio/src/translations/en.h.txt b/radio/src/translations/en.h.txt index 2131762603a..00f7d6ce72c 100644 --- a/radio/src/translations/en.h.txt +++ b/radio/src/translations/en.h.txt @@ -859,7 +859,7 @@ #define TR_MULTI_AUTOBIND TR(INDENT "Autobind",INDENT "Bind on powerup") #define TR_MULTI_DSM_AUTODTECT TR(INDENT "Autodetect", INDENT "Autodetect format") #define TR_MULTI_LOWPOWER TR(INDENT "Low power", INDENT "Low power mode") -#define TR_SPORT_OUT INDENT "S.port out" +#define TR_SPORT_OUT INDENT "Telemetry" #define TR_DISABLE_INTERNAL TR("Disable int.", "Disable internal RF") #define TR_MODULE_NO_SERIAL_MODE TR("!serial mode", "Not in serial mode") #define TR_MODULE_NO_INPUT TR("No input", "No serial input") diff --git a/radio/src/translations/es.h.txt b/radio/src/translations/es.h.txt index f591bca2535..da8c21f07ce 100644 --- a/radio/src/translations/es.h.txt +++ b/radio/src/translations/es.h.txt @@ -835,7 +835,7 @@ #define TR_MULTI_AUTOBIND TR(INDENT "Autobind",INDENT "Bind on powerup") #define TR_MULTI_DSM_AUTODTECT TR(INDENT "Autodetect", INDENT "Autodetect format") #define TR_MULTI_LOWPOWER TR(INDENT "Low power", INDENT "Low power mode") -#define TR_SPORT_OUT INDENT "S.port out" +#define TR_SPORT_OUT INDENT "Telemetry" #define TR_DISABLE_INTERNAL TR("Disable int. RF", "Disable internal RF") #define TR_MODULE_NO_SERIAL_MODE TR("!serial mode", "Not in serial mode") #define TR_MODULE_NO_INPUT TR("No input", "No serial input") diff --git a/radio/src/translations/fi.h.txt b/radio/src/translations/fi.h.txt index c30aeac5f11..7c651bbda52 100644 --- a/radio/src/translations/fi.h.txt +++ b/radio/src/translations/fi.h.txt @@ -831,7 +831,7 @@ #define TR_MULTI_AUTOBIND TR(INDENT "Autobind",INDENT "Bind on powerup") #define TR_MULTI_DSM_AUTODTECT TR(INDENT "Autodetect", INDENT "Autodetect format") #define TR_MULTI_LOWPOWER TR(INDENT "Low power", INDENT "Low power mode") -#define TR_SPORT_OUT INDENT "S.port out" +#define TR_SPORT_OUT INDENT "Telemetry" #define TR_DISABLE_INTERNAL TR("Disable int. RF", "Disable internal RF") #define TR_MODULE_NO_SERIAL_MODE TR("!serial mode", "Not in serial mode") #define TR_MODULE_NO_INPUT TR("No input", "No serial input") diff --git a/radio/src/translations/fr.h.txt b/radio/src/translations/fr.h.txt index 7ffef444a2e..1b0a6f9c177 100644 --- a/radio/src/translations/fr.h.txt +++ b/radio/src/translations/fr.h.txt @@ -873,7 +873,7 @@ #define TR_MULTI_AUTOBIND TR(INDENT "Bind auto", INDENT "Bind automatique") #define TR_MULTI_DSM_AUTODTECT TR(INDENT "Autodét.", INDENT "Autodétection") #define TR_MULTI_LOWPOWER TR(INDENT "Basse puis.", INDENT "Mode basse puiss.") -#define TR_SPORT_OUT INDENT "S.port out" +#define TR_SPORT_OUT INDENT "Telemetry" #define TR_DISABLE_INTERNAL TR("Désact intRF", "Désact. RF interne") #define TR_MODULE_NO_SERIAL_MODE TR("Mode série?", "Pas en mode série") #define TR_MODULE_NO_INPUT TR("Pas de sign.", "Aucun signal série") diff --git a/radio/src/translations/it.h.txt b/radio/src/translations/it.h.txt index 19dbff33d10..678c22c9d80 100644 --- a/radio/src/translations/it.h.txt +++ b/radio/src/translations/it.h.txt @@ -860,7 +860,7 @@ #define TR_MULTI_AUTOBIND TR(INDENT "Autobind",INDENT "Bind on powerup") #define TR_MULTI_DSM_AUTODTECT TR(INDENT "Autodetect", INDENT "Autodetect format") #define TR_MULTI_LOWPOWER TR(INDENT "Low power", INDENT "Low power mode") -#define TR_SPORT_OUT INDENT "S.port out" +#define TR_SPORT_OUT INDENT "Telemetry" #define TR_DISABLE_INTERNAL TR("Disable int. RF", "Disable internal RF") #define TR_MODULE_NO_SERIAL_MODE TR("!serial mode", "Not in serial mode") #define TR_MODULE_NO_INPUT TR("No input", "No serial input") diff --git a/radio/src/translations/nl.h.txt b/radio/src/translations/nl.h.txt index 1c9e5aff205..3b38291c4b6 100644 --- a/radio/src/translations/nl.h.txt +++ b/radio/src/translations/nl.h.txt @@ -855,7 +855,7 @@ #define TR_MULTI_AUTOBIND TR(INDENT "Autobind",INDENT "Bind on powerup") #define TR_MULTI_DSM_AUTODTECT TR(INDENT "Autodetect", INDENT "Autodetect format") #define TR_MULTI_LOWPOWER TR(INDENT "Low power", INDENT "Low power mode") -#define TR_SPORT_OUT INDENT "S.port out" +#define TR_SPORT_OUT INDENT "Telemetry" #define TR_DISABLE_INTERNAL TR("Disable int. RF", "Disable internal RF") #define TR_MODULE_NO_SERIAL_MODE TR("!serial mode", "Not in serial mode") #define TR_MODULE_NO_INPUT TR("No input", "No serial input") diff --git a/radio/src/translations/pl.h.txt b/radio/src/translations/pl.h.txt index 3d142edc123..db042cd0adf 100644 --- a/radio/src/translations/pl.h.txt +++ b/radio/src/translations/pl.h.txt @@ -861,7 +861,7 @@ #define TR_MULTI_AUTOBIND TR(INDENT "Autobind",INDENT "Bind on powerup") #define TR_MULTI_DSM_AUTODTECT TR(INDENT "Autodetect", INDENT "Autodetect format") #define TR_MULTI_LOWPOWER TR(INDENT "Low power", INDENT "Low power mode") -#define TR_SPORT_OUT INDENT "S.port out" +#define TR_SPORT_OUT INDENT "Telemetry" #define TR_DISABLE_INTERNAL TR("Disable int. RF", "Disable internal RF") #define TR_MODULE_NO_SERIAL_MODE TR("!serial mode", "Not in serial mode") #define TR_MODULE_NO_INPUT TR("No input", "No serial input") diff --git a/radio/src/translations/pt.h.txt b/radio/src/translations/pt.h.txt index a4dc3b6cbc2..854a0861766 100644 --- a/radio/src/translations/pt.h.txt +++ b/radio/src/translations/pt.h.txt @@ -837,7 +837,7 @@ #define TR_MULTI_AUTOBIND TR(INDENT "Autobind",INDENT "Bind on powerup") #define TR_MULTI_DSM_AUTODTECT TR(INDENT "Autodetect", INDENT "Autodetect format") #define TR_MULTI_LOWPOWER TR(INDENT "Low power", INDENT "Low power mode") -#define TR_SPORT_OUT INDENT "S.port out" +#define TR_SPORT_OUT INDENT "Telemetry" #define TR_DISABLE_INTERNAL TR("Disable int. RF", "Disable internal RF") #define TR_MODULE_NO_SERIAL_MODE TR("!serial mode", "Not in serial mode") #define TR_MODULE_NO_INPUT TR("No input", "No serial input") diff --git a/radio/src/translations/se.h.txt b/radio/src/translations/se.h.txt index 63b4d5d2644..2a79795bc0f 100644 --- a/radio/src/translations/se.h.txt +++ b/radio/src/translations/se.h.txt @@ -874,7 +874,7 @@ #define TR_MULTI_AUTOBIND TR(INDENT "Autobind",INDENT "Bind on powerup") #define TR_MULTI_DSM_AUTODTECT TR(INDENT "Autodetect", INDENT "Autodetect format") #define TR_MULTI_LOWPOWER TR(INDENT "Low power", INDENT "Low power mode") -#define TR_SPORT_OUT INDENT "S.port out" +#define TR_SPORT_OUT INDENT "Telemetry" #define TR_DISABLE_INTERNAL TR("Disable int. RF", "Disable internal RF") #define TR_MODULE_NO_SERIAL_MODE TR("!serial mode", "Not in serial mode") #define TR_MODULE_NO_INPUT TR("No input", "No serial input")