Merge pull request #6626 from opentx/raphaelcoeffic/companion-access
Companion ACCESS support
This commit is contained in:
@@ -333,14 +333,12 @@ const int Boards::getCapability(Board::Type board, Board::Capability capability)
|
||||
return 8;
|
||||
else if (IS_JUMPER_T12(board))
|
||||
return 6;
|
||||
else if (IS_TARANIS_XLITES(board))
|
||||
return 6;
|
||||
else if (IS_TARANIS_XLITE(board))
|
||||
return 6;
|
||||
else if (IS_TARANIS(board))
|
||||
return 8;
|
||||
else if (board == Board::BOARD_TARANIS_X9DP_2019)
|
||||
return 9;
|
||||
else if (IS_TARANIS(board))
|
||||
return 8;
|
||||
else if (IS_HORUS(board))
|
||||
return 10;
|
||||
else
|
||||
|
||||
@@ -585,6 +585,78 @@ class TransformedField: public DataField {
|
||||
DataField & field;
|
||||
};
|
||||
|
||||
template<class selectorT>
|
||||
class UnionField: public DataField {
|
||||
public:
|
||||
|
||||
class UnionMember {
|
||||
public:
|
||||
virtual ~UnionMember() {}
|
||||
virtual bool select(const selectorT& attr) const = 0;
|
||||
virtual DataField* getField() = 0;
|
||||
};
|
||||
|
||||
class TransformedMember: public UnionMember, public TransformedField {
|
||||
public:
|
||||
TransformedMember(DataField* parent, DataField& field):
|
||||
TransformedField(parent, field)
|
||||
{
|
||||
}
|
||||
virtual DataField* getField()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
};
|
||||
|
||||
UnionField(DataField * parent, selectorT& selectField, const char * name="Union"):
|
||||
DataField(parent, name), selectField(selectField), maxSize(0)
|
||||
{
|
||||
}
|
||||
|
||||
~UnionField() {
|
||||
foreach(UnionMember *member, members) {
|
||||
delete member;
|
||||
}
|
||||
}
|
||||
|
||||
inline void Append(UnionMember * member) {
|
||||
members.append(member);
|
||||
if (member->getField()->size() > maxSize)
|
||||
maxSize = member->getField()->size();
|
||||
}
|
||||
|
||||
virtual void ExportBits(QBitArray & output)
|
||||
{
|
||||
foreach(UnionMember *member, members) {
|
||||
if (member->select(selectField)) {
|
||||
member->getField()->ExportBits(output);
|
||||
break;
|
||||
}
|
||||
}
|
||||
output.resize(maxSize);
|
||||
}
|
||||
|
||||
virtual void ImportBits(const QBitArray & input)
|
||||
{
|
||||
foreach(UnionMember *member, members) {
|
||||
if (member->select(selectField)) {
|
||||
member->getField()->ImportBits(input);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual unsigned int size()
|
||||
{
|
||||
return maxSize;
|
||||
}
|
||||
|
||||
protected:
|
||||
selectorT& selectField;
|
||||
QList<UnionMember *> members;
|
||||
unsigned int maxSize;
|
||||
};
|
||||
|
||||
class ConversionTable {
|
||||
|
||||
public:
|
||||
|
||||
@@ -30,6 +30,20 @@ void ModuleData::convert(RadioDataConversionState & cstate)
|
||||
}
|
||||
}
|
||||
|
||||
bool ModuleData::isPxx2Module() const
|
||||
{
|
||||
switch(protocol){
|
||||
case PULSES_ACCESS_ISRM:
|
||||
case PULSES_ACCESS_R9M:
|
||||
case PULSES_ACCESS_R9M_LITE:
|
||||
case PULSES_ACCESS_R9M_LITE_PRO:
|
||||
case PULSES_XJT_LITE_X16:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
QString ModuleData::rfProtocolToString() const
|
||||
{
|
||||
switch (protocol) {
|
||||
@@ -105,11 +119,13 @@ QString ModuleData::protocolToString(unsigned protocol)
|
||||
"DIY Multiprotocol Module",
|
||||
"FrSky PXX R9M",
|
||||
"FrSky PXX R9M Lite",
|
||||
"FrSky PXX R9M Lite Pro",
|
||||
"SBUS output at VBat",
|
||||
"FrSky ACCESS ISRM",
|
||||
"FrSky ACCESS ISRM", "FrSky ACCST ISRM D16",
|
||||
"FrSky ACCESS R9M",
|
||||
"FrSky ACCESS R9M Lite",
|
||||
"FrSky ACCESS R9M Lite Pro"
|
||||
"FrSky ACCESS R9M Lite Pro",
|
||||
"FrSky XJT lite (D16)", "FrSky XJT lite (D8)", "FrSky XJT lite (LR12)"
|
||||
};
|
||||
|
||||
return CHECK_IN_ARRAY(strings, protocol);
|
||||
|
||||
@@ -48,11 +48,16 @@ enum PulsesProtocol {
|
||||
PULSES_MULTIMODULE,
|
||||
PULSES_PXX_R9M,
|
||||
PULSES_PXX_R9M_LITE,
|
||||
PULSES_PXX_R9M_LITE_PRO,
|
||||
PULSES_SBUS,
|
||||
PULSES_ACCESS_ISRM,
|
||||
PULSES_ACCST_ISRM_D16,
|
||||
PULSES_ACCESS_R9M,
|
||||
PULSES_ACCESS_R9M_LITE,
|
||||
PULSES_ACCESS_R9M_LITE_PRO,
|
||||
PULSES_XJT_LITE_X16,
|
||||
PULSES_XJT_LITE_D8,
|
||||
PULSES_XJT_LITE_LR12,
|
||||
PULSES_PROTOCOL_LAST
|
||||
};
|
||||
|
||||
@@ -128,13 +133,18 @@ enum ModuleSubtypeR9M {
|
||||
MODULE_SUBTYPE_R9M_LAST=MODULE_SUBTYPE_R9M_AUPLUS
|
||||
};
|
||||
|
||||
constexpr int PXX2_MAX_RECEIVERS_PER_MODULE = 3;
|
||||
constexpr int PXX2_LEN_RX_NAME = 8;
|
||||
|
||||
class ModuleData {
|
||||
Q_DECLARE_TR_FUNCTIONS(ModuleData)
|
||||
|
||||
public:
|
||||
ModuleData() { clear(); }
|
||||
unsigned int modelId;
|
||||
int protocol;
|
||||
unsigned int protocol; // type in datastructs.h
|
||||
int rfProtocol; // rfProtocol in datastructs.h
|
||||
|
||||
unsigned int subType;
|
||||
bool invertedSerial;
|
||||
unsigned int channelsStart;
|
||||
@@ -142,14 +152,14 @@ class ModuleData {
|
||||
unsigned int failsafeMode;
|
||||
int failsafeChannels[CPN_MAX_CHNOUT];
|
||||
|
||||
struct {
|
||||
struct PPM {
|
||||
int delay;
|
||||
bool pulsePol; // false = positive
|
||||
bool outputType; // false = open drain, true = push pull
|
||||
int frameLength;
|
||||
} ppm;
|
||||
|
||||
struct {
|
||||
struct Multi {
|
||||
unsigned int rfProtocol;
|
||||
bool autoBindMode;
|
||||
bool lowPowerMode;
|
||||
@@ -157,22 +167,22 @@ class ModuleData {
|
||||
int optionValue;
|
||||
} multi;
|
||||
|
||||
struct {
|
||||
int power; // 0 10 mW, 1 100 mW, 2 500 mW, 3 1W
|
||||
struct PXX {
|
||||
unsigned int power; // 0 10 mW, 1 100 mW, 2 500 mW, 3 1W
|
||||
bool receiver_telem_off; // false = receiver telem enabled
|
||||
bool receiver_channel_9_16; // false = pwm out 1-8, true 9-16
|
||||
bool external_antenna; // false = internal antenna, true = external antenna
|
||||
bool sport_out;
|
||||
} pxx;
|
||||
|
||||
struct {
|
||||
// unsigned int receivers;
|
||||
// char receiverName[3][8];
|
||||
char data[1 + 3 * 8];
|
||||
struct Access {
|
||||
unsigned int receivers;
|
||||
char receiverName[PXX2_MAX_RECEIVERS_PER_MODULE][PXX2_LEN_RX_NAME+1];
|
||||
} access;
|
||||
|
||||
void clear() { memset(this, 0, sizeof(ModuleData)); }
|
||||
void convert(RadioDataConversionState & cstate);
|
||||
bool isPxx2Module() const;
|
||||
QString polarityToString() const { return ppm.pulsePol ? tr("Positive") : tr("Negative"); }
|
||||
QString rfProtocolToString() const;
|
||||
QString subTypeToString(int type = -1) const;
|
||||
|
||||
@@ -1868,7 +1868,8 @@ class SensorField: public TransformedField {
|
||||
if (sensor.type == SensorData::TELEM_TYPE_CUSTOM) {
|
||||
_id = sensor.id;
|
||||
_subid = sensor.subid;
|
||||
_instance = sensor.instance;
|
||||
// keep highest 3 bits from instance (rxIdx & moduleIdx are read-only)
|
||||
_instance = (sensor.instance & 0x1F) | (_instance & 0xE0);
|
||||
_ratio = sensor.ratio;
|
||||
_offset = sensor.offset;
|
||||
}
|
||||
@@ -1891,7 +1892,9 @@ class SensorField: public TransformedField {
|
||||
if (sensor.type == SensorData::TELEM_TYPE_CUSTOM) {
|
||||
sensor.id = _id;
|
||||
sensor.subid = _subid;
|
||||
sensor.instance = _instance;
|
||||
sensor.instance = _instance & 0x1F; // 5 bits instance
|
||||
sensor.rxIdx = (_instance >> 5) & 0x03; // 2 bits Rx idx
|
||||
sensor.moduleIdx = (_instance >> 7) & 0x1; // 1 bit module idx
|
||||
sensor.ratio = _ratio;
|
||||
sensor.offset = _offset;
|
||||
}
|
||||
@@ -1939,14 +1942,238 @@ class SensorField: public TransformedField {
|
||||
int exportPpmDelay(int delay) { return (delay - 300) / 50; }
|
||||
int importPpmDelay(int delay) { return 300 + 50 * delay; }
|
||||
|
||||
class ModuleUnionField: public UnionField<unsigned int> {
|
||||
|
||||
class PPMField: public UnionField::UnionMember, public StructField {
|
||||
public:
|
||||
PPMField(DataField * parent, ModuleData::PPM& ppm):
|
||||
StructField(parent, "PPM")
|
||||
{
|
||||
Append(new ConversionField< SignedField<6> >(parent, ppm.delay, exportPpmDelay, importPpmDelay));
|
||||
Append(new BoolField<1>(parent, ppm.pulsePol));
|
||||
Append(new BoolField<1>(parent, ppm.outputType));
|
||||
Append(new SignedField<8>(parent, ppm.frameLength));
|
||||
}
|
||||
|
||||
virtual bool select(const unsigned int& attr) const
|
||||
{
|
||||
return true; // take what's left
|
||||
}
|
||||
|
||||
virtual DataField* getField()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
};
|
||||
|
||||
class MultiField: public UnionField::TransformedMember {
|
||||
public:
|
||||
MultiField(DataField * parent, ModuleData& module):
|
||||
UnionField::TransformedMember(parent, internalField),
|
||||
internalField(this, "Multi"),
|
||||
module(module),
|
||||
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.autoBindMode));
|
||||
internalField.Append(new BoolField<1>(this, multi.lowPowerMode));
|
||||
internalField.Append(new BoolField<1>(this, multi.customProto));
|
||||
internalField.Append(new SignedField<8>(this, multi.optionValue));
|
||||
}
|
||||
|
||||
virtual bool select(const unsigned int& attr) const
|
||||
{
|
||||
return attr==PULSES_MULTIMODULE;
|
||||
}
|
||||
|
||||
virtual void beforeExport()
|
||||
{
|
||||
module.rfProtocol = module.multi.rfProtocol & 0xf;
|
||||
rfProtExtra = (module.multi.rfProtocol >> 4) & 0x03;
|
||||
}
|
||||
|
||||
virtual void afterImport()
|
||||
{
|
||||
module.multi.rfProtocol =
|
||||
(rfProtExtra & 0x3) << 4 | (module.rfProtocol & 0xf);
|
||||
}
|
||||
|
||||
private:
|
||||
StructField internalField;
|
||||
ModuleData& module;
|
||||
unsigned int rfProtExtra;
|
||||
};
|
||||
|
||||
class PxxField: public UnionField::TransformedMember {
|
||||
public:
|
||||
PxxField(DataField * parent, ModuleData& module):
|
||||
UnionField::TransformedMember(parent, internalField),
|
||||
internalField(this, "Pxx"),
|
||||
module(module)
|
||||
{
|
||||
ModuleData::PXX& pxx = module.pxx;
|
||||
internalField.Append(new UnsignedField<2>(this, pxx.power));
|
||||
internalField.Append(new SpareBitsField<2>(this));
|
||||
internalField.Append(new BoolField<1>(this, pxx.receiver_telem_off));
|
||||
internalField.Append(new BoolField<1>(this, pxx.receiver_channel_9_16));
|
||||
internalField.Append(new BoolField<1>(this, pxx.external_antenna));
|
||||
internalField.Append(new BoolField<1>(this, pxx.sport_out));
|
||||
}
|
||||
|
||||
bool select(const unsigned int& attr) const {
|
||||
return attr==PULSES_PXX_XJT_X16 ||
|
||||
attr==PULSES_PXX_DJT ||
|
||||
attr==PULSES_PXX_R9M ||
|
||||
attr==PULSES_PXX_R9M_LITE;
|
||||
}
|
||||
|
||||
virtual void beforeExport()
|
||||
{
|
||||
if (module.protocol >= PULSES_PXX_XJT_X16 && module.protocol <= PULSES_PXX_XJT_LR12) {
|
||||
module.subType = module.protocol - PULSES_PXX_XJT_X16;
|
||||
}
|
||||
}
|
||||
|
||||
virtual void afterImport()
|
||||
{
|
||||
if (module.protocol == PULSES_PXX_XJT_X16) {
|
||||
module.protocol += module.subType;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
StructField internalField;
|
||||
ModuleData& module;
|
||||
};
|
||||
|
||||
class AccessField: public UnionField::TransformedMember {
|
||||
public:
|
||||
AccessField(DataField * parent, ModuleData& module):
|
||||
UnionField::TransformedMember(parent, internalField),
|
||||
internalField(this, "Access"),
|
||||
module(module)
|
||||
{
|
||||
internalField.Append(new UnsignedField<3>(this, module.access.receivers));
|
||||
internalField.Append(new SpareBitsField<5>(this));
|
||||
|
||||
for (int i=0; i<PXX2_MAX_RECEIVERS_PER_MODULE; i++)
|
||||
internalField.Append(new CharField<8>(this, receiverName[i]));
|
||||
}
|
||||
|
||||
bool select(const unsigned int& attr) const {
|
||||
return attr >= PULSES_ACCESS_ISRM && attr <= PULSES_ACCESS_R9M_LITE_PRO;
|
||||
}
|
||||
|
||||
virtual void beforeExport()
|
||||
{
|
||||
if (module.protocol == PULSES_ACCST_ISRM_D16 ||
|
||||
module.protocol == PULSES_ACCESS_ISRM) {
|
||||
module.subType = module.protocol - PULSES_ACCESS_ISRM;
|
||||
}
|
||||
for (int i=0; i<PXX2_MAX_RECEIVERS_PER_MODULE; i++) {
|
||||
for (int pos=0; pos<PXX2_LEN_RX_NAME+1; pos++) {
|
||||
|
||||
if (pos == PXX2_LEN_RX_NAME
|
||||
|| module.access.receiverName[i][pos] == '\0') {
|
||||
|
||||
memset(module.access.receiverName[i]+pos,'\0',PXX2_LEN_RX_NAME-pos);
|
||||
break;
|
||||
}
|
||||
receiverName[i][pos] = module.access.receiverName[i][pos];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual void afterImport()
|
||||
{
|
||||
if (module.protocol == PULSES_ACCESS_ISRM) {
|
||||
module.protocol += module.subType;
|
||||
}
|
||||
for (int i=0; i<PXX2_MAX_RECEIVERS_PER_MODULE; i++) {
|
||||
for (int pos=0; pos<PXX2_LEN_RX_NAME+1; pos++) {
|
||||
|
||||
if (pos == PXX2_LEN_RX_NAME || receiverName[i][pos] == ' '
|
||||
|| receiverName[i][pos] == '\0') {
|
||||
|
||||
module.access.receiverName[i][pos] = '\0';
|
||||
break;
|
||||
}
|
||||
module.access.receiverName[i][pos] = receiverName[i][pos];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
StructField internalField;
|
||||
ModuleData& module;
|
||||
char receiverName[PXX2_MAX_RECEIVERS_PER_MODULE][PXX2_LEN_RX_NAME+1];
|
||||
};
|
||||
|
||||
public:
|
||||
ModuleUnionField(DataField * parent, ModuleData & module):
|
||||
UnionField<unsigned int>(parent, module.protocol)
|
||||
{
|
||||
Append(new AccessField(parent, module));
|
||||
Append(new PxxField(parent, module));
|
||||
Append(new MultiField(parent, module));
|
||||
Append(new PPMField(parent, module.ppm));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class ModuleField: public TransformedField {
|
||||
public:
|
||||
ModuleField(DataField * parent, ModuleData & module, Board::Type board, unsigned int version):
|
||||
TransformedField(parent, internalField),
|
||||
internalField(this, "Module"),
|
||||
module(module),
|
||||
protocolsConversionTable(board)
|
||||
{
|
||||
internalField.Append(new ConversionField<UnsignedField<4> >(this, module.protocol, &protocolsConversionTable, "Protocol", DataField::tr("OpenTX doesn't accept this radio protocol")));
|
||||
internalField.Append(new SignedField<4>(this, module.rfProtocol));
|
||||
internalField.Append(new UnsignedField<8>(this, module.channelsStart));
|
||||
internalField.Append(new ConversionField<SignedField<8> >(this, module.channelsCount, -8));
|
||||
internalField.Append(new UnsignedField<4>(this, module.failsafeMode));
|
||||
internalField.Append(new UnsignedField<3>(this, module.subType));
|
||||
internalField.Append(new BoolField<1>(this, module.invertedSerial));
|
||||
if (version <= 218) {
|
||||
for (int i=0; i<32; i++) {
|
||||
internalField.Append(new SignedField<16>(this, module.failsafeChannels[i]));
|
||||
}
|
||||
}
|
||||
|
||||
internalField.Append(new ModuleUnionField(parent, module));
|
||||
}
|
||||
|
||||
virtual void beforeExport()
|
||||
{
|
||||
if (module.protocol >= PULSES_LP45 && module.protocol <= PULSES_DSMX) {
|
||||
module.rfProtocol = module.protocol - PULSES_LP45;
|
||||
}
|
||||
}
|
||||
|
||||
virtual void afterImport()
|
||||
{
|
||||
if (module.protocol == PULSES_LP45) {
|
||||
module.protocol += module.rfProtocol;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
StructField internalField;
|
||||
ModuleData& module;
|
||||
ProtocolsConversionTable protocolsConversionTable;
|
||||
};
|
||||
|
||||
OpenTxModelData::OpenTxModelData(ModelData & modelData, Board::Type board, unsigned int version, unsigned int variant):
|
||||
TransformedField(nullptr, internalField),
|
||||
internalField(this, "ModelData"),
|
||||
modelData(modelData),
|
||||
board(board),
|
||||
version(version),
|
||||
variant(variant),
|
||||
protocolsConversionTable(board)
|
||||
variant(variant)
|
||||
{
|
||||
sprintf(name, "Model %s", modelData.name);
|
||||
|
||||
@@ -2094,26 +2321,8 @@ OpenTxModelData::OpenTxModelData(ModelData & modelData, Board::Type board, unsig
|
||||
|
||||
int modulesCount = (version <= 218 ? 3 : 2);
|
||||
for (int module=0; module<modulesCount; module++) {
|
||||
internalField.Append(new ConversionField<SignedField<4> >(this, modelData.moduleData[module].protocol, &protocolsConversionTable, "Protocol", DataField::tr("OpenTX doesn't accept this radio protocol")));
|
||||
internalField.Append(new SignedField<4>(this, subprotocols[module]));
|
||||
internalField.Append(new UnsignedField<8>(this, modelData.moduleData[module].channelsStart));
|
||||
internalField.Append(new ConversionField<SignedField<8> >(this, modelData.moduleData[module].channelsCount, -8));
|
||||
internalField.Append(new UnsignedField<4>(this, modelData.moduleData[module].failsafeMode));
|
||||
internalField.Append(new UnsignedField<3>(this, modelData.moduleData[module].subType));
|
||||
internalField.Append(new BoolField<1>(this, modelData.moduleData[module].invertedSerial));
|
||||
if (version <= 218) {
|
||||
for (int i=0; i<32; i++) {
|
||||
internalField.Append(new SignedField<16>(this, modelData.moduleData[module].failsafeChannels[i]));
|
||||
}
|
||||
}
|
||||
internalField.Append(new ConversionField< SignedField<6> >(this, modelData.moduleData[module].ppm.delay, exportPpmDelay, importPpmDelay));
|
||||
internalField.Append(new BoolField<1>(this, modelData.moduleData[module].ppm.pulsePol));
|
||||
internalField.Append(new BoolField<1>(this, modelData.moduleData[module].ppm.outputType));
|
||||
internalField.Append(new SignedField<8>(this, modelData.moduleData[module].ppm.frameLength));
|
||||
if (version >= 219) {
|
||||
// TODO ACCESS
|
||||
internalField.Append(new CharField<1 + 3 * 8 - 2>(this, modelData.moduleData[module].access.data));
|
||||
}
|
||||
|
||||
internalField.Append(new ModuleField(this, modelData.moduleData[module], board, version));
|
||||
}
|
||||
|
||||
if (version >= 219) {
|
||||
@@ -2221,35 +2430,6 @@ void OpenTxModelData::beforeExport()
|
||||
// qDebug() << QString("before export model") << modelData.name;
|
||||
|
||||
for (int module=0; module<2; module++) {
|
||||
if ((modelData.moduleData[module].protocol >= PULSES_PXX_XJT_X16 && modelData.moduleData[module].protocol <= PULSES_PXX_XJT_LR12) ||
|
||||
modelData.moduleData[module].protocol == PULSES_PXX_R9M) {
|
||||
if (modelData.moduleData[module].protocol != PULSES_PXX_R9M) {
|
||||
subprotocols[module] = modelData.moduleData[module].protocol - PULSES_PXX_XJT_X16;
|
||||
}
|
||||
int pxxByte = (modelData.moduleData[module].pxx.power & 0x03)
|
||||
| modelData.moduleData[module].pxx.receiver_telem_off << 4
|
||||
| modelData.moduleData[module].pxx.receiver_channel_9_16 << 5;
|
||||
modelData.moduleData[module].ppm.delay = 300 + 50 * pxxByte;
|
||||
modelData.moduleData[module].ppm.pulsePol = modelData.moduleData[module].pxx.external_antenna;
|
||||
modelData.moduleData[module].ppm.outputType = modelData.moduleData[module].pxx.sport_out;
|
||||
|
||||
}
|
||||
else if (modelData.moduleData[module].protocol >= PULSES_LP45 && modelData.moduleData[module].protocol <= PULSES_DSMX) {
|
||||
subprotocols[module] = modelData.moduleData[module].protocol - PULSES_LP45;
|
||||
}
|
||||
else if (modelData.moduleData[module].protocol == PULSES_MULTIMODULE) {
|
||||
// copy multi settings to ppm settings to get them written to the eeprom
|
||||
// (reverse the int => ms logic of the ppm delay) since only ppm is written
|
||||
subprotocols[module] = modelData.moduleData[module].multi.rfProtocol & (0x1f);
|
||||
int multiByte = ((modelData.moduleData[module].multi.rfProtocol >> 4) & 0x03) | (modelData.moduleData[module].multi.customProto << 7);
|
||||
modelData.moduleData[module].ppm.delay = 300 + 50 * multiByte;
|
||||
modelData.moduleData[module].ppm.frameLength = modelData.moduleData[module].multi.optionValue;
|
||||
modelData.moduleData[module].ppm.outputType = modelData.moduleData[module].multi.lowPowerMode;
|
||||
modelData.moduleData[module].ppm.pulsePol = modelData.moduleData[module].multi.autoBindMode;
|
||||
}
|
||||
else {
|
||||
subprotocols[module] = (module == 0 ? -1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (IS_HORUS(board)) {
|
||||
@@ -2268,39 +2448,11 @@ void OpenTxModelData::afterImport()
|
||||
{
|
||||
qCDebug(eepromImport) << QString("OpenTxModelData::afterImport()") << modelData.name;
|
||||
|
||||
// ??? what's this ???
|
||||
if (IS_HORUS(board)) {
|
||||
modelData.moduleData[0].protocol = PULSES_PXX_XJT_X16;
|
||||
}
|
||||
|
||||
for (int module=0; module<2; module++) {
|
||||
if (modelData.moduleData[module].protocol == PULSES_PXX_XJT_X16 || modelData.moduleData[module].protocol == PULSES_LP45) {
|
||||
if (subprotocols[module] >= 0)
|
||||
modelData.moduleData[module].protocol += subprotocols[module];
|
||||
else
|
||||
modelData.moduleData[module].protocol = PULSES_OFF;
|
||||
}
|
||||
else if (modelData.moduleData[module].protocol == PULSES_MULTIMODULE) {
|
||||
// Copy data from ppm struct to multi struct
|
||||
auto multiByte = (unsigned int)((modelData.moduleData[module].ppm.delay - 300) / 50);
|
||||
modelData.moduleData[module].multi.rfProtocol = (subprotocols[module] & 0x0f) | ((multiByte & 0x3) << 4);
|
||||
modelData.moduleData[module].multi.customProto = (multiByte & 0x80) == 0x80;
|
||||
modelData.moduleData[module].multi.optionValue = modelData.moduleData[module].ppm.frameLength;
|
||||
modelData.moduleData[module].multi.lowPowerMode = modelData.moduleData[module].ppm.outputType;
|
||||
modelData.moduleData[module].multi.autoBindMode = modelData.moduleData[module].ppm.pulsePol;
|
||||
}
|
||||
|
||||
if ((modelData.moduleData[module].protocol >= PULSES_PXX_XJT_X16 && modelData.moduleData[module].protocol <= PULSES_PXX_XJT_LR12) ||
|
||||
modelData.moduleData[module].protocol == PULSES_PXX_R9M) {
|
||||
// Do the same for pxx
|
||||
auto pxxByte = (unsigned int)((modelData.moduleData[module].ppm.delay - 300) / 50);
|
||||
modelData.moduleData[module].pxx.power = pxxByte & 0x03;
|
||||
modelData.moduleData[module].pxx.receiver_telem_off = static_cast<bool>(pxxByte & (1 << 4));
|
||||
modelData.moduleData[module].pxx.receiver_channel_9_16 = static_cast<bool>(pxxByte & (1 << 5));
|
||||
modelData.moduleData[module].pxx.sport_out = modelData.moduleData[module].ppm.outputType;
|
||||
modelData.moduleData[module].pxx.external_antenna = modelData.moduleData[module].ppm.pulsePol;
|
||||
}
|
||||
}
|
||||
|
||||
if (IS_HORUS(board)) {
|
||||
uint32_t newSwitchWarningStates = 0;
|
||||
for (int i = 0; i < MAX_SWITCHES(board, version); i++) {
|
||||
@@ -2472,13 +2624,17 @@ OpenTxGeneralData::OpenTxGeneralData(GeneralSettings & generalData, Board::Type
|
||||
internalField.Append(new ArmCustomFunctionField(this, generalData.customFn[i], board, version, variant));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (IS_STM32(board)) {
|
||||
if (version >= 218) {
|
||||
internalField.Append(new UnsignedField<4>(this, generalData.hw_uartMode));
|
||||
// not on Horus...
|
||||
for (uint8_t i=0; i<4; i++) {
|
||||
internalField.Append(new UnsignedField<1>(this, generalData.sliderConfig[i]));
|
||||
if (!IS_HORUS(board)) {
|
||||
for (uint8_t i=0; i<4; i++) {
|
||||
internalField.Append(new UnsignedField<1>(this, generalData.sliderConfig[i]));
|
||||
}
|
||||
}
|
||||
else {
|
||||
internalField.Append(new SpareBitsField<4>(this));
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -2536,6 +2692,8 @@ OpenTxGeneralData::OpenTxGeneralData(GeneralSettings & generalData, Board::Type
|
||||
|
||||
if (IS_TARANIS_X9E(board))
|
||||
internalField.Append(new SpareBitsField<64>(this)); // switchUnlockStates
|
||||
else if (IS_TARANIS_X9D(board))
|
||||
internalField.Append(new SpareBitsField<32>(this)); // switchUnlockStates
|
||||
else if (IS_TARANIS(board))
|
||||
internalField.Append(new SpareBitsField<16>(this)); // switchUnlockStates
|
||||
|
||||
@@ -2590,7 +2748,7 @@ OpenTxGeneralData::OpenTxGeneralData(GeneralSettings & generalData, Board::Type
|
||||
internalField.Append(new UnsignedField<7>(this, generalData.backlightOffBright));
|
||||
internalField.Append(new ZCharField<10>(this, generalData.bluetoothName, "Bluetooth name"));
|
||||
}
|
||||
else if (IS_TARANIS_X9E(board) || (version >= 219 && (IS_TARANIS_X7(board) || IS_TARANIS_XLITE(board) || IS_TARANIS_XLITES(board)))) {
|
||||
else if (IS_TARANIS_X9E(board) || (version >= 219 && (IS_TARANIS_X7(board) || IS_TARANIS_X9D(board) || IS_TARANIS_XLITE(board)))) {
|
||||
internalField.Append(new SpareBitsField<8>(this));
|
||||
internalField.Append(new ZCharField<10>(this, generalData.bluetoothName, "Bluetooth name"));
|
||||
}
|
||||
|
||||
@@ -83,7 +83,8 @@ class ProtocolsConversionTable: public ConversionTable
|
||||
addConversion(PULSES_PXX_XJT_D8, val);
|
||||
addConversion(PULSES_PXX_XJT_LR12, val++);
|
||||
|
||||
addConversion(PULSES_ACCESS_ISRM, val++);
|
||||
addConversion(PULSES_ACCESS_ISRM, val);
|
||||
addConversion(PULSES_ACCST_ISRM_D16, val++);
|
||||
|
||||
addConversion(PULSES_LP45, val);
|
||||
addConversion(PULSES_DSM2, val);
|
||||
@@ -96,9 +97,14 @@ class ProtocolsConversionTable: public ConversionTable
|
||||
addConversion(PULSES_ACCESS_R9M, val++);
|
||||
addConversion(PULSES_PXX_R9M_LITE, val++);
|
||||
addConversion(PULSES_ACCESS_R9M_LITE, val++);
|
||||
addConversion(PULSES_PXX_R9M_LITE_PRO, val++);
|
||||
addConversion(PULSES_ACCESS_R9M_LITE_PRO, val++);
|
||||
|
||||
addConversion(PULSES_SBUS, val++);
|
||||
|
||||
addConversion(PULSES_XJT_LITE_X16, val);
|
||||
addConversion(PULSES_XJT_LITE_D8, val);
|
||||
addConversion(PULSES_XJT_LITE_LR12, val++);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -141,7 +147,6 @@ class OpenTxModelData: public TransformedField {
|
||||
unsigned int variant;
|
||||
char name[256];
|
||||
int subprotocols[CPN_MAX_MODULES+1/*trainer*/];
|
||||
ProtocolsConversionTable protocolsConversionTable;
|
||||
ChannelsConversionTable channelsConversionTable;
|
||||
QStringList _errors;
|
||||
};
|
||||
|
||||
@@ -772,11 +772,12 @@ int OpenTxFirmware::isAvailable(PulsesProtocol proto, int port)
|
||||
case PULSES_PPM:
|
||||
return id.contains("internalppm") ? 1 : 0;
|
||||
case PULSES_ACCESS_ISRM:
|
||||
case PULSES_ACCST_ISRM_D16:
|
||||
return (IS_TARANIS_XLITES(board) || IS_TARANIS_X9LITE(board)) ? 1 : 0;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
case 1:
|
||||
switch (proto) {
|
||||
case PULSES_OFF:
|
||||
@@ -802,6 +803,10 @@ int OpenTxFirmware::isAvailable(PulsesProtocol proto, int port)
|
||||
case PULSES_ACCESS_R9M_LITE:
|
||||
case PULSES_ACCESS_R9M_LITE_PRO:
|
||||
return (IS_TARANIS_XLITES(board) || IS_TARANIS_X9LITE(board)) ? 1 : 0;
|
||||
case PULSES_XJT_LITE_X16:
|
||||
case PULSES_XJT_LITE_D8:
|
||||
case PULSES_XJT_LITE_LR12:
|
||||
return (IS_TARANIS_XLITES(board) || IS_TARANIS_X9LITE(board)) ? 1 : 0;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "sensordata.h"
|
||||
|
||||
#include "radiodata.h"
|
||||
#include "modeldata.h"
|
||||
|
||||
void SensorData::updateUnit()
|
||||
{
|
||||
@@ -90,3 +91,25 @@ QString SensorData::nameToString(int index) const
|
||||
{
|
||||
return RadioData::getElementName(tr("TELE"), index + 1, label);
|
||||
}
|
||||
|
||||
QString SensorData::getRxOrModName(const ModelData* model) const
|
||||
{
|
||||
if ((type != TELEM_TYPE_CUSTOM) || (!id && !instance))
|
||||
return QString();
|
||||
|
||||
const ModuleData& module = model->moduleData[moduleIdx];
|
||||
|
||||
if (module.isPxx2Module()) {
|
||||
if (module.access.receivers & (1 << rxIdx)) {
|
||||
return QString(module.access.receiverName[rxIdx]);
|
||||
}
|
||||
|
||||
// receiver does not seem to be active
|
||||
return QString();
|
||||
}
|
||||
|
||||
if (moduleIdx)
|
||||
return tr("Internal");
|
||||
|
||||
return tr("External");
|
||||
}
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
|
||||
constexpr int CPN_MAX_SENSORS = 60;
|
||||
|
||||
class ModelData;
|
||||
|
||||
class SensorData {
|
||||
Q_DECLARE_TR_FUNCTIONS(SensorData)
|
||||
|
||||
@@ -111,6 +113,8 @@ class SensorData {
|
||||
unsigned int id;
|
||||
unsigned int subid;
|
||||
unsigned int instance;
|
||||
unsigned int rxIdx;
|
||||
unsigned int moduleIdx;
|
||||
unsigned int persistentValue;
|
||||
unsigned int formula;
|
||||
char label[4+1];
|
||||
@@ -144,6 +148,7 @@ class SensorData {
|
||||
void updateUnit();
|
||||
QString unitString() const;
|
||||
QString nameToString(int index) const;
|
||||
QString getRxOrModName(const ModelData* model) const;
|
||||
void clear() { memset(this, 0, sizeof(SensorData)); }
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user