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
|
// receiverTelemetryOff: 0
|
||||||
// receiverHigherChannels: 0
|
// receiverHigherChannels: 0
|
||||||
|
|
||||||
|
// type: TYPE_GHOST
|
||||||
|
// subType: 0
|
||||||
|
// channelsStart: 0
|
||||||
|
// channelsCount: 16
|
||||||
|
// failsafeMode: NOT_SET
|
||||||
|
// mod:
|
||||||
|
// ghost:
|
||||||
|
// raw12bits: 0
|
||||||
|
|
||||||
static const YamlLookupTable protocolLut = {
|
static const YamlLookupTable protocolLut = {
|
||||||
{ PULSES_OFF, "TYPE_NONE" },
|
{ PULSES_OFF, "TYPE_NONE" },
|
||||||
{ PULSES_PPM, "TYPE_PPM" },
|
{ PULSES_PPM, "TYPE_PPM" },
|
||||||
@@ -284,6 +293,11 @@ Node convert<ModuleData>::encode(const ModuleData& rhs)
|
|||||||
sbus["refreshRate"] = rhs.ppm.frameLength;
|
sbus["refreshRate"] = rhs.ppm.frameLength;
|
||||||
mod["sbus"] = sbus;
|
mod["sbus"] = sbus;
|
||||||
} break;
|
} break;
|
||||||
|
case PULSES_GHOST: {
|
||||||
|
Node ghost;
|
||||||
|
ghost["raw12bits"] = (int)rhs.ghost.raw12bits;
|
||||||
|
mod["ghost"] = ghost;
|
||||||
|
} break;
|
||||||
// TODO: afhds3, flysky
|
// TODO: afhds3, flysky
|
||||||
default: {
|
default: {
|
||||||
Node ppm;
|
Node ppm;
|
||||||
@@ -384,6 +398,9 @@ bool convert<ModuleData>::decode(const Node& node, ModuleData& rhs)
|
|||||||
for (const auto& rx : pxx2["receiverName"]) {
|
for (const auto& rx : pxx2["receiverName"]) {
|
||||||
rx >> rhs.access.receiverName;
|
rx >> rhs.access.receiverName;
|
||||||
}
|
}
|
||||||
|
} else if (mod["ghost"]) {
|
||||||
|
Node ghost = mod["ghost"];
|
||||||
|
ghost["raw12bits"] >> rhs.ghost.raw12bits;
|
||||||
} else if (mod["flysky"]) {
|
} else if (mod["flysky"]) {
|
||||||
//TODO
|
//TODO
|
||||||
} else if (mod["afhds3"]) {
|
} else if (mod["afhds3"]) {
|
||||||
|
|||||||
@@ -227,6 +227,10 @@ class ModuleData {
|
|||||||
int antennaMode; // false = internal antenna, true = external antenna
|
int antennaMode; // false = internal antenna, true = external antenna
|
||||||
} pxx;
|
} pxx;
|
||||||
|
|
||||||
|
struct GHOST {
|
||||||
|
bool raw12bits;
|
||||||
|
} ghost;
|
||||||
|
|
||||||
struct Access {
|
struct Access {
|
||||||
unsigned int receivers;
|
unsigned int receivers;
|
||||||
char receiverName[PXX2_MAX_RECEIVERS_PER_MODULE][PXX2_LEN_RX_NAME+1];
|
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] = {};
|
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:
|
public:
|
||||||
ModuleUnionField(DataField * parent, ModuleData & module, Board::Type board, unsigned int version):
|
ModuleUnionField(DataField * parent, ModuleData & module, Board::Type board, unsigned int version):
|
||||||
UnionField<unsigned int>(parent, module.protocol)
|
UnionField<unsigned int>(parent, module.protocol)
|
||||||
@@ -2267,6 +2290,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 Afhds3Field(parent, module));
|
Append(new Afhds3Field(parent, module));
|
||||||
|
Append(new GhostField(parent, module));
|
||||||
}
|
}
|
||||||
Append(new PxxField(parent, module, version));
|
Append(new PxxField(parent, module, version));
|
||||||
Append(new MultiField(parent, module));
|
Append(new MultiField(parent, module));
|
||||||
|
|||||||
@@ -202,6 +202,7 @@ void TimerPanel::onModeChanged(int index)
|
|||||||
#define MASK_RX_FREQ (1<<14)
|
#define MASK_RX_FREQ (1<<14)
|
||||||
#define MASK_RF_POWER (1<<15)
|
#define MASK_RF_POWER (1<<15)
|
||||||
#define MASK_RF_RACING_MODE (1<<16)
|
#define MASK_RF_RACING_MODE (1<<16)
|
||||||
|
#define MASK_GHOST (1<<17)
|
||||||
|
|
||||||
quint8 ModulePanel::failsafesValueDisplayType = ModulePanel::FAILSAFE_DISPLAY_PERCENT;
|
quint8 ModulePanel::failsafesValueDisplayType = ModulePanel::FAILSAFE_DISPLAY_PERCENT;
|
||||||
|
|
||||||
@@ -445,7 +446,7 @@ void ModulePanel::update()
|
|||||||
case PULSES_CROSSFIRE:
|
case PULSES_CROSSFIRE:
|
||||||
mask |= MASK_CHANNELS_RANGE | MASK_RX_NUMBER;
|
mask |= MASK_CHANNELS_RANGE | MASK_RX_NUMBER;
|
||||||
case PULSES_GHOST:
|
case PULSES_GHOST:
|
||||||
mask |= MASK_CHANNELS_RANGE;
|
mask |= MASK_CHANNELS_RANGE | MASK_GHOST;
|
||||||
module.channelsCount = 16;
|
module.channelsCount = 16;
|
||||||
break;
|
break;
|
||||||
case PULSES_PPM:
|
case PULSES_PPM:
|
||||||
@@ -616,6 +617,12 @@ void ModulePanel::update()
|
|||||||
ui->label_option->setText(qApp->translate("Multiprotocols", qPrintable(pdef.optionsstr)));
|
ui->label_option->setText(qApp->translate("Multiprotocols", qPrintable(pdef.optionsstr)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ghost settings fields
|
||||||
|
ui->raw12bits->setVisible(mask & MASK_GHOST);
|
||||||
|
if (mask & MASK_GHOST) {
|
||||||
|
ui->raw12bits->setChecked(module.ghost.raw12bits);
|
||||||
|
}
|
||||||
|
|
||||||
if (mask & MASK_ACCESS) {
|
if (mask & MASK_ACCESS) {
|
||||||
ui->rx1->setText(module.access.receiverName[0]);
|
ui->rx1->setText(module.access.receiverName[0]);
|
||||||
ui->rx2->setText(module.access.receiverName[1]);
|
ui->rx2->setText(module.access.receiverName[1]);
|
||||||
@@ -827,6 +834,11 @@ void ModulePanel::on_disableChMap_stateChanged(int state)
|
|||||||
module.multi.disableMapping = (state == Qt::Checked);
|
module.multi.disableMapping = (state == Qt::Checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ModulePanel::on_raw12bits_stateChanged(int state)
|
||||||
|
{
|
||||||
|
module.ghost.raw12bits = (state == Qt::Checked);
|
||||||
|
}
|
||||||
|
|
||||||
void ModulePanel::on_racingMode_stateChanged(int state)
|
void ModulePanel::on_racingMode_stateChanged(int state)
|
||||||
{
|
{
|
||||||
module.access.racingMode = (state == Qt::Checked);
|
module.access.racingMode = (state == Qt::Checked);
|
||||||
|
|||||||
@@ -99,6 +99,7 @@ class ModulePanel : public ModelPanel
|
|||||||
void onSubTypeChanged();
|
void onSubTypeChanged();
|
||||||
void on_autoBind_stateChanged(int state);
|
void on_autoBind_stateChanged(int state);
|
||||||
void on_disableChMap_stateChanged(int state);
|
void on_disableChMap_stateChanged(int state);
|
||||||
|
void on_raw12bits_stateChanged(int state);
|
||||||
void on_racingMode_stateChanged(int state);
|
void on_racingMode_stateChanged(int state);
|
||||||
void on_disableTelem_stateChanged(int state);
|
void on_disableTelem_stateChanged(int state);
|
||||||
void on_lowPower_stateChanged(int state);
|
void on_lowPower_stateChanged(int state);
|
||||||
|
|||||||
@@ -1051,7 +1051,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="12" column="0" colspan="2">
|
<item row="14" column="0" colspan="2">
|
||||||
<spacer name="horizontalSpacer_3">
|
<spacer name="horizontalSpacer_3">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
@@ -1071,6 +1071,13 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="12" column="1">
|
||||||
|
<widget class="QCheckBox" name="raw12bits">
|
||||||
|
<property name="text">
|
||||||
|
<string>Raw 12 bits</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0" colspan="3">
|
<item row="2" column="0" colspan="3">
|
||||||
|
|||||||
@@ -230,6 +230,9 @@ QString ModelPrinter::printModule(int idx)
|
|||||||
str << printLabelValue(tr("RF Output Power"), module.powerValueToString(firmware));
|
str << printLabelValue(tr("RF Output Power"), module.powerValueToString(firmware));
|
||||||
str << printLabelValue(tr("RX Output Frequency"), QString("%1Hz").arg(module.afhds3.rxFreq));
|
str << printLabelValue(tr("RX Output Frequency"), QString("%1Hz").arg(module.afhds3.rxFreq));
|
||||||
}
|
}
|
||||||
|
if (module.protocol == PULSES_GHOST) {
|
||||||
|
str << printLabelValue(tr("Raw 12 bits"), printBoolean(module.ghost.raw12bits, BOOLEAN_YN));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result = str.join(" ");
|
result = str.join(" ");
|
||||||
|
|||||||
Reference in New Issue
Block a user