From 978e9a260c933571a1da6665fffe76a663b0627e Mon Sep 17 00:00:00 2001 From: bsongis Date: Sat, 22 Nov 2014 19:03:11 +0100 Subject: [PATCH] Partly fixes #1861 --- companion/src/eeprominterface.h | 2 +- companion/src/modeledit/telemetry.cpp | 32 ++++++++++++++++----------- companion/src/modeledit/telemetry.h | 3 +++ radio/src/myeeprom.h | 2 +- radio/src/telemetry/telemetry.cpp | 7 +++++- radio/src/telemetry/telemetry.h | 2 +- 6 files changed, 31 insertions(+), 17 deletions(-) diff --git a/companion/src/eeprominterface.h b/companion/src/eeprominterface.h index 766b51738..3875de597 100644 --- a/companion/src/eeprominterface.h +++ b/companion/src/eeprominterface.h @@ -970,7 +970,7 @@ class SensorData { unsigned int gps; unsigned int alt; - bool isAvailable() const { return type==TYPE_CALCULATED || id!=0 || instance!=0; } + bool isAvailable() const { return strlen(label) > 0; } void updateUnit(); QString unitString() const; void clear() { memset(this, 0, sizeof(SensorData)); } diff --git a/companion/src/modeledit/telemetry.cpp b/companion/src/modeledit/telemetry.cpp index daa655d5a..8cae9db5a 100644 --- a/companion/src/modeledit/telemetry.cpp +++ b/companion/src/modeledit/telemetry.cpp @@ -337,20 +337,25 @@ void TelemetryCustomScreen::populateTelemetrySourceCB(QComboBox *b, unsigned int { b->clear(); - b->addItem(RawSource(SOURCE_TYPE_NONE, 0).toString(model)); - - for (unsigned int i = 0; i < (last ? TELEMETRY_SOURCES_STATUS_COUNT : TELEMETRY_SOURCES_DISPLAY_COUNT); i++) { - b->addItem(RawSource(SOURCE_TYPE_TELEMETRY, i).toString(model)); - if (!firmware->isTelemetrySourceAvailable(i)) { - // disable item - QModelIndex index = b->model()->index(i+1, 0); - QVariant v(0); - b->model()->setData(index, v, Qt::UserRole - 1); - } + if (IS_ARM(firmware->getBoard())) { + // TODO } + else { + b->addItem(RawSource(SOURCE_TYPE_NONE, 0).toString(model)); - b->setCurrentIndex(value); - b->setMaxVisibleItems(10); + for (unsigned int i = 0; i < (last ? TELEMETRY_SOURCES_STATUS_COUNT : TELEMETRY_SOURCES_DISPLAY_COUNT); i++) { + b->addItem(RawSource(SOURCE_TYPE_TELEMETRY, i).toString(model)); + if (!firmware->isTelemetrySourceAvailable(i)) { + // disable item + QModelIndex index = b->model()->index(i+1, 0); + QVariant v(0); + b->model()->setData(index, v, Qt::UserRole - 1); + } + } + + b->setCurrentIndex(value); + b->setMaxVisibleItems(10); + } } TelemetryCustomScreen::~TelemetryCustomScreen() @@ -605,7 +610,7 @@ void TelemetrySensorPanel::on_name_editingFinished() { if (!lock) { strcpy(sensor.label, ui->name->text().toAscii()); - update(); + emit nameModified(); emit modified(); } } @@ -678,6 +683,7 @@ TelemetryPanel::TelemetryPanel(QWidget *parent, ModelData & model, GeneralSettin TelemetrySensorPanel * panel = new TelemetrySensorPanel(this, model.sensorData[i], model, generalSettings, firmware); ui->sensorsLayout->addWidget(panel); sensorPanels[i] = panel; + connect(panel, SIGNAL(nameModified()), this, SLOT(update())); } } else { diff --git a/companion/src/modeledit/telemetry.h b/companion/src/modeledit/telemetry.h index cd5797872..1e58e88b6 100644 --- a/companion/src/modeledit/telemetry.h +++ b/companion/src/modeledit/telemetry.h @@ -87,6 +87,9 @@ class TelemetrySensorPanel: public ModelPanel ~TelemetrySensorPanel(); void update(); + signals: + void nameModified(); + protected slots: void on_name_editingFinished(); void on_type_currentIndexChanged(int index); diff --git a/radio/src/myeeprom.h b/radio/src/myeeprom.h index ab929420a..9b3abed75 100644 --- a/radio/src/myeeprom.h +++ b/radio/src/myeeprom.h @@ -1240,8 +1240,8 @@ PACK(typedef struct { }; void init(const char *label, uint8_t unit=UNIT_RAW, uint8_t prec=0); void init(uint16_t id); + bool isAvailable(); int32_t getValue(int32_t value, uint8_t unit, uint8_t prec) const; - }) TelemetrySensor; #endif diff --git a/radio/src/telemetry/telemetry.cpp b/radio/src/telemetry/telemetry.cpp index a9c53eb94..e1df0bb41 100644 --- a/radio/src/telemetry/telemetry.cpp +++ b/radio/src/telemetry/telemetry.cpp @@ -445,7 +445,7 @@ int availableTelemetryIndex() { for (int index=0; index 0; +} + int32_t convertTelemetryValue(int32_t value, uint8_t unit, uint8_t prec, uint8_t destUnit, uint8_t destPrec) { for (int i=prec; i