mirror of
https://github.com/opentx/opentx.git
synced 2025-07-26 01:35:21 +03:00
re-fix subType for PXX1 modules (#6708)
re-fix subType for PXX1 modules
This commit is contained in:
parent
995aa8708a
commit
005e74feea
3 changed files with 11 additions and 17 deletions
|
@ -2058,10 +2058,11 @@ class ModuleUnionField: public UnionField<unsigned int> {
|
||||||
|
|
||||||
class PxxField: public UnionField::TransformedMember {
|
class PxxField: public UnionField::TransformedMember {
|
||||||
public:
|
public:
|
||||||
PxxField(DataField * parent, ModuleData& module):
|
PxxField(DataField * parent, ModuleData& module, unsigned int version):
|
||||||
UnionField::TransformedMember(parent, internalField),
|
UnionField::TransformedMember(parent, internalField),
|
||||||
internalField(this, "Pxx"),
|
internalField(this, "Pxx"),
|
||||||
module(module)
|
module(module),
|
||||||
|
version(version)
|
||||||
{
|
{
|
||||||
ModuleData::PXX& pxx = module.pxx;
|
ModuleData::PXX& pxx = module.pxx;
|
||||||
internalField.Append(new UnsignedField<2>(this, pxx.power));
|
internalField.Append(new UnsignedField<2>(this, pxx.power));
|
||||||
|
@ -2073,7 +2074,7 @@ class ModuleUnionField: public UnionField<unsigned int> {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool select(const unsigned int& attr) const override {
|
bool select(const unsigned int& attr) const override {
|
||||||
return attr==PULSES_PXX_XJT_X16 ||
|
return (attr >= PULSES_PXX_XJT_X16 && attr <= PULSES_PXX_XJT_LR12) ||
|
||||||
attr==PULSES_PXX_DJT ||
|
attr==PULSES_PXX_DJT ||
|
||||||
attr==PULSES_PXX_R9M ||
|
attr==PULSES_PXX_R9M ||
|
||||||
attr==PULSES_PXX_R9M_LITE;
|
attr==PULSES_PXX_R9M_LITE;
|
||||||
|
@ -2089,13 +2090,17 @@ class ModuleUnionField: public UnionField<unsigned int> {
|
||||||
void afterImport() override
|
void afterImport() override
|
||||||
{
|
{
|
||||||
if (module.protocol == PULSES_PXX_XJT_X16) {
|
if (module.protocol == PULSES_PXX_XJT_X16) {
|
||||||
module.protocol += module.subType;
|
if (version <= 218)
|
||||||
|
module.protocol += module.rfProtocol;
|
||||||
|
else
|
||||||
|
module.protocol += module.subType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
StructField internalField;
|
StructField internalField;
|
||||||
ModuleData& module;
|
ModuleData& module;
|
||||||
|
unsigned int version;
|
||||||
};
|
};
|
||||||
|
|
||||||
class AccessField: public UnionField::TransformedMember {
|
class AccessField: public UnionField::TransformedMember {
|
||||||
|
@ -2163,7 +2168,7 @@ class ModuleUnionField: public UnionField<unsigned int> {
|
||||||
{
|
{
|
||||||
if (version >= 219)
|
if (version >= 219)
|
||||||
Append(new AccessField(parent, module));
|
Append(new AccessField(parent, module));
|
||||||
Append(new PxxField(parent, module));
|
Append(new PxxField(parent, module, version));
|
||||||
Append(new MultiField(parent, module));
|
Append(new MultiField(parent, module));
|
||||||
Append(new PPMField(parent, module.ppm));
|
Append(new PPMField(parent, module.ppm));
|
||||||
}
|
}
|
||||||
|
@ -2199,12 +2204,6 @@ class ModuleField: public TransformedField {
|
||||||
if (module.protocol >= PULSES_LP45 && module.protocol <= PULSES_DSMX) {
|
if (module.protocol >= PULSES_LP45 && module.protocol <= PULSES_DSMX) {
|
||||||
module.rfProtocol = module.protocol - PULSES_LP45;
|
module.rfProtocol = module.protocol - PULSES_LP45;
|
||||||
}
|
}
|
||||||
else if (module.protocol >= PULSES_PXX_XJT_X16 && module.protocol <= PULSES_PXX_XJT_LR12) {
|
|
||||||
module.subType = module.protocol - PULSES_PXX_XJT_X16;
|
|
||||||
}
|
|
||||||
else if (module.protocol >= PULSES_ACCESS_ISRM && module.protocol <= PULSES_ACCST_ISRM_D16) {
|
|
||||||
module.subType = module.protocol - PULSES_ACCESS_ISRM;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void afterImport() override
|
void afterImport() override
|
||||||
|
@ -2212,12 +2211,6 @@ class ModuleField: public TransformedField {
|
||||||
if (module.protocol == PULSES_LP45) {
|
if (module.protocol == PULSES_LP45) {
|
||||||
module.protocol += module.rfProtocol;
|
module.protocol += module.rfProtocol;
|
||||||
}
|
}
|
||||||
else if (module.protocol == PULSES_PXX_XJT_X16) {
|
|
||||||
module.protocol += module.subType;
|
|
||||||
}
|
|
||||||
else if (module.protocol == PULSES_ACCESS_ISRM) {
|
|
||||||
module.protocol += module.subType;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -271,6 +271,7 @@ TEST(Conversions, ConversionX10From22)
|
||||||
EXPECT_STREQ("Tes", model.flightModeData[0].name);
|
EXPECT_STREQ("Tes", model.flightModeData[0].name);
|
||||||
EXPECT_EQ(10, model.flightModeData[0].gvars[0]);
|
EXPECT_EQ(10, model.flightModeData[0].gvars[0]);
|
||||||
EXPECT_STREQ("Tes", model.gvarData[0].name);
|
EXPECT_STREQ("Tes", model.gvarData[0].name);
|
||||||
|
EXPECT_EQ(PULSES_PXX_XJT_D8, model.moduleData[0].protocol);
|
||||||
EXPECT_EQ(PULSES_PXX_R9M, model.moduleData[1].protocol);
|
EXPECT_EQ(PULSES_PXX_R9M, model.moduleData[1].protocol);
|
||||||
EXPECT_EQ(MODULE_SUBTYPE_R9M_EU, model.moduleData[1].subType);
|
EXPECT_EQ(MODULE_SUBTYPE_R9M_EU, model.moduleData[1].subType);
|
||||||
EXPECT_STREQ("Rud", model.inputNames[0]);
|
EXPECT_STREQ("Rud", model.inputNames[0]);
|
||||||
|
|
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue