chores(flysky): Separate AFHDS2A and AFHDS3 into 2 different module type (#3783)

* chores(flysky): separate AFHDS2A and AFHDS3 into 2 different module type

This should allow to remove some of the hacks added earlier.

* chore: Add some EL18 CI bits

* fix(afhds): cmake defs

* fix(ci): add el18 to commit-tests.sh

* chore(cpn): separate AFHDS2A and AFHDS3

* chore(cpn): remove binary import of afhds and legacy fxFreq field for afhds3

* fix(cpn): limit available internal afhds protocols to those supported by hardware

* chore(cpn): update Flysky int module test

* fix(cpn): compile error

* fix(cpn): afhds2a max channels

* fix: TR_MODULE_PROTOCOLS

* enh(cpn): more support for afhds2a and 3

* fix(cpn): rebase compile error

* fix(cpn): bit indexes

* fix(cpn): emi toString

* fix(cpn): limit available internal afhds protocols to those supported by hardware

* enh(cpn): add support for Flysky EL18

* fix(cpn): available protocols

* fix(cpn): rebase moduledata

* chore(cpn): add module fields to model print

* Separate AFHDS2A and AFHDS3 UI settings.

* Fix AFHDS3 conversion from old subtype value.
Fix 'Channel Range' layout on portrait LCD.

* Fix name.

---------

Co-authored-by: Peter Feerick <peter.feerick@gmail.com>
Co-authored-by: elecpower <neilh713@tpg.com.au>
Co-authored-by: Phil Mitchell <phil.a.mitchell@gmail.com>
This commit is contained in:
Raphael Coeffic
2023-09-07 19:24:03 +10:00
committed by GitHub
co-authored by Peter Feerick elecpower Phil Mitchell
parent 9515d29c9d
commit c4f1e7127d
59 changed files with 1098 additions and 463 deletions
@@ -54,8 +54,8 @@
// channelsStart: 0
// channelsCount: 18
// failsafeMode: NOT_SET
// mod:
// afhds3:
// mod:
// afhds3:
// emi: 2
// telemetry: 1
// phyMode: 2
@@ -78,10 +78,15 @@ static const YamlLookupTable protocolLut = {
{ PULSES_ACCESS_R9M_LITE_PRO, "TYPE_R9M_LITE_PRO_PXX2" },
{ PULSES_SBUS, "TYPE_SBUS" },
{ PULSES_XJT_LITE_X16, "TYPE_XJT_LITE_PXX2" },
{ PULSES_AFHDS3, "TYPE_FLYSKY" },
{ PULSES_FLYSKY_AFHDS2A, "TYPE_FLYSKY_AFHDS2A" },
{ PULSES_FLYSKY_AFHDS3, "TYPE_FLYSKY_AFHDS3" },
{ PULSES_LEMON_DSMP, "TYPE_LEMON_DSMP" },
};
static const YamlLookupTable oldprotocolLut = {
{ PULSES_FLYSKY_AFHDS2A, "TYPE_FLYSKY" },
};
static const YamlLookupTable xjtLut = {
{ 0, "D16" },
{ 1, "D8" },
@@ -111,9 +116,10 @@ static const YamlLookupTable dsmLut = {
{ 2, "DSMX" },
};
// depreciated - used for decoding and converting module subtype to protocol
static const YamlLookupTable afhdsLut = {
{ 0, "AFHDS3" },
{ 1, "AFHDS2A" } // could be complete nonsense, CHECK IT!
{ 0, "AFHDS2A" },
{ 1, "AFHDS3" }
};
static const YamlLookupTable failsafeLut = {
@@ -166,7 +172,7 @@ Node convert<ModuleData>::encode(const ModuleData& rhs)
break;
case PULSES_PPM:
node["subType"] = LookupValue(ppmLut, subtype);
break;
break;
case PULSES_MULTIMODULE: {
int rfProtocol = rhs.multi.rfProtocol + 1;
int subType = rhs.subType;
@@ -175,10 +181,6 @@ Node convert<ModuleData>::encode(const ModuleData& rhs)
st_str += std::to_string(subType);
node["subType"] = st_str;
} break;
case PULSES_AFHDS3: {
node["subType"] = LookupValue(afhdsLut, subtype);
break;
}
}
node["channelsStart"] = rhs.channelsStart;
@@ -246,9 +248,20 @@ Node convert<ModuleData>::encode(const ModuleData& rhs)
dsmp["flags"] = rhs.dsmp.flags;
mod["dsmp"] = dsmp;
} break;
// TODO: flysky
// TODO: afhds3
case PULSES_AFHDS3: {
case PULSES_FLYSKY_AFHDS2A: {
Node flysky;
for (int i = 0; i < 4; i++) {
flysky["rx_id"][std::to_string(i)]["val"] = rhs.flysky.rxId[i];
}
flysky["mode"] = rhs.flysky.mode;
flysky["rfPower"] = rhs.flysky.rfPower;
flysky["reserved"] = rhs.flysky.reserved;
for (int i = 0; i < 2; i++) {
flysky["rx_freq"][std::to_string(i)]["val"] = rhs.flysky.rxFreq[i];
}
mod["flysky"] = flysky;
} break;
case PULSES_FLYSKY_AFHDS3: {
Node afhds3;
afhds3["emi"] = rhs.afhds3.emi;
afhds3["telemetry"] = rhs.afhds3.telemetry;
@@ -275,6 +288,8 @@ Node convert<ModuleData>::encode(const ModuleData& rhs)
bool convert<ModuleData>::decode(const Node& node, ModuleData& rhs)
{
node["type"] >> protocolLut >> rhs.protocol;
if (rhs.protocol < 0)
node["type"] >> oldprotocolLut >> rhs.protocol;
Node subType;
node["subType"] >> subType;
@@ -319,6 +334,12 @@ bool convert<ModuleData>::decode(const Node& node, ModuleData& rhs)
} catch(...) {}
}
} break;
case PULSES_FLYSKY_AFHDS2A: {
int subProto = 0;
subType >> afhdsLut >> subProto;
rhs.protocol += subProto;
rhs.subType = 0;
} break;
}
node["channelsStart"] >> rhs.channelsStart;
@@ -381,15 +402,37 @@ bool convert<ModuleData>::decode(const Node& node, ModuleData& rhs)
Node dsmp = mod["dsmp"];
dsmp["flags"] >> rhs.dsmp.flags;
} else if (mod["flysky"]) {
// TODO: flysky
Node flysky = mod["flysky"];
for (int i = 0; i < 4; i++) {
if (flysky["rx_id"][std::to_string(i)]) {
Node rxid = flysky["rx_id"][std::to_string(i)];
if (rxid.IsMap()) {
if (rxid["val"]) {
rxid["val"] >> rhs.flysky.rxId[i];
}
}
}
}
flysky["mode"] >> rhs.flysky.mode;
flysky["rfPower"] >> rhs.flysky.rfPower;
flysky["reserved"] >> rhs.flysky.reserved;
for (int i = 0; i < 2; i++) {
if (flysky["rx_freq"][std::to_string(i)]) {
Node rxfreq = flysky["rx_freq"][std::to_string(i)];
if (rxfreq.IsMap()) {
if (rxfreq["val"]) {
rxfreq["val"] >> rhs.flysky.rxFreq[i];
}
}
}
}
} else if (mod["afhds3"]) {
// TODO: afhds3
Node afhds3 = mod["afhds3"];
afhds3["emi"] >> rhs.afhds3.emi;
afhds3["telemetry"] >> rhs.afhds3.telemetry;
afhds3["phyMode"] >> rhs.afhds3.phyMode;
afhds3["reserved"] >> rhs.afhds3.reserved;
afhds3["rfPower"] >> rhs.afhds3.rfPower;
Node afhds3 = mod["afhds3"];
afhds3["emi"] >> rhs.afhds3.emi;
afhds3["telemetry"] >> rhs.afhds3.telemetry;
afhds3["phyMode"] >> rhs.afhds3.phyMode;
afhds3["reserved"] >> rhs.afhds3.reserved;
afhds3["rfPower"] >> rhs.afhds3.rfPower;
}
}