fix: Update built-in Multi-protocol module protocol lists, single source for firmware and cpn (#3435)
* - Concentrated Multi protocol definitions into a consistent single source. Actually two .h files, one for the protocol list and names, the other for subtypes and capababilites, see comments in .h files as to why - updated available protocols reflecting 1.3.3.20 (15+ protocols) - fixed Companion always showing f/s and channel map options in model setup disregarding the protocol capability * Following @pfeerick's review: changed heaeders and typos fixed Ubuntu runtime error on assert fixed change of Multi protocol not triggering writing yaml file * corrected copy/paste error * fixed FrSky index juggling * Updated Multiprotocol database to current MPM project status (ref. MPM Multiprotos.ino) - changed protocol name FX816 to FX - added Flysky AFHDS2A options PPM and PPWM SBUS 16ch subtypes "PWM,SB16" and "PPM,SB16 - added V761 option to select TOPRC - added FX options "816" and "620" - added FRSKYR9 option "-- 8ch" * MPM protocol scan excludes some protocols which are not meant to be selected. For Companion and Simualtor (and for radios if there is no MPM connected) this was handled in different places with outdated information. Harmonized and centralized the handling of non-selectabale protocols into the single source for all companion, Simulator and all gui types. * More cleanup: - changed some MPM protocol names to the ones the MPM delivers with MPM protocol scan to harmonize names between CPN/Simulator/radio - added XN2927DUMP and MOULDKG to the list of excluded MPM protocols just like the MPM does with MPM protocol scan - added new option value limits and moved definitions to single source - adapted CPN and radio to use common definitions of option values for all GUI types - moved distributed MPM (as far as possible) to one coherent place under a single #if defined (MULTIMODULE) - fixed option value not reset at change of protocol - some editorial stuff Note: There is still some work to be done on CPN GUI option values. DSM2 servo rates are hard coded, BAYANG telemetry options are only shown by index and not by text as in radio code, AFHDS2A servo update rate is shown as index too which is to no use for users. I'll try to fix all this in the next session, but request to get rid of BAYANG telemetry options translations. It is much easier to define a common string list by using untranslated.h * rebase due to fr.h * resolve merge conflict with main fr.h * more cleanup: - deleted multiple definition of MM_RF_CUSTOM_SELECTED in favor of single source define - bw radios: change to only allow defined protocols rather than a fixed 127 protocols * Changes: - magic sentinel number 0xfe as define - add 10 NN protocol entries for future use of new MPM protocols not yet defined in ETX (still recommend timely ETX maintenance update if MPM releases new firmware) * Changes by @elecpower: - align field labels to radio - change servo update frequency from combo box to spin box with edit only via up/down arrows to stop invalid values being entered via keyboard. Remove frequency list used to populate combo box as only used by Companion. - add validation to module yaml decode checking for unsupported multi protocols and/or multi protocol sub types and if unsupported set module to OFF just to be safe. * Changes: - radio: added validation to module yaml decode checking for unsupported multi protocols and/or multi protocol sub types and if unsupported set module to OFF just to be safe. * CPN: use sentinel define * cpn: Sort multi protocols list (courtesy @elecpower) * fixes #3480 changes: - moved FrSky subtype defines to MultiProtoDefs.h - updated bind_button_driver.cpp * missed replacing one instance of setMultiProtocol() * changes: - editorial change - added multi option to OMP protocol (ref #2713) * rather go for STR_MULTI_RFTUNE because MPM manual talks about RF tune * made XN297_DUMP selectable (available with MPM debug fw only) * corrected merge mistakes
This commit is contained in:
@@ -202,26 +202,28 @@ void TimerPanel::onModeChanged(int index)
|
||||
#define FAILSAFE_CHANNEL_HOLD 2000
|
||||
#define FAILSAFE_CHANNEL_NOPULSE 2001
|
||||
|
||||
#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)
|
||||
#define MASK_RX_FREQ (1<<14)
|
||||
#define MASK_RF_POWER (1<<15)
|
||||
#define MASK_RF_RACING_MODE (1<<16)
|
||||
#define MASK_GHOST (1<<17)
|
||||
#define MASK_BAUDRATE (1<<18)
|
||||
#define MASK_MULTI_DSM_OPT (1<<19)
|
||||
#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)
|
||||
#define MASK_RX_FREQ (1<<14)
|
||||
#define MASK_RF_POWER (1<<15)
|
||||
#define MASK_RF_RACING_MODE (1<<16)
|
||||
#define MASK_GHOST (1<<17)
|
||||
#define MASK_BAUDRATE (1<<18)
|
||||
#define MASK_MULTI_DSM_OPT (1<<19)
|
||||
#define MASK_CHANNELMAP (1<<20)
|
||||
#define MASK_MULTI_BAYANG_OPT (1<<21)
|
||||
|
||||
quint8 ModulePanel::failsafesValueDisplayType = ModulePanel::FAILSAFE_DISPLAY_PERCENT;
|
||||
|
||||
@@ -289,14 +291,7 @@ ModulePanel::ModulePanel(QWidget * parent, ModelData & model, ModuleData & modul
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i <= MODULE_SUBTYPE_MULTI_LAST; i++) {
|
||||
if (i == MODULE_SUBTYPE_MULTI_SCANNER || i == MODULE_SUBTYPE_MULTI_CONFIG)
|
||||
continue;
|
||||
ui->multiProtocol->addItem(Multiprotocols::protocolToString(i), i);
|
||||
}
|
||||
for (int i = MODULE_SUBTYPE_MULTI_LAST + 1; i <= 124; i++) {
|
||||
ui->multiProtocol->addItem(QString::number(i + 3), i);
|
||||
}
|
||||
ui->multiProtocol->setModel(Multiprotocols::protocolItemModel());
|
||||
|
||||
ui->btnGrpValueType->setId(ui->optPercent, FAILSAFE_DISPLAY_PERCENT);
|
||||
ui->btnGrpValueType->setId(ui->optUs, FAILSAFE_DISPLAY_USEC);
|
||||
@@ -499,7 +494,18 @@ void ModulePanel::update()
|
||||
break;
|
||||
case PULSES_MULTIMODULE:
|
||||
mask |= MASK_CHANNELS_RANGE | MASK_RX_NUMBER | MASK_MULTIMODULE | MASK_SUBTYPES;
|
||||
max_rx_num = 63;
|
||||
|
||||
switch (module.multi.rfProtocol) {
|
||||
case MODULE_SUBTYPE_MULTI_OLRS:
|
||||
max_rx_num = MODULE_SUBTYPE_MULTI_OLRS_RXNUM;
|
||||
case MODULE_SUBTYPE_MULTI_BUGS:
|
||||
max_rx_num = MODULE_SUBTYPE_MULTI_BUGS_RXNUM;
|
||||
case MODULE_SUBTYPE_MULTI_BUGS_MINI:
|
||||
max_rx_num = MODULE_SUBTYPE_MULTI_BUGS_MINI_RXNUM;
|
||||
default:
|
||||
max_rx_num = 63;
|
||||
}
|
||||
|
||||
if (module.multi.rfProtocol == MODULE_SUBTYPE_MULTI_DSM2)
|
||||
mask |= MASK_CHANNELS_COUNT;
|
||||
else
|
||||
@@ -507,11 +513,15 @@ void ModulePanel::update()
|
||||
if (pdef.optionsstr != nullptr) {
|
||||
if (module.multi.rfProtocol == MODULE_SUBTYPE_MULTI_DSM2)
|
||||
mask |= MASK_MULTI_DSM_OPT;
|
||||
else if (module.multi.rfProtocol == MODULE_SUBTYPE_MULTI_BAYANG)
|
||||
mask |= MASK_MULTI_BAYANG_OPT;
|
||||
else
|
||||
mask |= MASK_MULTIOPTION;
|
||||
}
|
||||
if (pdef.hasFailsafe || (module.multi.rfProtocol == MODULE_SUBTYPE_MULTI_FRSKY && (module.subType == 0 || module.subType == 2 || module.subType > 3 )))
|
||||
mask |= MASK_FAILSAFES;
|
||||
if (pdef.disableChannelMap)
|
||||
mask |= MASK_CHANNELMAP;
|
||||
break;
|
||||
case PULSES_AFHDS3:
|
||||
module.channelsCount = 18;
|
||||
@@ -533,8 +543,7 @@ void ModulePanel::update()
|
||||
else if (model->trainerMode != TRAINER_MODE_MASTER_JACK) {
|
||||
mask |= MASK_PPM_FIELDS | MASK_CHANNELS_RANGE | MASK_CHANNELS_COUNT;
|
||||
}
|
||||
|
||||
if (module.hasFailsafes(firmware)) {
|
||||
else if (module.hasFailsafes(firmware)) {
|
||||
mask |= MASK_FAILSAFES;
|
||||
}
|
||||
|
||||
@@ -647,10 +656,10 @@ void ModulePanel::update()
|
||||
ui->optionValue->setVisible(mask & MASK_MULTIOPTION);
|
||||
ui->lblChkOption->setVisible(mask & MASK_MULTI_DSM_OPT);
|
||||
ui->chkOption->setVisible(mask & MASK_MULTI_DSM_OPT);
|
||||
ui->lblCboOption->setVisible(mask & MASK_MULTI_DSM_OPT);
|
||||
ui->cboOption->setVisible(mask & MASK_MULTI_DSM_OPT);
|
||||
ui->lblCboOption->setVisible(mask & MASK_MULTI_DSM_OPT || mask & MASK_MULTI_BAYANG_OPT);
|
||||
ui->cboOption->setVisible(mask & MASK_MULTI_DSM_OPT || mask & MASK_MULTI_BAYANG_OPT);
|
||||
ui->disableTelem->setVisible(mask & MASK_MULTIMODULE);
|
||||
ui->disableChMap->setVisible(mask & MASK_MULTIMODULE);
|
||||
ui->disableChMap->setVisible(mask & MASK_CHANNELMAP);
|
||||
ui->lowPower->setVisible(mask & MASK_MULTIMODULE);
|
||||
ui->autoBind->setVisible(mask & MASK_MULTIMODULE);
|
||||
if (module.multi.rfProtocol == MODULE_SUBTYPE_MULTI_DSM2)
|
||||
@@ -667,10 +676,32 @@ void ModulePanel::update()
|
||||
}
|
||||
|
||||
if (mask & MASK_MULTIOPTION) {
|
||||
ui->optionValue->setMinimum(pdef.getOptionMin());
|
||||
ui->optionValue->setMaximum(pdef.getOptionMax());
|
||||
ui->optionValue->setValue(module.multi.optionValue);
|
||||
ui->label_option->setText(qApp->translate("Multiprotocols", qPrintable(pdef.optionsstr)));
|
||||
int8_t min, max;
|
||||
getMultiOptionValues(module.multi.rfProtocol, min, max);
|
||||
|
||||
auto lineEdit = ui->optionValue->findChild<QLineEdit*>();
|
||||
|
||||
if (module.multi.rfProtocol == MODULE_SUBTYPE_MULTI_FS_AFHDS2A) {
|
||||
ui->optionValue->setMinimum(50 + 5 * min);
|
||||
ui->optionValue->setMaximum(50 + 5 * max);
|
||||
ui->optionValue->setSingleStep(5);
|
||||
ui->optionValue->setValue(50 + 5 * module.multi.optionValue);
|
||||
if (lineEdit) {
|
||||
lineEdit->setReadOnly(true);
|
||||
lineEdit->setFocusPolicy(Qt::NoFocus);
|
||||
}
|
||||
}
|
||||
else {
|
||||
ui->optionValue->setMinimum(min);
|
||||
ui->optionValue->setMaximum(max);
|
||||
ui->optionValue->setSingleStep(1);
|
||||
ui->optionValue->setValue(module.multi.optionValue);
|
||||
if (lineEdit) {
|
||||
lineEdit->setReadOnly(false);
|
||||
lineEdit->setFocusPolicy(Qt::WheelFocus);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mask & MASK_MULTI_DSM_OPT) {
|
||||
@@ -678,7 +709,15 @@ void ModulePanel::update()
|
||||
ui->chkOption->setChecked(Helpers::getBitmappedValue(module.multi.optionValue, 0));
|
||||
ui->lblCboOption->setText(qApp->translate("Multiprotocols", "Servo update rate"));
|
||||
ui->cboOption->clear();
|
||||
ui->cboOption->addItems({"22ms", "11ms"});
|
||||
ui->cboOption->addItems({ DSM2_OPTION_SERVOFREQ_NAMES });
|
||||
ui->cboOption->setSizeAdjustPolicy(QComboBox::AdjustToContents);
|
||||
ui->cboOption->setCurrentIndex(Helpers::getBitmappedValue(module.multi.optionValue, 1));
|
||||
}
|
||||
|
||||
if (mask & MASK_MULTI_BAYANG_OPT) {
|
||||
ui->lblCboOption->setText(qApp->translate("Multiprotocols", qPrintable(pdef.optionsstr)));
|
||||
ui->cboOption->clear();
|
||||
ui->cboOption->addItems({ BAYANG_OPTION_TELEMETRY_NAMES });
|
||||
ui->cboOption->setSizeAdjustPolicy(QComboBox::AdjustToContents);
|
||||
ui->cboOption->setCurrentIndex(Helpers::getBitmappedValue(module.multi.optionValue, 1));
|
||||
}
|
||||
@@ -864,6 +903,7 @@ void ModulePanel::onMultiProtocolChanged(int index)
|
||||
if (!lock && module.multi.rfProtocol != (unsigned)rfProtocol) {
|
||||
lock=true;
|
||||
module.multi.rfProtocol = (unsigned int)rfProtocol;
|
||||
module.multi.optionValue = 0;
|
||||
unsigned int maxSubTypes = multiProtocols.getProtocol(index).numSubTypes();
|
||||
if (rfProtocol > MODULE_SUBTYPE_MULTI_LAST)
|
||||
maxSubTypes = 8;
|
||||
@@ -876,10 +916,15 @@ void ModulePanel::onMultiProtocolChanged(int index)
|
||||
}
|
||||
}
|
||||
|
||||
void ModulePanel::on_optionValue_editingFinished()
|
||||
void ModulePanel::on_optionValue_valueChanged(int value)
|
||||
{
|
||||
if (module.multi.optionValue != ui->optionValue->value()) {
|
||||
module.multi.optionValue = ui->optionValue->value();
|
||||
if (!lock) {
|
||||
if (module.multi.rfProtocol == MODULE_SUBTYPE_MULTI_FS_AFHDS2A) {
|
||||
module.multi.optionValue = (value - 50) / 5;
|
||||
}
|
||||
else {
|
||||
module.multi.optionValue = value;
|
||||
}
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user