chore: Companion - add support for GHOST 12bit opt (#1689)
* chore: Companion - add support for 12bit GHOST opt Resolves #1510 * Ghost protocol reading and writing non-yaml formats Co-authored-by: elecpower <neilh713@tpg.com.au>
This commit is contained in:
co-authored by
elecpower
parent
9e6ab84599
commit
4571c7b724
@@ -37,6 +37,15 @@
|
||||
// receiverTelemetryOff: 0
|
||||
// receiverHigherChannels: 0
|
||||
|
||||
// type: TYPE_GHOST
|
||||
// subType: 0
|
||||
// channelsStart: 0
|
||||
// channelsCount: 16
|
||||
// failsafeMode: NOT_SET
|
||||
// mod:
|
||||
// ghost:
|
||||
// raw12bits: 0
|
||||
|
||||
static const YamlLookupTable protocolLut = {
|
||||
{ PULSES_OFF, "TYPE_NONE" },
|
||||
{ PULSES_PPM, "TYPE_PPM" },
|
||||
@@ -284,6 +293,11 @@ Node convert<ModuleData>::encode(const ModuleData& rhs)
|
||||
sbus["refreshRate"] = rhs.ppm.frameLength;
|
||||
mod["sbus"] = sbus;
|
||||
} break;
|
||||
case PULSES_GHOST: {
|
||||
Node ghost;
|
||||
ghost["raw12bits"] = (int)rhs.ghost.raw12bits;
|
||||
mod["ghost"] = ghost;
|
||||
} break;
|
||||
// TODO: afhds3, flysky
|
||||
default: {
|
||||
Node ppm;
|
||||
@@ -384,6 +398,9 @@ bool convert<ModuleData>::decode(const Node& node, ModuleData& rhs)
|
||||
for (const auto& rx : pxx2["receiverName"]) {
|
||||
rx >> rhs.access.receiverName;
|
||||
}
|
||||
} else if (mod["ghost"]) {
|
||||
Node ghost = mod["ghost"];
|
||||
ghost["raw12bits"] >> rhs.ghost.raw12bits;
|
||||
} else if (mod["flysky"]) {
|
||||
//TODO
|
||||
} else if (mod["afhds3"]) {
|
||||
|
||||
@@ -227,6 +227,10 @@ class ModuleData {
|
||||
int antennaMode; // false = internal antenna, true = external antenna
|
||||
} pxx;
|
||||
|
||||
struct GHOST {
|
||||
bool raw12bits;
|
||||
} ghost;
|
||||
|
||||
struct Access {
|
||||
unsigned int receivers;
|
||||
char receiverName[PXX2_MAX_RECEIVERS_PER_MODULE][PXX2_LEN_RX_NAME+1];
|
||||
|
||||
@@ -2260,6 +2260,29 @@ class ModuleUnionField: public UnionField<unsigned int> {
|
||||
char receiverName[PXX2_MAX_RECEIVERS_PER_MODULE][PXX2_LEN_RX_NAME+1] = {};
|
||||
};
|
||||
|
||||
class GhostField: public UnionField::TransformedMember {
|
||||
public:
|
||||
GhostField(DataField * parent, ModuleData& module):
|
||||
UnionField::TransformedMember(parent, internalField),
|
||||
internalField(this, "GHOST")
|
||||
{
|
||||
internalField.Append(new BoolField<1>(this, module.ghost.raw12bits));
|
||||
internalField.Append(new SpareBitsField<7>(this));
|
||||
}
|
||||
|
||||
bool select(const unsigned int & attr) const override
|
||||
{
|
||||
return attr == PULSES_GHOST;
|
||||
}
|
||||
|
||||
void beforeExport() override {}
|
||||
|
||||
void afterImport() override {}
|
||||
|
||||
private:
|
||||
StructField internalField;
|
||||
};
|
||||
|
||||
public:
|
||||
ModuleUnionField(DataField * parent, ModuleData & module, Board::Type board, unsigned int version):
|
||||
UnionField<unsigned int>(parent, module.protocol)
|
||||
@@ -2267,6 +2290,7 @@ class ModuleUnionField: public UnionField<unsigned int> {
|
||||
if (version >= 219) {
|
||||
Append(new AccessField(parent, module));
|
||||
Append(new Afhds3Field(parent, module));
|
||||
Append(new GhostField(parent, module));
|
||||
}
|
||||
Append(new PxxField(parent, module, version));
|
||||
Append(new MultiField(parent, module));
|
||||
|
||||
Reference in New Issue
Block a user