Bsongis/issue 6798 (#6818)
* Avoid conversion of unused sensors * Allow conversion of R9M sensors * Conversion fixes in Companion
This commit is contained in:
@@ -1935,16 +1935,25 @@ class SensorField: public TransformedField {
|
||||
void afterImport() override
|
||||
{
|
||||
if (sensor.type == SensorData::TELEM_TYPE_CUSTOM) {
|
||||
sensor.id = _id;
|
||||
sensor.subid = _subid;
|
||||
if (model.moduleData[0].isPxx1Module() || model.moduleData[1].isPxx1Module())
|
||||
sensor.instance = (_instance & 0x1F) + (version <= 218 ? -1 : 0); // 5 bits instance
|
||||
else
|
||||
sensor.instance = _instance & 0x1F;
|
||||
sensor.rxIdx = (_instance >> 5) & 0x03; // 2 bits Rx idx
|
||||
sensor.moduleIdx = (_instance >> 7) & 0x1; // 1 bit module idx
|
||||
sensor.ratio = _ratio;
|
||||
sensor.offset = _offset;
|
||||
if (strlen(sensor.label) == 0) {
|
||||
sensor.clear();
|
||||
}
|
||||
else {
|
||||
sensor.id = _id;
|
||||
sensor.subid = _subid;
|
||||
if (model.moduleData[0].isPxx1Module() || model.moduleData[1].isPxx1Module()) {
|
||||
sensor.instance = (_instance & 0x1F) + (version <= 218 ? -1 : 0); // 5 bits instance
|
||||
sensor.rxIdx = 0x03; // 2 bits Rx idx
|
||||
sensor.moduleIdx = 0x01; // 1 bit module idx
|
||||
}
|
||||
else {
|
||||
sensor.instance = _instance & 0x1F;
|
||||
sensor.rxIdx = (_instance >> 5) & 0x03; // 2 bits Rx idx
|
||||
sensor.moduleIdx = (_instance >> 7) & 0x1; // 1 bit module idx
|
||||
}
|
||||
sensor.ratio = _ratio;
|
||||
sensor.offset = _offset;
|
||||
}
|
||||
}
|
||||
else {
|
||||
sensor.persistentValue = _id;
|
||||
|
||||
@@ -92,24 +92,16 @@ QString SensorData::nameToString(int index) const
|
||||
return RadioData::getElementName(tr("TELE"), index + 1, label);
|
||||
}
|
||||
|
||||
QString SensorData::getRxOrModName(const ModelData* model) const
|
||||
QString SensorData::getOrigin(const ModelData * model) const
|
||||
{
|
||||
if ((type != TELEM_TYPE_CUSTOM) || (!id && !instance))
|
||||
if (type != TELEM_TYPE_CUSTOM || !id)
|
||||
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
|
||||
const ModuleData & module = model->moduleData[moduleIdx];
|
||||
if (module.isPxx2Module() && rxIdx <= 2 && module.access.receivers & (1 << rxIdx)) {
|
||||
return QString(module.access.receiverName[rxIdx]);
|
||||
}
|
||||
else {
|
||||
return QString();
|
||||
}
|
||||
|
||||
if (moduleIdx)
|
||||
return tr("Internal");
|
||||
|
||||
return tr("External");
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ class SensorData {
|
||||
void updateUnit();
|
||||
QString unitString() const;
|
||||
QString nameToString(int index) const;
|
||||
QString getRxOrModName(const ModelData* model) const;
|
||||
QString getOrigin(const ModelData* model) const;
|
||||
void clear() { memset(this, 0, sizeof(SensorData)); }
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user