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:
|
||||
|
||||
Reference in New Issue
Block a user