display receiver or module name for each sensor (if available)
This commit is contained in:
@@ -21,6 +21,7 @@
|
|||||||
#include "sensordata.h"
|
#include "sensordata.h"
|
||||||
|
|
||||||
#include "radiodata.h"
|
#include "radiodata.h"
|
||||||
|
#include "modeldata.h"
|
||||||
|
|
||||||
void SensorData::updateUnit()
|
void SensorData::updateUnit()
|
||||||
{
|
{
|
||||||
@@ -90,3 +91,25 @@ QString SensorData::nameToString(int index) const
|
|||||||
{
|
{
|
||||||
return RadioData::getElementName(tr("TELE"), index + 1, label);
|
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;
|
constexpr int CPN_MAX_SENSORS = 60;
|
||||||
|
|
||||||
|
class ModelData;
|
||||||
|
|
||||||
class SensorData {
|
class SensorData {
|
||||||
Q_DECLARE_TR_FUNCTIONS(SensorData)
|
Q_DECLARE_TR_FUNCTIONS(SensorData)
|
||||||
|
|
||||||
@@ -146,6 +148,7 @@ class SensorData {
|
|||||||
void updateUnit();
|
void updateUnit();
|
||||||
QString unitString() const;
|
QString unitString() const;
|
||||||
QString nameToString(int index) const;
|
QString nameToString(int index) const;
|
||||||
|
QString getRxOrModName(const ModelData* model) const;
|
||||||
void clear() { memset(this, 0, sizeof(SensorData)); }
|
void clear() { memset(this, 0, sizeof(SensorData)); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -680,26 +680,11 @@ void TelemetrySensorPanel::update()
|
|||||||
ui->instanceLabel->show();
|
ui->instanceLabel->show();
|
||||||
ui->instance->show();
|
ui->instance->show();
|
||||||
|
|
||||||
const ModuleData& module = model->moduleData[sensor.moduleIdx];
|
bool is_pxx2 = model->moduleData[sensor.moduleIdx].isPxx2Module();
|
||||||
if (module.isPxx2Module()) {
|
ui->rxLabel->setVisible(is_pxx2);
|
||||||
ui->rxLabel->show();
|
ui->moduleLabel->setVisible(!is_pxx2);
|
||||||
ui->moduleLabel->hide();
|
|
||||||
if (module.access.receivers & (1 << sensor.rxIdx)) {
|
ui->rxOrMod->setText(sensor.getRxOrModName(model));
|
||||||
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"));
|
|
||||||
}
|
|
||||||
ui->rxOrMod->show();
|
ui->rxOrMod->show();
|
||||||
|
|
||||||
ui->formula->hide();
|
ui->formula->hide();
|
||||||
@@ -767,14 +752,24 @@ void populateTelemetrySourcesComboBox(AutoComboBox * cb, const ModelData * model
|
|||||||
cb->clear();
|
cb->clear();
|
||||||
if (negative) {
|
if (negative) {
|
||||||
for (int i=-CPN_MAX_SENSORS; i<0; ++i) {
|
for (int i=-CPN_MAX_SENSORS; i<0; ++i) {
|
||||||
if (model->sensorData[-i-1].isAvailable())
|
const SensorData& sensor = model->sensorData[-i-1];
|
||||||
cb->addItem(QString("-%1").arg(model->sensorData[-i-1].label), i);
|
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);
|
cb->addItem("---", 0);
|
||||||
for (unsigned i=1; i<=CPN_MAX_SENSORS; ++i) {
|
for (unsigned i=1; i<=CPN_MAX_SENSORS; ++i) {
|
||||||
if (model->sensorData[i-1].isAvailable())
|
const SensorData& sensor = model->sensorData[i-1];
|
||||||
cb->addItem(model->sensorData[i-1].label, i);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user