diff --git a/companion/src/firmwares/sensordata.cpp b/companion/src/firmwares/sensordata.cpp index 56c2653fe..a88f3239a 100644 --- a/companion/src/firmwares/sensordata.cpp +++ b/companion/src/firmwares/sensordata.cpp @@ -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"); +} diff --git a/companion/src/firmwares/sensordata.h b/companion/src/firmwares/sensordata.h index d289e998d..8e95aa7f6 100644 --- a/companion/src/firmwares/sensordata.h +++ b/companion/src/firmwares/sensordata.h @@ -25,6 +25,8 @@ constexpr int CPN_MAX_SENSORS = 60; +class ModelData; + class SensorData { Q_DECLARE_TR_FUNCTIONS(SensorData) @@ -146,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)); } }; diff --git a/companion/src/modeledit/telemetry.cpp b/companion/src/modeledit/telemetry.cpp index 78a4c90a4..5d6a23278 100644 --- a/companion/src/modeledit/telemetry.cpp +++ b/companion/src/modeledit/telemetry.cpp @@ -680,26 +680,11 @@ void TelemetrySensorPanel::update() ui->instanceLabel->show(); ui->instance->show(); - const ModuleData& module = model->moduleData[sensor.moduleIdx]; - if (module.isPxx2Module()) { - ui->rxLabel->show(); - ui->moduleLabel->hide(); - if (module.access.receivers & (1 << sensor.rxIdx)) { - ui->rxOrMod->setText(module.access.receiverName[sensor.rxIdx]); - } - else { - // receiver does not seem to be active - ui->rxOrMod->clear(); - } - } - else { - ui->rxLabel->hide(); - ui->moduleLabel->show(); - if (sensor.moduleIdx) - ui->rxOrMod->setText(tr("Internal")); - else - ui->rxOrMod->setText(tr("External")); - } + bool is_pxx2 = model->moduleData[sensor.moduleIdx].isPxx2Module(); + ui->rxLabel->setVisible(is_pxx2); + ui->moduleLabel->setVisible(!is_pxx2); + + ui->rxOrMod->setText(sensor.getRxOrModName(model)); ui->rxOrMod->show(); ui->formula->hide(); @@ -767,14 +752,24 @@ void populateTelemetrySourcesComboBox(AutoComboBox * cb, const ModelData * model cb->clear(); if (negative) { for (int i=-CPN_MAX_SENSORS; i<0; ++i) { - if (model->sensorData[-i-1].isAvailable()) - cb->addItem(QString("-%1").arg(model->sensorData[-i-1].label), i); + const SensorData& sensor = model->sensorData[-i-1]; + if (sensor.isAvailable()) { + if (sensor.type == SensorData::TELEM_TYPE_CUSTOM) + cb->addItem(QString("-%1 (%2)").arg(sensor.label, sensor.getRxOrModName(model)), i); + else + cb->addItem(QString("-%1").arg(sensor.label), i); + } } } cb->addItem("---", 0); for (unsigned i=1; i<=CPN_MAX_SENSORS; ++i) { - if (model->sensorData[i-1].isAvailable()) - cb->addItem(model->sensorData[i-1].label, i); + const SensorData& sensor = model->sensorData[i-1]; + if (sensor.isAvailable()) { + if (sensor.type == SensorData::TELEM_TYPE_CUSTOM) + cb->addItem(QString("%1 (%2)").arg(sensor.label, sensor.getRxOrModName(model)), i); + else + cb->addItem(QString("%1").arg(sensor.label), i); + } } }