Support new Multi 1.3 features (#7077)
This commit is contained in:
@@ -86,7 +86,7 @@ QString ModuleData::rfProtocolToString() const
|
||||
{
|
||||
switch (protocol) {
|
||||
case PULSES_MULTIMODULE:
|
||||
return Multiprotocols::protocolToString((int)multi.rfProtocol, multi.customProto);
|
||||
return Multiprotocols::protocolToString((int)multi.rfProtocol);
|
||||
|
||||
default:
|
||||
return CPN_STR_UNKNOWN_ITEM;
|
||||
@@ -107,7 +107,7 @@ QString ModuleData::subTypeToString(int type) const
|
||||
|
||||
switch (protocol) {
|
||||
case PULSES_MULTIMODULE:
|
||||
return Multiprotocols::subTypeToString(multi.customProto ? MM_RF_CUSTOM_SELECTED : (int)multi.rfProtocol, (unsigned)type);
|
||||
return Multiprotocols::subTypeToString((int)multi.rfProtocol, (unsigned)type);
|
||||
|
||||
case PULSES_PXX_R9M:
|
||||
return CHECK_IN_ARRAY(strings, type);
|
||||
|
||||
@@ -164,9 +164,10 @@ class ModuleData {
|
||||
|
||||
struct Multi {
|
||||
unsigned int rfProtocol;
|
||||
bool disableTelemetry;
|
||||
bool disableMapping;
|
||||
bool autoBindMode;
|
||||
bool lowPowerMode;
|
||||
bool customProto;
|
||||
int optionValue;
|
||||
} multi;
|
||||
|
||||
|
||||
@@ -172,5 +172,8 @@ QString Multiprotocols::protocolToString(int protocol, bool custom)
|
||||
// static
|
||||
QString Multiprotocols::subTypeToString(int protocol, unsigned subType)
|
||||
{
|
||||
return tr(qPrintable(multiProtocols.getProtocol(protocol).subTypeStrings.value(subType, CPN_STR_UNKNOWN_ITEM)));
|
||||
if (protocol > MODULE_SUBTYPE_MULTI_LAST)
|
||||
return tr(qPrintable(QString::number(subType)));
|
||||
else
|
||||
return tr(qPrintable(multiProtocols.getProtocol(protocol).subTypeStrings.value(subType, CPN_STR_UNKNOWN_ITEM)));
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
#include <vector>
|
||||
#include <QtCore>
|
||||
#include "moduledata.h"
|
||||
|
||||
#define MM_RF_CUSTOM_SELECTED 0xff
|
||||
|
||||
@@ -48,7 +49,7 @@ class Multiprotocols
|
||||
|
||||
unsigned int numSubTypes() const
|
||||
{
|
||||
return (unsigned int) subTypeStrings.length();
|
||||
return protocol > MODULE_SUBTYPE_MULTI_LAST ? 8 : (unsigned int) subTypeStrings.length();
|
||||
}
|
||||
|
||||
int getOptionMin() const;
|
||||
|
||||
@@ -2037,9 +2037,10 @@ class ModuleUnionField: public UnionField<unsigned int> {
|
||||
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.customProto));
|
||||
internalField.Append(new UnsignedField<3>(this, rfProtExtra));
|
||||
internalField.Append(new BoolField<1>(this, multi.disableTelemetry));
|
||||
internalField.Append(new BoolField<1>(this, multi.disableMapping));
|
||||
internalField.Append(new SpareBitsField<1>(this));
|
||||
internalField.Append(new BoolField<1>(this, multi.autoBindMode));
|
||||
internalField.Append(new BoolField<1>(this, multi.lowPowerMode));
|
||||
internalField.Append(new SignedField<8>(this, multi.optionValue));
|
||||
@@ -2052,12 +2053,17 @@ class ModuleUnionField: public UnionField<unsigned int> {
|
||||
|
||||
void beforeExport() override
|
||||
{
|
||||
rfProtExtra = (module.multi.rfProtocol >> 4) & 0x03;
|
||||
if (module.multi.rfProtocol > MODULE_SUBTYPE_MULTI_LAST)
|
||||
module.multi.rfProtocol += 3;
|
||||
rfProtExtra = (module.multi.rfProtocol & 0x70) >> 4;
|
||||
module.multi.rfProtocol &= 0x0f;
|
||||
}
|
||||
|
||||
void afterImport() override
|
||||
{
|
||||
module.multi.rfProtocol = (rfProtExtra & 0x3) << 4 | (module.rfProtocol & 0xf);
|
||||
module.multi.rfProtocol = (rfProtExtra << 4) + (module.rfProtocol & 0xf);
|
||||
if (module.multi.rfProtocol > MODULE_SUBTYPE_MULTI_LAST)
|
||||
module.multi.rfProtocol -= 3;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -227,6 +227,9 @@ ModulePanel::ModulePanel(QWidget * parent, ModelData & model, ModuleData & modul
|
||||
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->btnGrpValueType->setId(ui->optPercent, FAILSAFE_DISPLAY_PERCENT);
|
||||
ui->btnGrpValueType->setId(ui->optUs, FAILSAFE_DISPLAY_USEC);
|
||||
@@ -469,14 +472,14 @@ void ModulePanel::update()
|
||||
break;
|
||||
case PULSES_MULTIMODULE:
|
||||
mask |= MASK_CHANNELS_RANGE | MASK_RX_NUMBER | MASK_MULTIMODULE | MASK_SUBTYPES;
|
||||
max_rx_num = 15;
|
||||
max_rx_num = 63;
|
||||
if (module.multi.rfProtocol == MODULE_SUBTYPE_MULTI_DSM2)
|
||||
mask |= MASK_CHANNELS_COUNT;
|
||||
else
|
||||
module.channelsCount = 16;
|
||||
if (pdef.optionsstr != nullptr)
|
||||
mask |= MASK_MULTIOPTION;
|
||||
if (pdef.hasFailsafe)
|
||||
if (pdef.hasFailsafe || (module.multi.rfProtocol == MODULE_SUBTYPE_MULTI_FRSKY && (module.subType == 0 || module.subType == 2 || module.subType > 3 )))
|
||||
mask |= MASK_FAILSAFES;
|
||||
break;
|
||||
case PULSES_OFF:
|
||||
@@ -565,7 +568,7 @@ void ModulePanel::update()
|
||||
unsigned i = 0;
|
||||
switch(protocol){
|
||||
case PULSES_MULTIMODULE:
|
||||
numEntries = (module.multi.customProto ? 8 : pdef.numSubTypes());
|
||||
numEntries = (module.multi.rfProtocol > MODULE_SUBTYPE_MULTI_LAST ? 8 : pdef.numSubTypes());
|
||||
break;
|
||||
case PULSES_PXX_R9M:
|
||||
if (firmware->getCapability(HasModuleR9MFlex))
|
||||
@@ -587,11 +590,15 @@ void ModulePanel::update()
|
||||
ui->multiProtocol->setVisible(mask & MASK_MULTIMODULE);
|
||||
ui->label_option->setVisible(mask & MASK_MULTIOPTION);
|
||||
ui->optionValue->setVisible(mask & MASK_MULTIOPTION);
|
||||
ui->disableTelem->setVisible(mask & MASK_MULTIMODULE);
|
||||
ui->disableChMap->setVisible(mask & MASK_MULTIMODULE);
|
||||
ui->autoBind->setVisible(mask & MASK_MULTIMODULE);
|
||||
ui->lowPower->setVisible(mask & MASK_MULTIMODULE);
|
||||
|
||||
if (mask & MASK_MULTIMODULE) {
|
||||
ui->multiProtocol->setCurrentIndex(ui->multiProtocol->findData(module.multi.rfProtocol));
|
||||
ui->disableTelem->setChecked(module.multi.disableTelemetry);
|
||||
ui->disableChMap->setChecked(module.multi.disableMapping);
|
||||
ui->autoBind->setChecked(module.multi.autoBindMode);
|
||||
ui->lowPower->setChecked(module.multi.lowPowerMode);
|
||||
}
|
||||
@@ -763,7 +770,7 @@ void ModulePanel::onMultiProtocolChanged(int index)
|
||||
lock=true;
|
||||
module.multi.rfProtocol = (unsigned int)rfProtocol;
|
||||
unsigned int maxSubTypes = multiProtocols.getProtocol(index).numSubTypes();
|
||||
if (module.multi.customProto)
|
||||
if (rfProtocol > MODULE_SUBTYPE_MULTI_LAST)
|
||||
maxSubTypes=8;
|
||||
module.subType = std::min(module.subType, maxSubTypes -1);
|
||||
module.channelsCount = getMaxChannelCount();
|
||||
@@ -793,10 +800,21 @@ void ModulePanel::onSubTypeChanged()
|
||||
}
|
||||
}
|
||||
|
||||
void ModulePanel::on_disableTelem_stateChanged(int state)
|
||||
{
|
||||
module.multi.disableTelemetry = (state == Qt::Checked);
|
||||
}
|
||||
|
||||
void ModulePanel::on_disableChMap_stateChanged(int state)
|
||||
{
|
||||
module.multi.disableMapping = (state == Qt::Checked);
|
||||
}
|
||||
|
||||
void ModulePanel::on_autoBind_stateChanged(int state)
|
||||
{
|
||||
module.multi.autoBindMode = (state == Qt::Checked);
|
||||
}
|
||||
|
||||
void ModulePanel::on_lowPower_stateChanged(int state)
|
||||
{
|
||||
module.multi.lowPowerMode = (state == Qt::Checked);
|
||||
|
||||
@@ -86,6 +86,8 @@ class ModulePanel : public ModelPanel
|
||||
void onMultiProtocolChanged(int index);
|
||||
void onSubTypeChanged();
|
||||
void on_autoBind_stateChanged(int state);
|
||||
void on_disableChMap_stateChanged(int state);
|
||||
void on_disableTelem_stateChanged(int state);
|
||||
void on_lowPower_stateChanged(int state);
|
||||
void on_r9mPower_currentIndexChanged(int index);
|
||||
void setChannelFailsafeValue(const int channel, const int value, quint8 updtSb = 0);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1075</width>
|
||||
<height>434</height>
|
||||
<height>438</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -937,7 +937,7 @@
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0" colspan="2">
|
||||
<item row="11" column="0" colspan="2">
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
@@ -950,6 +950,20 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<widget class="QCheckBox" name="disableTelem">
|
||||
<property name="text">
|
||||
<string>Disable Telemetry</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="1">
|
||||
<widget class="QCheckBox" name="disableChMap">
|
||||
<property name="text">
|
||||
<string>Disable Ch. Map</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="3">
|
||||
|
||||
Reference in New Issue
Block a user