From fa8fbb6dbb2950b00de13c20cd6188f124f41e7b Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Tue, 13 Aug 2019 20:42:48 +0200 Subject: [PATCH 01/17] Added general registrationId --- companion/src/generaledit/generalsetup.cpp | 12 + companion/src/generaledit/generalsetup.h | 1 + companion/src/generaledit/generalsetup.ui | 617 +++++++++++---------- 3 files changed, 330 insertions(+), 300 deletions(-) diff --git a/companion/src/generaledit/generalsetup.cpp b/companion/src/generaledit/generalsetup.cpp index b96306af3..bcc61afde 100644 --- a/companion/src/generaledit/generalsetup.cpp +++ b/companion/src/generaledit/generalsetup.cpp @@ -455,6 +455,9 @@ void GeneralSetupPanel::setValues() ui->pwrOnSpeed->setValue(generalSettings.pwrOnSpeed); ui->pwrOffSpeed->setValue(generalSettings.pwrOffSpeed); + + // TODO: only if ACCESS available?? + ui->registrationId->setText(generalSettings.registrationId); } void GeneralSetupPanel::on_faimode_CB_stateChanged(int) @@ -747,6 +750,15 @@ void GeneralSetupPanel::on_blAlarm_ChkB_stateChanged() emit modified(); } +void GeneralSetupPanel::on_ownerID_editingFinished() +{ + //copy ownerID back to generalSettings.registrationId + QByteArray array = ui->registrationId->text().toLocal8Bit(); + strncpy(generalSettings.registrationId, "pafleraf", 9); + generalSettings.registrationId[8] = '\0'; + emit modified(); +} + void GeneralSetupPanel::stickReverseEdited() { generalSettings.stickReverse = ((int)ui->stickReverse1->isChecked()) | ((int)ui->stickReverse2->isChecked()<<1) | ((int)ui->stickReverse3->isChecked()<<2) | ((int)ui->stickReverse4->isChecked()<<3); diff --git a/companion/src/generaledit/generalsetup.h b/companion/src/generaledit/generalsetup.h index 9dc636768..5ad3a1afe 100644 --- a/companion/src/generaledit/generalsetup.h +++ b/companion/src/generaledit/generalsetup.h @@ -87,6 +87,7 @@ class GeneralSetupPanel : public GeneralPanel void on_vBatMinDSB_editingFinished(); void on_vBatMaxDSB_editingFinished(); void on_contrastSB_editingFinished(); + void on_ownerID_editingFinished(); void on_pwrOnSpeed_valueChanged(); void on_pwrOffSpeed_valueChanged(); diff --git a/companion/src/generaledit/generalsetup.ui b/companion/src/generaledit/generalsetup.ui index 5e2941508..88789aa8c 100644 --- a/companion/src/generaledit/generalsetup.ui +++ b/companion/src/generaledit/generalsetup.ui @@ -554,6 +554,33 @@ + + + + + 0 + 0 + + + + 23 + + + + + + + RotEnc Navigation + + + + + + + + + + @@ -567,59 +594,89 @@ - - - - Country Code - - - - - + + - If you enable FAI, only RSSI and RxBt sensors will keep working. This function cannot be disabled by the radio. - - - - - - - - FAI Mode + + + + + This is the switch selectrion for turning on the backlight (if installed). + + + + + -1 - - - - - - -14 - - - 12 - - - 0 - - - - - - - Automatically adjust the radio's clock if a GPS is connected to telemetry. - - - Qt::RightToLeft - - - Adjust RTC - - - - + + + + Backlight flash on alarm + + + + + + + Backlight Auto OFF after + + + + + + + Backlight Switch + + + + + + + ms + + + 200 + + + 1000 + + + 10 + + + 500 + + + + + + + Voice Language + + + + + + + Hz + + + 300 + + + 1100 + + + 10 + + + 700 + + @@ -653,94 +710,38 @@ - - + + - Speaker Volume + Vario repeat at zero - - - - Hz + + + + Vario pitch at zero - - 1300 + + + + + + FAI Mode + + + + + + Backlight OFF Brightness + + + + + - 2900 - - - 10 - - - 1700 - - - - - - - Vario pitch at max - - - - - - - Backlight Switch - - - - - - - - 0 - 0 - - - - 23 - - - - - - - - - Color 1 - - - - - - - 20 - - - 5 - - - Qt::Horizontal - - - - - - - Color 2 - - - - - - - - - Sound Mode + 100 @@ -772,17 +773,95 @@ - - - - Backlight color + + + + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">LCD Screen Contrast</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Values can be 20-45</span></p></body></html> + + + 1 + + + 20 + + + 1 - - + + + + Hz + + + 1300 + + + 2900 + + + 10 + + + 1700 + + + + + - Speaker Pitch (spkr only) + Timeshift from UTC + + + + + + + 5 + + + 100 + + + + + + + + America + + + + + Japan + + + + + Europe + + + + + + + + If you enable FAI, only RSSI and RxBt sensors will keep working. This function cannot be disabled by the radio. + + + @@ -810,6 +889,13 @@ + + + + Backlight Brightness + + + @@ -906,168 +992,116 @@ - - - - ms - - - 200 - - - 1000 - - - 10 - - - 500 - - - - - - - Hz - - - 300 - - - 1100 - - - 10 - - - 700 - - - - - + + - Backlight flash on alarm + Backlight color - - + + - Vario pitch at zero + Vario pitch at max - - + + - Vario repeat at zero + Speaker Pitch (spkr only) - - - - 100 - - - - - - - Backlight Auto OFF after - - - - - - - - - - - - - This is the switch selectrion for turning on the backlight (if installed). - - - - - -1 - - - - - - - - - - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">LCD Screen Contrast</span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Values can be 20-45</span></p></body></html> - - - 1 - - - 20 - - - 1 - - - - - - - RotEnc Navigation - - - - - - - - - - - - - - Backlight Brightness - - - - - + + - - America - + + + Color 1 + + - - Japan - + + + 20 + + + 5 + + + Qt::Horizontal + + - - Europe - + + + Color 2 + + + + + + + + Country Code + - + + + + Sound Mode + + + + + + + Speaker Volume + + + + + + + + + -14 + + + 12 + + + 0 + + + + + + + Automatically adjust the radio's clock if a GPS is connected to telemetry. + + + Qt::RightToLeft + + + Adjust RTC + + + + + + + + + Qt::Vertical @@ -1080,37 +1114,20 @@ p, li { white-space: pre-wrap; } - - + + - Voice Language + Owner Registration ID - - - - Timeshift from UTC + + + + aaaaaaAA - - - - - - - - - Backlight OFF Brightness - - - - - - - 5 - - - 100 + + 8 From ac0ee910785d2aeaf2ef4d26a6db87d521bf1350 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Wed, 14 Aug 2019 09:37:31 +0200 Subject: [PATCH 02/17] support for other modules & protocols --- companion/src/firmwares/moduledata.cpp | 5 +- companion/src/firmwares/moduledata.h | 4 + .../src/firmwares/opentx/opentxeeprom.cpp | 11 ++- companion/src/firmwares/opentx/opentxeeprom.h | 7 +- .../src/firmwares/opentx/opentxinterface.cpp | 7 +- companion/src/modeledit/setup.cpp | 84 ++++++++++++++----- companion/src/modeledit/setup_module.ui | 77 +++++++++++++++-- 7 files changed, 158 insertions(+), 37 deletions(-) diff --git a/companion/src/firmwares/moduledata.cpp b/companion/src/firmwares/moduledata.cpp index cd72f01f1..4b11df7af 100644 --- a/companion/src/firmwares/moduledata.cpp +++ b/companion/src/firmwares/moduledata.cpp @@ -106,10 +106,11 @@ QString ModuleData::protocolToString(unsigned protocol) "FrSky PXX R9M", "FrSky PXX R9M Lite", "SBUS output at VBat", - "FrSky ACCESS ISRM", + "FrSky ACCESS ISRM", "FrSky ACCST ISRM D16", "FrSky ACCESS R9M", "FrSky ACCESS R9M Lite", - "FrSky ACCESS R9M Lite Pro" + "FrSky ACCESS R9M Lite Pro", + "FrSky XJT lite (D16)", "FrSky XJT lite (D8)", "FrSky XJT lite (LR12)" }; return CHECK_IN_ARRAY(strings, protocol); diff --git a/companion/src/firmwares/moduledata.h b/companion/src/firmwares/moduledata.h index d96322eab..2f940c504 100644 --- a/companion/src/firmwares/moduledata.h +++ b/companion/src/firmwares/moduledata.h @@ -50,9 +50,13 @@ enum PulsesProtocol { PULSES_PXX_R9M_LITE, PULSES_SBUS, PULSES_ACCESS_ISRM, + PULSES_ACCST_ISRM_D16, PULSES_ACCESS_R9M, PULSES_ACCESS_R9M_LITE, PULSES_ACCESS_R9M_LITE_PRO, + PULSES_XJT_LITE_X16, + PULSES_XJT_LITE_D8, + PULSES_XJT_LITE_LR12, PULSES_PROTOCOL_LAST }; diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index b50228604..a23c439ea 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -2222,7 +2222,8 @@ void OpenTxModelData::beforeExport() for (int module=0; module<2; module++) { if ((modelData.moduleData[module].protocol >= PULSES_PXX_XJT_X16 && modelData.moduleData[module].protocol <= PULSES_PXX_XJT_LR12) || - modelData.moduleData[module].protocol == PULSES_PXX_R9M) { + modelData.moduleData[module].protocol == PULSES_PXX_R9M) { + if (modelData.moduleData[module].protocol != PULSES_PXX_R9M) { subprotocols[module] = modelData.moduleData[module].protocol - PULSES_PXX_XJT_X16; } @@ -2232,7 +2233,6 @@ void OpenTxModelData::beforeExport() modelData.moduleData[module].ppm.delay = 300 + 50 * pxxByte; modelData.moduleData[module].ppm.pulsePol = modelData.moduleData[module].pxx.external_antenna; modelData.moduleData[module].ppm.outputType = modelData.moduleData[module].pxx.sport_out; - } else if (modelData.moduleData[module].protocol >= PULSES_LP45 && modelData.moduleData[module].protocol <= PULSES_DSMX) { subprotocols[module] = modelData.moduleData[module].protocol - PULSES_LP45; @@ -2247,6 +2247,9 @@ void OpenTxModelData::beforeExport() modelData.moduleData[module].ppm.outputType = modelData.moduleData[module].multi.lowPowerMode; modelData.moduleData[module].ppm.pulsePol = modelData.moduleData[module].multi.autoBindMode; } + else if (modelData.moduleData[module].protocol == PULSES_ACCST_ISRM_D16 || modelData.moduleData[module].protocol == PULSES_ACCESS_ISRM) { + subprotocols[module] = modelData.moduleData[module].protocol - PULSES_ACCESS_ISRM; + } else { subprotocols[module] = (module == 0 ? -1 : 0); } @@ -2273,7 +2276,9 @@ void OpenTxModelData::afterImport() } for (int module=0; module<2; module++) { - if (modelData.moduleData[module].protocol == PULSES_PXX_XJT_X16 || modelData.moduleData[module].protocol == PULSES_LP45) { + if (modelData.moduleData[module].protocol == PULSES_PXX_XJT_X16 + || modelData.moduleData[module].protocol == PULSES_LP45 + || modelData.moduleData[module].protocol == PULSES_ACCESS_ISRM) { if (subprotocols[module] >= 0) modelData.moduleData[module].protocol += subprotocols[module]; else diff --git a/companion/src/firmwares/opentx/opentxeeprom.h b/companion/src/firmwares/opentx/opentxeeprom.h index b421420ba..ff11a0dc3 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.h +++ b/companion/src/firmwares/opentx/opentxeeprom.h @@ -83,7 +83,8 @@ class ProtocolsConversionTable: public ConversionTable addConversion(PULSES_PXX_XJT_D8, val); addConversion(PULSES_PXX_XJT_LR12, val++); - addConversion(PULSES_ACCESS_ISRM, val++); + addConversion(PULSES_ACCESS_ISRM, val); + addConversion(PULSES_ACCST_ISRM_D16, val++); addConversion(PULSES_LP45, val); addConversion(PULSES_DSM2, val); @@ -99,6 +100,10 @@ class ProtocolsConversionTable: public ConversionTable addConversion(PULSES_ACCESS_R9M_LITE_PRO, val++); addConversion(PULSES_SBUS, val++); + + addConversion(PULSES_XJT_LITE_X16, val); + addConversion(PULSES_XJT_LITE_D8, val); + addConversion(PULSES_XJT_LITE_LR12, val++); } }; diff --git a/companion/src/firmwares/opentx/opentxinterface.cpp b/companion/src/firmwares/opentx/opentxinterface.cpp index 72483c506..6fe953b5e 100644 --- a/companion/src/firmwares/opentx/opentxinterface.cpp +++ b/companion/src/firmwares/opentx/opentxinterface.cpp @@ -772,11 +772,12 @@ int OpenTxFirmware::isAvailable(PulsesProtocol proto, int port) case PULSES_PPM: return id.contains("internalppm") ? 1 : 0; case PULSES_ACCESS_ISRM: + case PULSES_ACCST_ISRM_D16: return (IS_TARANIS_XLITES(board) || IS_TARANIS_X9LITE(board)) ? 1 : 0; default: return 0; } - + case 1: switch (proto) { case PULSES_OFF: @@ -802,6 +803,10 @@ int OpenTxFirmware::isAvailable(PulsesProtocol proto, int port) case PULSES_ACCESS_R9M_LITE: case PULSES_ACCESS_R9M_LITE_PRO: return (IS_TARANIS_XLITES(board) || IS_TARANIS_X9LITE(board)) ? 1 : 0; + case PULSES_XJT_LITE_X16: + case PULSES_XJT_LITE_D8: + case PULSES_XJT_LITE_LR12: + return (IS_TARANIS_XLITES(board) || IS_TARANIS_X9LITE(board)) ? 1 : 0; default: return 0; } diff --git a/companion/src/modeledit/setup.cpp b/companion/src/modeledit/setup.cpp index 2dc74e5fe..b833eff7b 100644 --- a/companion/src/modeledit/setup.cpp +++ b/companion/src/modeledit/setup.cpp @@ -166,19 +166,20 @@ void TimerPanel::on_name_editingFinished() #define FAILSAFE_CHANNEL_HOLD 2000 #define FAILSAFE_CHANNEL_NOPULSE 2001 -#define MASK_PROTOCOL 1 -#define MASK_CHANNELS_COUNT 2 -#define MASK_RX_NUMBER 4 -#define MASK_CHANNELS_RANGE 8 -#define MASK_PPM_FIELDS 16 -#define MASK_FAILSAFES 32 -#define MASK_OPEN_DRAIN 64 -#define MASK_MULTIMODULE 128 -#define MASK_ANTENNA 256 -#define MASK_MULTIOPTION 512 -#define MASK_R9M 1024 -#define MASK_SBUSPPM_FIELDS 2048 -#define MASK_SUBTYPES 4096 +#define MASK_PROTOCOL (1<<0) +#define MASK_CHANNELS_COUNT (1<<1) +#define MASK_RX_NUMBER (1<<2) +#define MASK_CHANNELS_RANGE (1<<3) +#define MASK_PPM_FIELDS (1<<4) +#define MASK_FAILSAFES (1<<5) +#define MASK_OPEN_DRAIN (1<<6) +#define MASK_MULTIMODULE (1<<7) +#define MASK_ANTENNA (1<<8) +#define MASK_MULTIOPTION (1<<9) +#define MASK_R9M (1<<10) +#define MASK_SBUSPPM_FIELDS (1<<11) +#define MASK_SUBTYPES (1<<12) +#define MASK_ACCESS (1<<13) quint8 ModulePanel::failsafesValueDisplayType = ModulePanel::FAILSAFE_DISPLAY_PERCENT; @@ -232,6 +233,8 @@ ModulePanel::ModulePanel(QWidget * parent, ModelData & model, ModuleData & modul ui->btnGrpValueType->setId(ui->optUs, FAILSAFE_DISPLAY_USEC); ui->btnGrpValueType->button(failsafesValueDisplayType)->setChecked(true); + ui->registrationId->setText(model.registrationId); + setupFailsafes(); disableMouseScrolling(); @@ -257,8 +260,13 @@ bool ModulePanel::moduleHasFailsafes() { return firmware->getCapability(HasFailsafe) && ( (PulsesProtocol)module.protocol == PulsesProtocol::PULSES_ACCESS_ISRM || + (PulsesProtocol)module.protocol == PulsesProtocol::PULSES_ACCST_ISRM_D16 || (PulsesProtocol)module.protocol == PulsesProtocol::PULSES_PXX_XJT_X16 || - (PulsesProtocol)module.protocol == PulsesProtocol::PULSES_PXX_R9M); + (PulsesProtocol)module.protocol == PulsesProtocol::PULSES_PXX_R9M || + (PulsesProtocol)module.protocol == PulsesProtocol::PULSES_ACCESS_R9M || + (PulsesProtocol)module.protocol == PulsesProtocol::PULSES_ACCESS_R9M_LITE || + (PulsesProtocol)module.protocol == PulsesProtocol::PULSES_ACCESS_R9M_LITE_PRO || + (PulsesProtocol)module.protocol == PulsesProtocol::PULSES_XJT_LITE_X16); } void ModulePanel::setupFailsafes() @@ -364,18 +372,30 @@ void ModulePanel::update() if (moduleIdx >= 0) { mask |= MASK_PROTOCOL; switch (protocol) { - case PULSES_ACCESS_ISRM: - mask |= MASK_CHANNELS_RANGE | MASK_CHANNELS_COUNT | MASK_RX_NUMBER; - break; case PULSES_PXX_R9M: mask |= MASK_R9M | MASK_SUBTYPES; + case PULSES_ACCESS_R9M: + case PULSES_ACCESS_R9M_LITE: + case PULSES_ACCESS_R9M_LITE_PRO: + case PULSES_ACCESS_ISRM: + case PULSES_ACCST_ISRM_D16: + case PULSES_XJT_LITE_X16: + case PULSES_XJT_LITE_D8: + case PULSES_XJT_LITE_LR12: case PULSES_PXX_XJT_X16: case PULSES_PXX_XJT_D8: case PULSES_PXX_XJT_LR12: case PULSES_PXX_DJT: mask |= MASK_CHANNELS_RANGE | MASK_CHANNELS_COUNT; - if (protocol==PULSES_PXX_XJT_X16 || protocol==PULSES_PXX_XJT_LR12 || protocol==PULSES_PXX_R9M) + // ACCST Rx ID + if (protocol==PULSES_PXX_XJT_X16 || protocol==PULSES_PXX_XJT_LR12 || + protocol==PULSES_PXX_R9M || protocol==PULSES_ACCST_ISRM_D16 || + protocol==PULSES_XJT_LITE_X16 || protocol==PULSES_XJT_LITE_LR12) mask |= MASK_RX_NUMBER; + // ACCESS + else if (protocol==PULSES_ACCESS_ISRM || protocol==PULSES_ACCESS_R9M || + protocol==PULSES_ACCESS_R9M_LITE || protocol==PULSES_ACCESS_R9M_LITE_PRO) + mask |= MASK_RX_NUMBER | MASK_ACCESS; if ((IS_HORUS(board) || board == Board::BOARD_TARANIS_XLITE) && moduleIdx == 0) mask |= MASK_ANTENNA; break; @@ -492,10 +512,17 @@ void ModulePanel::update() if (mask & MASK_SUBTYPES) { unsigned numEntries = 2; // R9M FCC/EU unsigned i = 0; - if (mask & MASK_MULTIMODULE) + switch(protocol){ + case PULSES_MULTIMODULE: numEntries = (module.multi.customProto ? 8 : pdef.numSubTypes()); - else if (firmware->getCapability(HasModuleR9MFlex)) - i = 2; + break; + case PULSES_PXX_R9M: + if (firmware->getCapability(HasModuleR9MFlex)) + i = 2; + break; + default: + break; + } numEntries += i; const QSignalBlocker blocker(ui->multiSubType); ui->multiSubType->clear(); @@ -525,6 +552,21 @@ void ModulePanel::update() ui->label_option->setText(qApp->translate("Multiprotocols", qPrintable(pdef.optionsstr))); } + if (mask & MASK_ACCESS) { + if (QString(generalSettings.registrationId) == ui->registrationId->text()) { + ui->registrationIdLabel->hide(); + ui->registrationId->hide(); + } + else { + ui->registrationIdLabel->show(); + ui->registrationId->show(); + } + } + else { + ui->registrationIdLabel->hide(); + ui->registrationId->hide(); + } + // Failsafes ui->label_failsafeMode->setVisible(mask & MASK_FAILSAFES); ui->failsafeMode->setVisible(mask & MASK_FAILSAFES); diff --git a/companion/src/modeledit/setup_module.ui b/companion/src/modeledit/setup_module.ui index 2f6426870..6d088ff1b 100644 --- a/companion/src/modeledit/setup_module.ui +++ b/companion/src/modeledit/setup_module.ui @@ -301,6 +301,19 @@ + + + + Qt::Horizontal + + + + 40 + 20 + + + + @@ -535,6 +548,19 @@ + + + + Qt::Horizontal + + + + 40 + 20 + + + + @@ -577,7 +603,7 @@ - + Multi Radio Protocol @@ -587,7 +613,7 @@ - + @@ -600,14 +626,14 @@ - + Sub Type - + @@ -620,7 +646,7 @@ - + @@ -636,7 +662,7 @@ - + @@ -674,7 +700,7 @@ - + @@ -690,7 +716,7 @@ - + @@ -728,7 +754,7 @@ - + @@ -772,6 +798,39 @@ + + + + Registration ID + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + true + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + From 4946f946fdbd3cd21a9a27f650cf82572f8a5817 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Sun, 18 Aug 2019 17:45:35 +0200 Subject: [PATCH 03/17] use proper structures for module union fields .. and quite some fixes. --- companion/src/firmwares/eepromimportexport.h | 72 +++++ companion/src/firmwares/moduledata.cpp | 1 + companion/src/firmwares/moduledata.h | 23 +- .../src/firmwares/opentx/opentxeeprom.cpp | 289 ++++++++++++------ companion/src/firmwares/opentx/opentxeeprom.h | 2 +- 5 files changed, 292 insertions(+), 95 deletions(-) diff --git a/companion/src/firmwares/eepromimportexport.h b/companion/src/firmwares/eepromimportexport.h index e5cbab7e5..be562fb41 100644 --- a/companion/src/firmwares/eepromimportexport.h +++ b/companion/src/firmwares/eepromimportexport.h @@ -585,6 +585,78 @@ class TransformedField: public DataField { DataField & field; }; +template +class UnionField: public DataField { + public: + + class UnionMember { + public: + virtual ~UnionMember() {} + virtual bool select(const selectorT& attr) const = 0; + virtual DataField* getField() = 0; + }; + + class TransformedMember: public UnionMember, public TransformedField { + public: + TransformedMember(DataField* parent, DataField& field): + TransformedField(parent, field) + { + } + virtual DataField* getField() + { + return this; + } + }; + + UnionField(DataField * parent, selectorT& selectField, const char * name="Union"): + DataField(parent, name), selectField(selectField), maxSize(0) + { + } + + ~UnionField() { + foreach(UnionMember *member, members) { + delete member; + } + } + + inline void Append(UnionMember * member) { + members.append(member); + if (member->getField()->size() > maxSize) + maxSize = member->getField()->size(); + } + + virtual void ExportBits(QBitArray & output) + { + foreach(UnionMember *member, members) { + if (member->select(selectField)) { + member->getField()->ExportBits(output); + break; + } + } + output.resize(maxSize); + } + + virtual void ImportBits(const QBitArray & input) + { + foreach(UnionMember *member, members) { + if (member->select(selectField)) { + member->getField()->ImportBits(input); + break; + } + } + } + + virtual unsigned int size() + { + return maxSize; + } + + protected: + selectorT& selectField; + QList members; + unsigned int maxSize; +}; + class ConversionTable { public: diff --git a/companion/src/firmwares/moduledata.cpp b/companion/src/firmwares/moduledata.cpp index 4b11df7af..001d0d956 100644 --- a/companion/src/firmwares/moduledata.cpp +++ b/companion/src/firmwares/moduledata.cpp @@ -105,6 +105,7 @@ QString ModuleData::protocolToString(unsigned protocol) "DIY Multiprotocol Module", "FrSky PXX R9M", "FrSky PXX R9M Lite", + "FrSky PXX R9M Lite Pro", "SBUS output at VBat", "FrSky ACCESS ISRM", "FrSky ACCST ISRM D16", "FrSky ACCESS R9M", diff --git a/companion/src/firmwares/moduledata.h b/companion/src/firmwares/moduledata.h index 2f940c504..1752afb64 100644 --- a/companion/src/firmwares/moduledata.h +++ b/companion/src/firmwares/moduledata.h @@ -48,6 +48,7 @@ enum PulsesProtocol { PULSES_MULTIMODULE, PULSES_PXX_R9M, PULSES_PXX_R9M_LITE, + PULSES_PXX_R9M_LITE_PRO, PULSES_SBUS, PULSES_ACCESS_ISRM, PULSES_ACCST_ISRM_D16, @@ -130,13 +131,18 @@ enum ModuleSubtypeR9M { MODULE_SUBTYPE_R9M_LAST=MODULE_SUBTYPE_R9M_AUPLUS }; +constexpr unsigned int PXX2_MAX_RECEIVERS_PER_MODULE = 3; +constexpr unsigned int PXX2_LEN_RX_NAME = 8; + class ModuleData { Q_DECLARE_TR_FUNCTIONS(ModuleData) public: ModuleData() { clear(); } unsigned int modelId; - int protocol; + unsigned int protocol; // type in datastructs.h + int rfProtocol; // rfProtocol in datastructs.h + unsigned int subType; bool invertedSerial; unsigned int channelsStart; @@ -144,14 +150,14 @@ class ModuleData { unsigned int failsafeMode; int failsafeChannels[CPN_MAX_CHNOUT]; - struct { + struct PPM { int delay; bool pulsePol; // false = positive bool outputType; // false = open drain, true = push pull int frameLength; } ppm; - struct { + struct Multi { unsigned int rfProtocol; bool autoBindMode; bool lowPowerMode; @@ -159,18 +165,17 @@ class ModuleData { int optionValue; } multi; - struct { - int power; // 0 10 mW, 1 100 mW, 2 500 mW, 3 1W + struct PXX { + unsigned int power; // 0 10 mW, 1 100 mW, 2 500 mW, 3 1W bool receiver_telem_off; // false = receiver telem enabled bool receiver_channel_9_16; // false = pwm out 1-8, true 9-16 bool external_antenna; // false = internal antenna, true = external antenna bool sport_out; } pxx; - struct { - // unsigned int receivers; - // char receiverName[3][8]; - char data[1 + 3 * 8]; + struct Access { + unsigned int receivers; + char receiverName[PXX2_MAX_RECEIVERS_PER_MODULE][PXX2_LEN_RX_NAME]; } access; void clear() { memset(this, 0, sizeof(ModuleData)); } diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index a23c439ea..591f67341 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -1939,14 +1939,213 @@ class SensorField: public TransformedField { int exportPpmDelay(int delay) { return (delay - 300) / 50; } int importPpmDelay(int delay) { return 300 + 50 * delay; } +class ModuleUnionField: public UnionField { + + class PPMField: public UnionField::UnionMember, public StructField { + public: + PPMField(DataField * parent, ModuleData::PPM& ppm): + StructField(parent, "PPM") + { + Append(new ConversionField< SignedField<6> >(parent, ppm.delay, exportPpmDelay, importPpmDelay)); + Append(new BoolField<1>(parent, ppm.pulsePol)); + Append(new BoolField<1>(parent, ppm.outputType)); + Append(new SignedField<8>(parent, ppm.frameLength)); + } + + virtual bool select(const unsigned int& attr) const + { + return true; // take what's left + } + + virtual DataField* getField() + { + return this; + } + }; + + class MultiField: public UnionField::TransformedMember { + public: + MultiField(DataField * parent, ModuleData& module): + UnionField::TransformedMember(parent, internalField), + internalField(this, "Multi"), + module(module), + rfProtExtra(0) + { + ModuleData::Multi& multi = module.multi; + internalField.Append(new UnsignedField<2>(this, rfProtExtra)); + internalField.Append(new SpareBitsField<3>(this)); + internalField.Append(new BoolField<1>(this, multi.autoBindMode)); + internalField.Append(new BoolField<1>(this, multi.lowPowerMode)); + internalField.Append(new BoolField<1>(this, multi.customProto)); + internalField.Append(new SignedField<8>(this, multi.optionValue)); + } + + virtual bool select(const unsigned int& attr) const + { + return attr==PULSES_MULTIMODULE; + } + + virtual void beforeExport() + { + module.rfProtocol = module.multi.rfProtocol & 0xf; + rfProtExtra = (module.multi.rfProtocol >> 4) & 0x03; + } + + virtual void afterImport() + { + module.multi.rfProtocol = + (rfProtExtra & 0x3) << 4 | (module.rfProtocol & 0xf); + } + + private: + StructField internalField; + ModuleData& module; + unsigned int rfProtExtra; + }; + + class PxxField: public UnionField::TransformedMember { + public: + PxxField(DataField * parent, ModuleData& module): + UnionField::TransformedMember(parent, internalField), + internalField(this, "Pxx"), + module(module) + { + ModuleData::PXX& pxx = module.pxx; + internalField.Append(new UnsignedField<2>(this, pxx.power)); + internalField.Append(new SpareBitsField<2>(this)); + internalField.Append(new BoolField<1>(this, pxx.receiver_telem_off)); + internalField.Append(new BoolField<1>(this, pxx.receiver_channel_9_16)); + internalField.Append(new BoolField<1>(this, pxx.external_antenna)); + internalField.Append(new BoolField<1>(this, pxx.sport_out)); + } + + bool select(const unsigned int& attr) const { + return attr==PULSES_PXX_XJT_X16 || + attr==PULSES_PXX_DJT || + attr==PULSES_PXX_R9M || + attr==PULSES_PXX_R9M_LITE; + } + + virtual void beforeExport() + { + if (module.protocol >= PULSES_PXX_XJT_X16 && module.protocol <= PULSES_PXX_XJT_LR12) { + module.subType = module.protocol - PULSES_PXX_XJT_X16; + } + } + + virtual void afterImport() + { + if (module.protocol == PULSES_PXX_XJT_X16) { + module.protocol += module.subType; + } + } + + private: + StructField internalField; + ModuleData& module; + }; + + class AccessField: public UnionField::TransformedMember { + public: + AccessField(DataField * parent, ModuleData& module): + UnionField::TransformedMember(parent, internalField), + internalField(this, "Access"), + module(module) + { + internalField.Append(new UnsignedField<3>(this, module.access.receivers)); + internalField.Append(new SpareBitsField<5>(this)); + + for (int i=0; i(this, module.access.receiverName[i])); + } + + bool select(const unsigned int& attr) const { + return attr >= PULSES_ACCESS_ISRM && attr <= PULSES_ACCESS_R9M_LITE_PRO; + } + + virtual void beforeExport() + { + if (module.protocol == PULSES_ACCST_ISRM_D16 || + module.protocol == PULSES_ACCESS_ISRM) { + module.subType = module.protocol - PULSES_ACCESS_ISRM; + } + } + + virtual void afterImport() + { + if (module.protocol == PULSES_ACCESS_ISRM) { + module.protocol += module.subType; + } + } + + private: + StructField internalField; + ModuleData& module; + }; + + public: + ModuleUnionField(DataField * parent, ModuleData & module): + UnionField(parent, module.protocol) + { + Append(new AccessField(parent, module)); + Append(new PxxField(parent, module)); + Append(new MultiField(parent, module)); + Append(new PPMField(parent, module.ppm)); + } +}; + + +class ModuleField: public TransformedField { + public: + ModuleField(DataField * parent, ModuleData & module, Board::Type board, unsigned int version): + TransformedField(parent, internalField), + internalField(this, "Module"), + module(module), + protocolsConversionTable(board) + { + internalField.Append(new ConversionField >(this, module.protocol, &protocolsConversionTable, "Protocol", DataField::tr("OpenTX doesn't accept this radio protocol"))); + internalField.Append(new SignedField<4>(this, module.rfProtocol)); + internalField.Append(new UnsignedField<8>(this, module.channelsStart)); + internalField.Append(new ConversionField >(this, module.channelsCount, -8)); + internalField.Append(new UnsignedField<4>(this, module.failsafeMode)); + internalField.Append(new UnsignedField<3>(this, module.subType)); + internalField.Append(new BoolField<1>(this, module.invertedSerial)); + if (version <= 218) { + for (int i=0; i<32; i++) { + internalField.Append(new SignedField<16>(this, module.failsafeChannels[i])); + } + } + + internalField.Append(new ModuleUnionField(parent, module)); + } + + virtual void beforeExport() + { + if (module.protocol >= PULSES_LP45 && module.protocol <= PULSES_DSMX) { + module.rfProtocol = module.protocol - PULSES_LP45; + } + } + + virtual void afterImport() + { + if (module.protocol == PULSES_LP45) { + module.protocol += module.rfProtocol; + } + } + + private: + StructField internalField; + ModuleData& module; + ProtocolsConversionTable protocolsConversionTable; +}; + OpenTxModelData::OpenTxModelData(ModelData & modelData, Board::Type board, unsigned int version, unsigned int variant): TransformedField(nullptr, internalField), internalField(this, "ModelData"), modelData(modelData), board(board), version(version), - variant(variant), - protocolsConversionTable(board) + variant(variant) { sprintf(name, "Model %s", modelData.name); @@ -2094,26 +2293,8 @@ OpenTxModelData::OpenTxModelData(ModelData & modelData, Board::Type board, unsig int modulesCount = (version <= 218 ? 3 : 2); for (int module=0; module >(this, modelData.moduleData[module].protocol, &protocolsConversionTable, "Protocol", DataField::tr("OpenTX doesn't accept this radio protocol"))); - internalField.Append(new SignedField<4>(this, subprotocols[module])); - internalField.Append(new UnsignedField<8>(this, modelData.moduleData[module].channelsStart)); - internalField.Append(new ConversionField >(this, modelData.moduleData[module].channelsCount, -8)); - internalField.Append(new UnsignedField<4>(this, modelData.moduleData[module].failsafeMode)); - internalField.Append(new UnsignedField<3>(this, modelData.moduleData[module].subType)); - internalField.Append(new BoolField<1>(this, modelData.moduleData[module].invertedSerial)); - if (version <= 218) { - for (int i=0; i<32; i++) { - internalField.Append(new SignedField<16>(this, modelData.moduleData[module].failsafeChannels[i])); - } - } - internalField.Append(new ConversionField< SignedField<6> >(this, modelData.moduleData[module].ppm.delay, exportPpmDelay, importPpmDelay)); - internalField.Append(new BoolField<1>(this, modelData.moduleData[module].ppm.pulsePol)); - internalField.Append(new BoolField<1>(this, modelData.moduleData[module].ppm.outputType)); - internalField.Append(new SignedField<8>(this, modelData.moduleData[module].ppm.frameLength)); - if (version >= 219) { - // TODO ACCESS - internalField.Append(new CharField<1 + 3 * 8 - 2>(this, modelData.moduleData[module].access.data)); - } + + internalField.Append(new ModuleField(this, modelData.moduleData[module], board, version)); } if (version >= 219) { @@ -2221,38 +2402,6 @@ void OpenTxModelData::beforeExport() // qDebug() << QString("before export model") << modelData.name; for (int module=0; module<2; module++) { - if ((modelData.moduleData[module].protocol >= PULSES_PXX_XJT_X16 && modelData.moduleData[module].protocol <= PULSES_PXX_XJT_LR12) || - modelData.moduleData[module].protocol == PULSES_PXX_R9M) { - - if (modelData.moduleData[module].protocol != PULSES_PXX_R9M) { - subprotocols[module] = modelData.moduleData[module].protocol - PULSES_PXX_XJT_X16; - } - int pxxByte = (modelData.moduleData[module].pxx.power & 0x03) - | modelData.moduleData[module].pxx.receiver_telem_off << 4 - | modelData.moduleData[module].pxx.receiver_channel_9_16 << 5; - modelData.moduleData[module].ppm.delay = 300 + 50 * pxxByte; - modelData.moduleData[module].ppm.pulsePol = modelData.moduleData[module].pxx.external_antenna; - modelData.moduleData[module].ppm.outputType = modelData.moduleData[module].pxx.sport_out; - } - else if (modelData.moduleData[module].protocol >= PULSES_LP45 && modelData.moduleData[module].protocol <= PULSES_DSMX) { - subprotocols[module] = modelData.moduleData[module].protocol - PULSES_LP45; - } - else if (modelData.moduleData[module].protocol == PULSES_MULTIMODULE) { - // copy multi settings to ppm settings to get them written to the eeprom - // (reverse the int => ms logic of the ppm delay) since only ppm is written - subprotocols[module] = modelData.moduleData[module].multi.rfProtocol & (0x1f); - int multiByte = ((modelData.moduleData[module].multi.rfProtocol >> 4) & 0x03) | (modelData.moduleData[module].multi.customProto << 7); - modelData.moduleData[module].ppm.delay = 300 + 50 * multiByte; - modelData.moduleData[module].ppm.frameLength = modelData.moduleData[module].multi.optionValue; - modelData.moduleData[module].ppm.outputType = modelData.moduleData[module].multi.lowPowerMode; - modelData.moduleData[module].ppm.pulsePol = modelData.moduleData[module].multi.autoBindMode; - } - else if (modelData.moduleData[module].protocol == PULSES_ACCST_ISRM_D16 || modelData.moduleData[module].protocol == PULSES_ACCESS_ISRM) { - subprotocols[module] = modelData.moduleData[module].protocol - PULSES_ACCESS_ISRM; - } - else { - subprotocols[module] = (module == 0 ? -1 : 0); - } } if (IS_HORUS(board)) { @@ -2271,41 +2420,11 @@ void OpenTxModelData::afterImport() { qCDebug(eepromImport) << QString("OpenTxModelData::afterImport()") << modelData.name; + // ??? what's this ??? if (IS_HORUS(board)) { modelData.moduleData[0].protocol = PULSES_PXX_XJT_X16; } - for (int module=0; module<2; module++) { - if (modelData.moduleData[module].protocol == PULSES_PXX_XJT_X16 - || modelData.moduleData[module].protocol == PULSES_LP45 - || modelData.moduleData[module].protocol == PULSES_ACCESS_ISRM) { - if (subprotocols[module] >= 0) - modelData.moduleData[module].protocol += subprotocols[module]; - else - modelData.moduleData[module].protocol = PULSES_OFF; - } - else if (modelData.moduleData[module].protocol == PULSES_MULTIMODULE) { - // Copy data from ppm struct to multi struct - auto multiByte = (unsigned int)((modelData.moduleData[module].ppm.delay - 300) / 50); - modelData.moduleData[module].multi.rfProtocol = (subprotocols[module] & 0x0f) | ((multiByte & 0x3) << 4); - modelData.moduleData[module].multi.customProto = (multiByte & 0x80) == 0x80; - modelData.moduleData[module].multi.optionValue = modelData.moduleData[module].ppm.frameLength; - modelData.moduleData[module].multi.lowPowerMode = modelData.moduleData[module].ppm.outputType; - modelData.moduleData[module].multi.autoBindMode = modelData.moduleData[module].ppm.pulsePol; - } - - if ((modelData.moduleData[module].protocol >= PULSES_PXX_XJT_X16 && modelData.moduleData[module].protocol <= PULSES_PXX_XJT_LR12) || - modelData.moduleData[module].protocol == PULSES_PXX_R9M) { - // Do the same for pxx - auto pxxByte = (unsigned int)((modelData.moduleData[module].ppm.delay - 300) / 50); - modelData.moduleData[module].pxx.power = pxxByte & 0x03; - modelData.moduleData[module].pxx.receiver_telem_off = static_cast(pxxByte & (1 << 4)); - modelData.moduleData[module].pxx.receiver_channel_9_16 = static_cast(pxxByte & (1 << 5)); - modelData.moduleData[module].pxx.sport_out = modelData.moduleData[module].ppm.outputType; - modelData.moduleData[module].pxx.external_antenna = modelData.moduleData[module].ppm.pulsePol; - } - } - if (IS_HORUS(board)) { uint32_t newSwitchWarningStates = 0; for (int i = 0; i < MAX_SWITCHES(board, version); i++) { diff --git a/companion/src/firmwares/opentx/opentxeeprom.h b/companion/src/firmwares/opentx/opentxeeprom.h index ff11a0dc3..9785c5f7b 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.h +++ b/companion/src/firmwares/opentx/opentxeeprom.h @@ -97,6 +97,7 @@ class ProtocolsConversionTable: public ConversionTable addConversion(PULSES_ACCESS_R9M, val++); addConversion(PULSES_PXX_R9M_LITE, val++); addConversion(PULSES_ACCESS_R9M_LITE, val++); + addConversion(PULSES_PXX_R9M_LITE_PRO, val++); addConversion(PULSES_ACCESS_R9M_LITE_PRO, val++); addConversion(PULSES_SBUS, val++); @@ -146,7 +147,6 @@ class OpenTxModelData: public TransformedField { unsigned int variant; char name[256]; int subprotocols[CPN_MAX_MODULES+1/*trainer*/]; - ProtocolsConversionTable protocolsConversionTable; ChannelsConversionTable channelsConversionTable; QStringList _errors; }; From ea929e4c19e614f1c2c0d7c4e98d442367b13e61 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Sun, 18 Aug 2019 18:35:19 +0200 Subject: [PATCH 04/17] fix typed comparison --- companion/src/firmwares/moduledata.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/companion/src/firmwares/moduledata.h b/companion/src/firmwares/moduledata.h index 1752afb64..12b1bde2b 100644 --- a/companion/src/firmwares/moduledata.h +++ b/companion/src/firmwares/moduledata.h @@ -131,8 +131,8 @@ enum ModuleSubtypeR9M { MODULE_SUBTYPE_R9M_LAST=MODULE_SUBTYPE_R9M_AUPLUS }; -constexpr unsigned int PXX2_MAX_RECEIVERS_PER_MODULE = 3; -constexpr unsigned int PXX2_LEN_RX_NAME = 8; +constexpr int PXX2_MAX_RECEIVERS_PER_MODULE = 3; +constexpr int PXX2_LEN_RX_NAME = 8; class ModuleData { Q_DECLARE_TR_FUNCTIONS(ModuleData) From c8e7522b3810e34583cab1bce1394b017f367400 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Sun, 18 Aug 2019 18:53:56 +0200 Subject: [PATCH 05/17] added receivers on module frame --- companion/src/modeledit/setup.cpp | 30 +++-- companion/src/modeledit/setup_module.ui | 147 ++++++++++++++++++++++-- 2 files changed, 156 insertions(+), 21 deletions(-) diff --git a/companion/src/modeledit/setup.cpp b/companion/src/modeledit/setup.cpp index b833eff7b..376a6f465 100644 --- a/companion/src/modeledit/setup.cpp +++ b/companion/src/modeledit/setup.cpp @@ -553,20 +553,26 @@ void ModulePanel::update() } if (mask & MASK_ACCESS) { - if (QString(generalSettings.registrationId) == ui->registrationId->text()) { - ui->registrationIdLabel->hide(); - ui->registrationId->hide(); - } - else { - ui->registrationIdLabel->show(); - ui->registrationId->show(); - } - } - else { - ui->registrationIdLabel->hide(); - ui->registrationId->hide(); + ui->rx1->setText(module.access.receiverName[0]); + ui->rx2->setText(module.access.receiverName[1]); + ui->rx3->setText(module.access.receiverName[2]); } + ui->registrationIdLabel->setVisible(mask & MASK_ACCESS); + ui->registrationId->setVisible(mask & MASK_ACCESS); + + ui->rx1Label->setVisible(mask & MASK_ACCESS); + ui->clearRx1->setVisible(mask & MASK_ACCESS); + ui->rx1->setVisible(mask & MASK_ACCESS); + + ui->rx2Label->setVisible(mask & MASK_ACCESS); + ui->clearRx2->setVisible(mask & MASK_ACCESS); + ui->rx2->setVisible(mask & MASK_ACCESS); + + ui->rx3Label->setVisible(mask & MASK_ACCESS); + ui->clearRx3->setVisible(mask & MASK_ACCESS); + ui->rx3->setVisible(mask & MASK_ACCESS); + // Failsafes ui->label_failsafeMode->setVisible(mask & MASK_FAILSAFES); ui->failsafeMode->setVisible(mask & MASK_FAILSAFES); diff --git a/companion/src/modeledit/setup_module.ui b/companion/src/modeledit/setup_module.ui index 6d088ff1b..ddf5843f6 100644 --- a/companion/src/modeledit/setup_module.ui +++ b/companion/src/modeledit/setup_module.ui @@ -7,7 +7,7 @@ 0 0 1042 - 297 + 375 @@ -239,25 +239,136 @@ - - + + + + Receiver 1 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + -1 + + + 0 + + + 0 + - + - Bind on startup + + + + true + + + false - + + + + 0 + 0 + + + + + 10 + + - Low Power + X + + + false - + + + + Receiver 2 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + true + + + + + + + + 10 + + + + X + + + false + + + + + + + + + Receiver 3 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + true + + + + + + + + 10 + + + + X + + + false + + + + + + @@ -301,7 +412,25 @@ - + + + + + + Bind on startup + + + + + + + Low Power + + + + + + Qt::Horizontal From 910964894390ad66b297802a55a1ca5b83a2d8bd Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Sun, 18 Aug 2019 19:36:49 +0200 Subject: [PATCH 06/17] fixed more types --- companion/src/modeledit/setup.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/companion/src/modeledit/setup.cpp b/companion/src/modeledit/setup.cpp index 376a6f465..2cfd66544 100644 --- a/companion/src/modeledit/setup.cpp +++ b/companion/src/modeledit/setup.cpp @@ -623,7 +623,7 @@ void ModulePanel::on_trainerMode_currentIndexChanged(int index) void ModulePanel::onProtocolChanged(int index) { - if (!lock && module.protocol != ui->protocol->itemData(index).toInt()) { + if (!lock && module.protocol != ui->protocol->itemData(index).toUInt()) { module.protocol = ui->protocol->itemData(index).toInt(); update(); emit modified(); @@ -648,7 +648,7 @@ void ModulePanel::on_antennaMode_currentIndexChanged(int index) void ModulePanel::on_r9mPower_currentIndexChanged(int index) { - if (!lock && module.pxx.power != index) { + if (!lock && module.pxx.power != (unsigned int)index) { module.pxx.power = index; emit modified(); } From 2257272e5c4f883874d8143778e57022bb82d4c3 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Sun, 18 Aug 2019 20:24:31 +0200 Subject: [PATCH 07/17] another type fix... --- companion/src/modeledit/setup.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/companion/src/modeledit/setup.cpp b/companion/src/modeledit/setup.cpp index 2cfd66544..a7733aaaa 100644 --- a/companion/src/modeledit/setup.cpp +++ b/companion/src/modeledit/setup.cpp @@ -215,7 +215,7 @@ ModulePanel::ModulePanel(QWidget * parent, ModelData & model, ModuleData & modul } // The protocols available on this board - for (int i=0; iisAvailable((PulsesProtocol) i, moduleIdx)) { if (IS_TARANIS_XLITE(firmware->getBoard()) && i == PULSES_PXX_R9M) //TODO remove when mini are handled as a different module type ui->protocol->addItem("FrSky R9M Mini", (QVariant) i); From c0dbc2cbb70e2df8e10b198289cca4eeca85342c Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Sun, 18 Aug 2019 20:25:19 +0200 Subject: [PATCH 08/17] removable receiver (access) --- companion/src/modeledit/setup.cpp | 47 +++++++++++++++++++++++++------ companion/src/modeledit/setup.h | 1 + 2 files changed, 39 insertions(+), 9 deletions(-) diff --git a/companion/src/modeledit/setup.cpp b/companion/src/modeledit/setup.cpp index a7733aaaa..db47fcc33 100644 --- a/companion/src/modeledit/setup.cpp +++ b/companion/src/modeledit/setup.cpp @@ -247,6 +247,10 @@ ModulePanel::ModulePanel(QWidget * parent, ModelData & model, ModuleData & modul connect(this, &ModulePanel::channelsRangeChanged, this, &ModulePanel::setupFailsafes); connect(ui->btnGrpValueType, static_cast(&QButtonGroup::buttonClicked), this, &ModulePanel::onFailsafesDisplayValueTypeChanged); + connect(ui->clearRx1, SIGNAL(clicked()), this, SLOT(onClearAccessRxClicked())); + connect(ui->clearRx2, SIGNAL(clicked()), this, SLOT(onClearAccessRxClicked())); + connect(ui->clearRx3, SIGNAL(clicked()), this, SLOT(onClearAccessRxClicked())); + lock = false; } @@ -561,17 +565,17 @@ void ModulePanel::update() ui->registrationIdLabel->setVisible(mask & MASK_ACCESS); ui->registrationId->setVisible(mask & MASK_ACCESS); - ui->rx1Label->setVisible(mask & MASK_ACCESS); - ui->clearRx1->setVisible(mask & MASK_ACCESS); - ui->rx1->setVisible(mask & MASK_ACCESS); + ui->rx1Label->setVisible((mask & MASK_ACCESS) && (module.access.receivers & (1<<0))); + ui->clearRx1->setVisible((mask & MASK_ACCESS) && (module.access.receivers & (1<<0))); + ui->rx1->setVisible((mask & MASK_ACCESS) && (module.access.receivers & (1<<0))); - ui->rx2Label->setVisible(mask & MASK_ACCESS); - ui->clearRx2->setVisible(mask & MASK_ACCESS); - ui->rx2->setVisible(mask & MASK_ACCESS); + ui->rx2Label->setVisible((mask & MASK_ACCESS) && (module.access.receivers & (1<<1))); + ui->clearRx2->setVisible((mask & MASK_ACCESS) && (module.access.receivers & (1<<1))); + ui->rx2->setVisible((mask & MASK_ACCESS) && (module.access.receivers & (1<<1))); - ui->rx3Label->setVisible(mask & MASK_ACCESS); - ui->clearRx3->setVisible(mask & MASK_ACCESS); - ui->rx3->setVisible(mask & MASK_ACCESS); + ui->rx3Label->setVisible((mask & MASK_ACCESS) && (module.access.receivers & (1<<2))); + ui->clearRx3->setVisible((mask & MASK_ACCESS) && (module.access.receivers & (1<<2))); + ui->rx3->setVisible((mask & MASK_ACCESS) && (module.access.receivers & (1<<2))); // Failsafes ui->label_failsafeMode->setVisible(mask & MASK_FAILSAFES); @@ -875,6 +879,30 @@ void ModulePanel::updateFailsafe(int channel) setChannelFailsafeValue(channel, failsafeValue, (FAILSAFE_DISPLAY_PERCENT | FAILSAFE_DISPLAY_USEC)); } +void ModulePanel::onClearAccessRxClicked() +{ + QPushButton *button = qobject_cast(sender()); + + if (button == ui->clearRx1) { + module.access.receivers &= ~(1<<0); + ui->rx1->clear(); + update(); + emit modified(); + } + else if (button == ui->clearRx2) { + module.access.receivers &= ~(1<<1); + ui->rx2->clear(); + update(); + emit modified(); + } + else if (button == ui->clearRx3) { + module.access.receivers &= ~(1<<2); + ui->rx3->clear(); + update(); + emit modified(); + } +} + /******************************************************************************/ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware): @@ -1421,3 +1449,4 @@ void SetupPanel::on_editText_clicked() g->exec(); } } + diff --git a/companion/src/modeledit/setup.h b/companion/src/modeledit/setup.h index f9c815ef2..fcfc495a4 100644 --- a/companion/src/modeledit/setup.h +++ b/companion/src/modeledit/setup.h @@ -95,6 +95,7 @@ class ModulePanel : public ModelPanel void onFailsafesDisplayValueTypeChanged(int type); void updateFailsafe(int channel); void on_optionValue_editingFinished(); + void onClearAccessRxClicked(); private: enum FailsafeValueDisplayTypes { FAILSAFE_DISPLAY_PERCENT = 1, FAILSAFE_DISPLAY_USEC = 2 }; From 645fb219f874cc3e5199fbd890e097fbfb24f096 Mon Sep 17 00:00:00 2001 From: Neil Horne Date: Thu, 23 May 2019 00:03:33 +1000 Subject: [PATCH 09/17] Fix SF changing adjust GV# not resetting mode (#6343) --- companion/src/modeledit/customfunctions.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/companion/src/modeledit/customfunctions.cpp b/companion/src/modeledit/customfunctions.cpp index f4f4bb6a0..552b31038 100644 --- a/companion/src/modeledit/customfunctions.cpp +++ b/companion/src/modeledit/customfunctions.cpp @@ -384,7 +384,6 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified) cfn.swtch = RawSwitch(fswtchSwtch[i]->currentData().toInt()); cfn.func = func; cfn.enabled = fswtchEnable[i]->isChecked(); - cfn.adjustMode = (AssignFunc)fswtchGVmode[i]->currentIndex(); } if (!cfn.isEmpty()) { @@ -418,6 +417,7 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified) int gvidx = func - FuncAdjustGV1; if (modified) cfn.adjustMode = fswtchGVmode[i]->currentIndex(); + fswtchGVmode[i]->setCurrentIndex(cfn.adjustMode); widgetsMask |= CUSTOM_FUNCTION_GV_MODE | CUSTOM_FUNCTION_ENABLE; if (cfn.adjustMode==FUNC_ADJUST_GVAR_CONSTANT || cfn.adjustMode==FUNC_ADJUST_GVAR_INCDEC) { if (modified) From 5fa820f98d37daea631e001897b978cd6e3d9b08 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Tue, 20 Aug 2019 00:50:28 +0200 Subject: [PATCH 10/17] added receiver display to sensors --- companion/src/firmwares/moduledata.cpp | 14 ++++++ companion/src/firmwares/moduledata.h | 3 +- .../src/firmwares/opentx/opentxeeprom.cpp | 22 ++++++-- companion/src/firmwares/sensordata.h | 2 + companion/src/modeledit/telemetry.cpp | 26 ++++++++++ companion/src/modeledit/telemetry_sensor.ui | 50 ++++++++++++++++++- 6 files changed, 112 insertions(+), 5 deletions(-) diff --git a/companion/src/firmwares/moduledata.cpp b/companion/src/firmwares/moduledata.cpp index 001d0d956..d2cc4fd1b 100644 --- a/companion/src/firmwares/moduledata.cpp +++ b/companion/src/firmwares/moduledata.cpp @@ -30,6 +30,20 @@ void ModuleData::convert(RadioDataConversionState & cstate) } } +bool ModuleData::isPxx2Module() const +{ + switch(protocol){ + case PULSES_ACCESS_ISRM: + case PULSES_ACCESS_R9M: + case PULSES_ACCESS_R9M_LITE: + case PULSES_ACCESS_R9M_LITE_PRO: + case PULSES_XJT_LITE_X16: + return true; + default: + return false; + } +} + QString ModuleData::rfProtocolToString() const { switch (protocol) { diff --git a/companion/src/firmwares/moduledata.h b/companion/src/firmwares/moduledata.h index 12b1bde2b..5b3f908a6 100644 --- a/companion/src/firmwares/moduledata.h +++ b/companion/src/firmwares/moduledata.h @@ -175,11 +175,12 @@ class ModuleData { struct Access { unsigned int receivers; - char receiverName[PXX2_MAX_RECEIVERS_PER_MODULE][PXX2_LEN_RX_NAME]; + char receiverName[PXX2_MAX_RECEIVERS_PER_MODULE][PXX2_LEN_RX_NAME+1]; } access; void clear() { memset(this, 0, sizeof(ModuleData)); } void convert(RadioDataConversionState & cstate); + bool isPxx2Module() const; QString polarityToString() const { return ppm.pulsePol ? tr("Positive") : tr("Negative"); } QString rfProtocolToString() const; QString subTypeToString(int type = -1) const; diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index 591f67341..b162a8984 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -1868,7 +1868,8 @@ class SensorField: public TransformedField { if (sensor.type == SensorData::TELEM_TYPE_CUSTOM) { _id = sensor.id; _subid = sensor.subid; - _instance = sensor.instance; + // keep highest 3 bits from instance (rxIdx & moduleIdx are read-only) + _instance = (sensor.instance & 0x1F) | (_instance & 0xE0); _ratio = sensor.ratio; _offset = sensor.offset; } @@ -1891,7 +1892,9 @@ class SensorField: public TransformedField { if (sensor.type == SensorData::TELEM_TYPE_CUSTOM) { sensor.id = _id; sensor.subid = _subid; - sensor.instance = _instance; + sensor.instance = _instance & 0x1F; // 5 bits instance + sensor.rxIdx = (_instance >> 5) & 0x03; // 2 bits Rx idx + sensor.moduleIdx = (_instance >> 7) & 0x1; // 1 bit module idx sensor.ratio = _ratio; sensor.offset = _offset; } @@ -2056,7 +2059,7 @@ class ModuleUnionField: public UnionField { internalField.Append(new SpareBitsField<5>(this)); for (int i=0; i(this, module.access.receiverName[i])); + internalField.Append(new CharField<8>(this, receiverName[i])); } bool select(const unsigned int& attr) const { @@ -2076,11 +2079,24 @@ class ModuleUnionField: public UnionField { if (module.protocol == PULSES_ACCESS_ISRM) { module.protocol += module.subType; } + for (int i=0; iid->hide(); ui->instanceLabel->hide(); ui->instance->hide(); + ui->rxLabel->hide(); + ui->moduleLabel->hide(); + ui->rxOrMod->hide(); ui->formula->show(); ui->formula->setCurrentIndex(sensor.formula); isConfigurable = (sensor.formula < SensorData::TELEM_FORMULA_CELL); @@ -676,6 +679,29 @@ void TelemetrySensorPanel::update() ui->id->show(); ui->instanceLabel->show(); ui->instance->show(); + + const ModuleData& module = model->moduleData[sensor.moduleIdx]; + if (module.isPxx2Module()) { + ui->rxLabel->show(); + ui->moduleLabel->hide(); + if (module.access.receivers & (1 << sensor.rxIdx)) { + ui->rxOrMod->setText(module.access.receiverName[sensor.rxIdx]); + } + else { + // receiver does not seem to be active + ui->rxOrMod->clear(); + } + } + else { + ui->rxLabel->hide(); + ui->moduleLabel->show(); + if (sensor.moduleIdx) + ui->rxOrMod->setText(tr("Internal Module")); + else + ui->rxOrMod->setText(tr("External Module")); + } + ui->rxOrMod->show(); + ui->formula->hide(); isConfigurable = sensor.unit < SensorData::UNIT_FIRST_VIRTUAL; ratioFieldsDisplayed = (sensor.unit < SensorData::UNIT_FIRST_VIRTUAL); diff --git a/companion/src/modeledit/telemetry_sensor.ui b/companion/src/modeledit/telemetry_sensor.ui index 9966bc8ee..f6007f6d6 100644 --- a/companion/src/modeledit/telemetry_sensor.ui +++ b/companion/src/modeledit/telemetry_sensor.ui @@ -13,7 +13,7 @@ Form - + 0 @@ -28,6 +28,12 @@ 0 + + + 50 + 16777215 + + 4 @@ -114,6 +120,48 @@ + + + + Rx + + + + + + + Mod. + + + + + + + + 0 + 0 + + + + + 60 + 16777215 + + + + false + + + Qt::RightToLeft + + + 10 + + + true + + + From 9915742f8eeecb7da9ed38492546e1e8412b560b Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Tue, 20 Aug 2019 10:45:49 +0200 Subject: [PATCH 11/17] avoid warnings --- radio/src/gui/common/stdlcd/radio_version.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/radio/src/gui/common/stdlcd/radio_version.cpp b/radio/src/gui/common/stdlcd/radio_version.cpp index 2d7ffe4ce..5851fadf5 100644 --- a/radio/src/gui/common/stdlcd/radio_version.cpp +++ b/radio/src/gui/common/stdlcd/radio_version.cpp @@ -33,7 +33,9 @@ #define MENU_BODY_TOP (FH + 1) #define MENU_BODY_BOTTOM (LCD_H) +#if defined(PXX2) constexpr uint8_t COLUMN2_X = 10 * FW; +#endif void menuRadioFirmwareOptions(event_t event) From 69add44f0c0161ee63612ecd94f3397740b20a5f Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Tue, 20 Aug 2019 10:46:47 +0200 Subject: [PATCH 12/17] fixed Board::Switches for X9D+ 2019 --- companion/src/firmwares/boards.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/companion/src/firmwares/boards.cpp b/companion/src/firmwares/boards.cpp index f753b354e..44e3f0221 100644 --- a/companion/src/firmwares/boards.cpp +++ b/companion/src/firmwares/boards.cpp @@ -333,14 +333,12 @@ const int Boards::getCapability(Board::Type board, Board::Capability capability) return 8; else if (IS_JUMPER_T12(board)) return 6; - else if (IS_TARANIS_XLITES(board)) - return 6; else if (IS_TARANIS_XLITE(board)) return 6; - else if (IS_TARANIS(board)) - return 8; else if (board == Board::BOARD_TARANIS_X9DP_2019) return 9; + else if (IS_TARANIS(board)) + return 8; else if (IS_HORUS(board)) return 10; else From a7cb78b8015fff30a879f894e8224192bdba1930 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Tue, 20 Aug 2019 10:47:17 +0200 Subject: [PATCH 13/17] better use the same type as in datastruct.h --- radio/src/gui/480x272/radio_hardware.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/radio/src/gui/480x272/radio_hardware.cpp b/radio/src/gui/480x272/radio_hardware.cpp index dc949ea6b..7a0f5cba5 100644 --- a/radio/src/gui/480x272/radio_hardware.cpp +++ b/radio/src/gui/480x272/radio_hardware.cpp @@ -177,7 +177,7 @@ bool menuRadioHardware(event_t event) lcdDrawMMM(HW_SETTINGS_COLUMN, y, 0); config = editChoice(HW_SETTINGS_COLUMN+50, y, STR_SWTYPES, config, SWITCH_NONE, SWITCH_TYPE_MAX(index), menuHorizontalPosition == 1 ? attr : 0, event); if (attr && checkIncDec_Ret) { - g_eeGeneral.switchConfig = bfSet(g_eeGeneral.switchConfig, config, 2*index, 2); + g_eeGeneral.switchConfig = bfSet(g_eeGeneral.switchConfig, config, 2*index, 2); } break; } From a7f515237079426a9df46bbb4d5b837cafeb0b0b Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Tue, 20 Aug 2019 10:49:07 +0200 Subject: [PATCH 14/17] fixing bit offsets round 1 --- companion/src/firmwares/opentx/opentxeeprom.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index b162a8984..e7be89610 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -2612,13 +2612,17 @@ OpenTxGeneralData::OpenTxGeneralData(GeneralSettings & generalData, Board::Type internalField.Append(new ArmCustomFunctionField(this, generalData.customFn[i], board, version, variant)); } } - + if (IS_STM32(board)) { if (version >= 218) { internalField.Append(new UnsignedField<4>(this, generalData.hw_uartMode)); - // not on Horus... - for (uint8_t i=0; i<4; i++) { - internalField.Append(new UnsignedField<1>(this, generalData.sliderConfig[i])); + if (!IS_HORUS(board)) { + for (uint8_t i=0; i<4; i++) { + internalField.Append(new UnsignedField<1>(this, generalData.sliderConfig[i])); + } + } + else { + internalField.Append(new SpareBitsField<4>(this)); } } else { @@ -2676,6 +2680,8 @@ OpenTxGeneralData::OpenTxGeneralData(GeneralSettings & generalData, Board::Type if (IS_TARANIS_X9E(board)) internalField.Append(new SpareBitsField<64>(this)); // switchUnlockStates + else if (IS_TARANIS_X9D(board)) + internalField.Append(new SpareBitsField<32>(this)); // switchUnlockStates else if (IS_TARANIS(board)) internalField.Append(new SpareBitsField<16>(this)); // switchUnlockStates @@ -2730,7 +2736,7 @@ OpenTxGeneralData::OpenTxGeneralData(GeneralSettings & generalData, Board::Type internalField.Append(new UnsignedField<7>(this, generalData.backlightOffBright)); internalField.Append(new ZCharField<10>(this, generalData.bluetoothName, "Bluetooth name")); } - else if (IS_TARANIS_X9E(board) || (version >= 219 && (IS_TARANIS_X7(board) || IS_TARANIS_XLITE(board) || IS_TARANIS_XLITES(board)))) { + else if (IS_TARANIS_X9E(board) || (version >= 219 && (IS_TARANIS_X7(board) || IS_TARANIS_X9D(board) || IS_TARANIS_XLITE(board)))) { internalField.Append(new SpareBitsField<8>(this)); internalField.Append(new ZCharField<10>(this, generalData.bluetoothName, "Bluetooth name")); } From b3c6301e5a2fa49fc4f4410048aa41bb3824a262 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Tue, 20 Aug 2019 10:49:25 +0200 Subject: [PATCH 15/17] shorter string --- companion/src/modeledit/telemetry.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/companion/src/modeledit/telemetry.cpp b/companion/src/modeledit/telemetry.cpp index 36f37a0b4..78a4c90a4 100644 --- a/companion/src/modeledit/telemetry.cpp +++ b/companion/src/modeledit/telemetry.cpp @@ -696,9 +696,9 @@ void TelemetrySensorPanel::update() ui->rxLabel->hide(); ui->moduleLabel->show(); if (sensor.moduleIdx) - ui->rxOrMod->setText(tr("Internal Module")); + ui->rxOrMod->setText(tr("Internal")); else - ui->rxOrMod->setText(tr("External Module")); + ui->rxOrMod->setText(tr("External")); } ui->rxOrMod->show(); From 4c12aac16c1f3e600800016253b8fee1156506ca Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Thu, 22 Aug 2019 06:21:31 +0200 Subject: [PATCH 16/17] display receiver or module name for each sensor (if available) --- companion/src/firmwares/sensordata.cpp | 23 ++++++++++++++ companion/src/firmwares/sensordata.h | 3 ++ companion/src/modeledit/telemetry.cpp | 43 ++++++++++++-------------- 3 files changed, 45 insertions(+), 24 deletions(-) diff --git a/companion/src/firmwares/sensordata.cpp b/companion/src/firmwares/sensordata.cpp index 56c2653fe..a88f3239a 100644 --- a/companion/src/firmwares/sensordata.cpp +++ b/companion/src/firmwares/sensordata.cpp @@ -21,6 +21,7 @@ #include "sensordata.h" #include "radiodata.h" +#include "modeldata.h" void SensorData::updateUnit() { @@ -90,3 +91,25 @@ QString SensorData::nameToString(int index) const { return RadioData::getElementName(tr("TELE"), index + 1, label); } + +QString SensorData::getRxOrModName(const ModelData* model) const +{ + if ((type != TELEM_TYPE_CUSTOM) || (!id && !instance)) + return QString(); + + const ModuleData& module = model->moduleData[moduleIdx]; + + if (module.isPxx2Module()) { + if (module.access.receivers & (1 << rxIdx)) { + return QString(module.access.receiverName[rxIdx]); + } + + // receiver does not seem to be active + return QString(); + } + + if (moduleIdx) + return tr("Internal"); + + return tr("External"); +} diff --git a/companion/src/firmwares/sensordata.h b/companion/src/firmwares/sensordata.h index d289e998d..8e95aa7f6 100644 --- a/companion/src/firmwares/sensordata.h +++ b/companion/src/firmwares/sensordata.h @@ -25,6 +25,8 @@ constexpr int CPN_MAX_SENSORS = 60; +class ModelData; + class SensorData { Q_DECLARE_TR_FUNCTIONS(SensorData) @@ -146,6 +148,7 @@ class SensorData { void updateUnit(); QString unitString() const; QString nameToString(int index) const; + QString getRxOrModName(const ModelData* model) const; void clear() { memset(this, 0, sizeof(SensorData)); } }; diff --git a/companion/src/modeledit/telemetry.cpp b/companion/src/modeledit/telemetry.cpp index 78a4c90a4..5d6a23278 100644 --- a/companion/src/modeledit/telemetry.cpp +++ b/companion/src/modeledit/telemetry.cpp @@ -680,26 +680,11 @@ void TelemetrySensorPanel::update() ui->instanceLabel->show(); ui->instance->show(); - const ModuleData& module = model->moduleData[sensor.moduleIdx]; - if (module.isPxx2Module()) { - ui->rxLabel->show(); - ui->moduleLabel->hide(); - if (module.access.receivers & (1 << sensor.rxIdx)) { - ui->rxOrMod->setText(module.access.receiverName[sensor.rxIdx]); - } - else { - // receiver does not seem to be active - ui->rxOrMod->clear(); - } - } - else { - ui->rxLabel->hide(); - ui->moduleLabel->show(); - if (sensor.moduleIdx) - ui->rxOrMod->setText(tr("Internal")); - else - ui->rxOrMod->setText(tr("External")); - } + bool is_pxx2 = model->moduleData[sensor.moduleIdx].isPxx2Module(); + ui->rxLabel->setVisible(is_pxx2); + ui->moduleLabel->setVisible(!is_pxx2); + + ui->rxOrMod->setText(sensor.getRxOrModName(model)); ui->rxOrMod->show(); ui->formula->hide(); @@ -767,14 +752,24 @@ void populateTelemetrySourcesComboBox(AutoComboBox * cb, const ModelData * model cb->clear(); if (negative) { for (int i=-CPN_MAX_SENSORS; i<0; ++i) { - if (model->sensorData[-i-1].isAvailable()) - cb->addItem(QString("-%1").arg(model->sensorData[-i-1].label), i); + const SensorData& sensor = model->sensorData[-i-1]; + if (sensor.isAvailable()) { + if (sensor.type == SensorData::TELEM_TYPE_CUSTOM) + cb->addItem(QString("-%1 (%2)").arg(sensor.label, sensor.getRxOrModName(model)), i); + else + cb->addItem(QString("-%1").arg(sensor.label), i); + } } } cb->addItem("---", 0); for (unsigned i=1; i<=CPN_MAX_SENSORS; ++i) { - if (model->sensorData[i-1].isAvailable()) - cb->addItem(model->sensorData[i-1].label, i); + const SensorData& sensor = model->sensorData[i-1]; + if (sensor.isAvailable()) { + if (sensor.type == SensorData::TELEM_TYPE_CUSTOM) + cb->addItem(QString("%1 (%2)").arg(sensor.label, sensor.getRxOrModName(model)), i); + else + cb->addItem(QString("%1").arg(sensor.label), i); + } } } From 83998d4fba11dc880919fd827c3c26952d58beec Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Thu, 22 Aug 2019 06:35:20 +0200 Subject: [PATCH 17/17] fixed saving receiver names --- companion/src/firmwares/opentx/opentxeeprom.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index e7be89610..1c8a0f994 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -2072,6 +2072,18 @@ class ModuleUnionField: public UnionField { module.protocol == PULSES_ACCESS_ISRM) { module.subType = module.protocol - PULSES_ACCESS_ISRM; } + for (int i=0; i