From 6c86cada2ca6f8d273eb6f7967659e90ac98fd3c Mon Sep 17 00:00:00 2001 From: bsongis Date: Thu, 19 Jun 2014 07:21:58 +0200 Subject: [PATCH 01/10] Bad initialization of weight in the MixerDialog (when no GVars) --- companion/src/helpers.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/companion/src/helpers.cpp b/companion/src/helpers.cpp index f82abc21f..b78ae41e5 100644 --- a/companion/src/helpers.cpp +++ b/companion/src/helpers.cpp @@ -158,7 +158,7 @@ GVarGroup::GVarGroup(QCheckBox *weightGV, QSpinBox *weightSB, QComboBox *weightC } else { weightGV->hide(); - if (weight > maxi || weight < -mini) { + if (weight > maxi || weight < mini) { weight = deflt; } } From 79abc49a6c6c41cddfe4284ba3b9b4bafcd8fa37 Mon Sep 17 00:00:00 2001 From: bsongis Date: Thu, 19 Jun 2014 10:10:54 +0200 Subject: [PATCH 02/10] Update of bars source when the telemetry protocol changes --- companion/src/modeledit/telemetry.cpp | 32 +++++++++++++++------------ companion/src/modeledit/telemetry.h | 1 + 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/companion/src/modeledit/telemetry.cpp b/companion/src/modeledit/telemetry.cpp index 9a42349dd..e5048772a 100644 --- a/companion/src/modeledit/telemetry.cpp +++ b/companion/src/modeledit/telemetry.cpp @@ -168,7 +168,8 @@ void TelemetryAnalog::on_RatioSB_editingFinished() if (calib<0) { if (calib<((ratio*-128)/255)) { analog.offset=-128; - } else { + } + else { analog.offset=round(calib*255/ratio); } } @@ -294,7 +295,6 @@ TelemetryCustomScreen::TelemetryCustomScreen(QWidget *parent, ModelData & model, for (int c=0; cgetCapability(TelemetryCustomScreensFieldsPerLine); c++) { fieldsCB[l][c] = new QComboBox(this); fieldsCB[l][c]->setProperty("index", c + (l<<8)); - populateTelemetrySourceCB(fieldsCB[l][c], screen.body.lines[l].source[c], l==3, model.frsky.usrProto); ui->screenNumsLayout->addWidget(fieldsCB[l][c], l, c, 1, 1); connect(fieldsCB[l][c], SIGNAL(currentIndexChanged(int)), this, SLOT(customFieldChanged(int))); } @@ -303,7 +303,6 @@ TelemetryCustomScreen::TelemetryCustomScreen(QWidget *parent, ModelData & model, for (int l=0; l<4; l++) { barsCB[l] = new QComboBox(this); barsCB[l]->setProperty("index", l); - populateTelemetrySourceCB(barsCB[l], screen.body.bars[l].source, false, model.frsky.usrProto); connect(barsCB[l], SIGNAL(currentIndexChanged(int)), this, SLOT(barSourceChanged(int))); ui->screenBarsLayout->addWidget(barsCB[l], l, 0, 1, 1); @@ -375,6 +374,16 @@ void TelemetryCustomScreen::update() ui->screenNums->setVisible(screen.type == 0); ui->screenBars->setVisible(screen.type != 0); + for (int l=0; l<4; l++) { + for (int c=0; cgetCapability(TelemetryCustomScreensFieldsPerLine); c++) { + populateTelemetrySourceCB(fieldsCB[l][c], screen.body.lines[l].source[c], l==3, model.frsky.usrProto); + } + } + + for (int l=0; l<4; l++) { + populateTelemetrySourceCB(barsCB[l], screen.body.bars[l].source, false, model.frsky.usrProto); + } + if (screen.type == 0) { for (int l=0; l<4; l++) { for (int c=0; cgetCapability(TelemetryCustomScreensFieldsPerLine); c++) { @@ -519,6 +528,7 @@ TelemetryPanel::TelemetryPanel(QWidget *parent, ModelData & model, GeneralSettin for (int i=0; igetCapability(TelemetryCustomScreens); i++) { TelemetryCustomScreen * tab = new TelemetryCustomScreen(this, model, model.frsky.screens[i], generalSettings, firmware); ui->customScreens->addTab(tab, tr("Telemetry screen %1").arg(i+1)); + telemetryCustomScreens[i] = tab; } if (IS_ARM(GetEepromInterface()->getBoard())) { @@ -606,16 +616,8 @@ void TelemetryPanel::setup() } } - if (!(firmware->getCapability(HasAltitudeSel)||firmware->getCapability(HasVario))) { - ui->altimetryGB->hide(); - } - - if (firmware->getCapability(NoTelemetryProtocol)) { - ui->frskyProtoCB->setDisabled(true); - } - else { - ui->frskyProtoCB->setEnabled(true); - } + ui->altimetryGB->setVisible(firmware->getCapability(HasAltitudeSel) || firmware->getCapability(HasVario)), + ui->frskyProtoCB->setDisabled(firmware->getCapability(NoTelemetryProtocol)); if (!firmware->getCapability(TelemetryUnits)) { ui->frskyUnitsCB->setDisabled(true); @@ -626,7 +628,7 @@ void TelemetryPanel::setup() ui->frskyUnitsCB->setCurrentIndex(index); } - if ((firmware->getCapability(Telemetry)&TM_HASWSHH)) { + if (firmware->getCapability(Telemetry) & TM_HASWSHH) { ui->frskyProtoCB->addItem(tr("Winged Shadow How High")); } else { @@ -740,6 +742,8 @@ void TelemetryPanel::on_bladesCount_editingFinished() void TelemetryPanel::on_frskyProtoCB_currentIndexChanged(int index) { model.frsky.usrProto = index; + for (int i=0; igetCapability(TelemetryCustomScreens); i++) + telemetryCustomScreens[i]->update(); emit modified(); } diff --git a/companion/src/modeledit/telemetry.h b/companion/src/modeledit/telemetry.h index 6694ae319..8cecffc7d 100644 --- a/companion/src/modeledit/telemetry.h +++ b/companion/src/modeledit/telemetry.h @@ -106,6 +106,7 @@ class TelemetryPanel : public ModelPanel private: Ui::Telemetry *ui; TelemetryAnalog * analogs[4]; + TelemetryCustomScreen * telemetryCustomScreens[4]; void setup(); void telBarUpdate(); From 1560fa8bd9cd2793632d99763e12e3079521a1af Mon Sep 17 00:00:00 2001 From: bsongis Date: Thu, 19 Jun 2014 10:13:11 +0200 Subject: [PATCH 03/10] Companion bug in speed values (Logical Switches) --- companion/src/eeprominterface.cpp | 16 ++++++++++++---- companion/src/eeprominterface.h | 2 +- companion/src/firmwares/opentx/opentxeeprom.cpp | 4 ++-- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/companion/src/eeprominterface.cpp b/companion/src/eeprominterface.cpp index c0c745001..fd4804dd6 100644 --- a/companion/src/eeprominterface.cpp +++ b/companion/src/eeprominterface.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "eeprominterface.h" #include "firmwares/er9x/er9xinterface.h" #include "firmwares/th9x/th9xinterface.h" @@ -103,6 +104,10 @@ RawSourceRange RawSource::getRange(bool singleprec) switch (type) { case SOURCE_TYPE_TELEMETRY: + if (singleprec) { + result.offset = -DBL_MAX; + } + switch (index) { case TELEMETRY_SOURCE_TX_BATT: result.step = 0.1; @@ -165,10 +170,12 @@ RawSourceRange RawSource::getRange(bool singleprec) case TELEMETRY_SOURCE_FUEL: result.max = 100; break; + case TELEMETRY_SOURCE_ASPEED: + case TELEMETRY_SOURCE_ASPEED_MAX: case TELEMETRY_SOURCE_SPEED: case TELEMETRY_SOURCE_SPEED_MAX: - result.step = singleprec ? 4 : 1; - result.max = singleprec ? (4*236) : 2000; + result.step = singleprec ? 1 : 1; + result.max = singleprec ? (1*255) : 2000; if (model && !model->frsky.imperial) { result.step *= 1.852; result.max *= 1.852; @@ -225,14 +232,15 @@ RawSourceRange RawSource::getRange(bool singleprec) result.max = 125; break; } - if (singleprec && !result.offset) { + + if (singleprec && result.offset==-DBL_MAX) { result.offset = result.max - (127*result.step); } break; default: result.max = (model && model->extendedLimits ? 125 : 100); - result.min = - result.max; + result.min = -result.max; break; } diff --git a/companion/src/eeprominterface.h b/companion/src/eeprominterface.h index a4ceddde4..ea7aed2cb 100644 --- a/companion/src/eeprominterface.h +++ b/companion/src/eeprominterface.h @@ -252,7 +252,7 @@ enum TelemetrySource { TELEMETRY_SOURCE_ACCZ, TELEMETRY_SOURCE_HDG, TELEMETRY_SOURCE_VERTICAL_SPEED, - TELEMETRY_SOURCE_ASPD, + TELEMETRY_SOURCE_ASPEED, TELEMETRY_SOURCE_DTE, TELEMETRY_SOURCE_A1_MIN, TELEMETRY_SOURCE_A2_MIN, diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index c42e80483..dd4dd8f3b 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -260,7 +260,7 @@ class SourcesConversionTable: public ConversionTable { for (int i=0; i= 216) { - addConversion(1+TELEMETRY_SOURCE_ASPD, val++); + addConversion(1+TELEMETRY_SOURCE_ASPEED, val++); addConversion(1+TELEMETRY_SOURCE_DTE, val++); } if (IS_ARM(board) && version >= 216) { From 36395862d126ebc48f17e82aa485cf41a4eaaa16 Mon Sep 17 00:00:00 2001 From: bsongis Date: Thu, 19 Jun 2014 10:19:52 +0200 Subject: [PATCH 04/10] Fixes #1311 --- companion/src/eeprominterface.cpp | 4 ++-- companion/src/modeledit/logicalswitches.cpp | 2 +- radio/src/opentx.cpp | 4 ++++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/companion/src/eeprominterface.cpp b/companion/src/eeprominterface.cpp index fd4804dd6..3d99fd0c5 100644 --- a/companion/src/eeprominterface.cpp +++ b/companion/src/eeprominterface.cpp @@ -174,8 +174,8 @@ RawSourceRange RawSource::getRange(bool singleprec) case TELEMETRY_SOURCE_ASPEED_MAX: case TELEMETRY_SOURCE_SPEED: case TELEMETRY_SOURCE_SPEED_MAX: - result.step = singleprec ? 1 : 1; - result.max = singleprec ? (1*255) : 2000; + result.step = singleprec ? 2 : 1; + result.max = singleprec ? (2*255) : 2000; if (model && !model->frsky.imperial) { result.step *= 1.852; result.max *= 1.852; diff --git a/companion/src/modeledit/logicalswitches.cpp b/companion/src/modeledit/logicalswitches.cpp index efe84b594..cae87ffce 100644 --- a/companion/src/modeledit/logicalswitches.cpp +++ b/companion/src/modeledit/logicalswitches.cpp @@ -230,7 +230,7 @@ void LogicalSwitchesPanel::edited() } else { model.customSw[i].val2 = round((value-range.offset)/range.step);; - value= model.customSw[i].val2*range.step + range.offset; + value = model.customSw[i].val2*range.step + range.offset; } if (source.isTimeBased()) cswitchTOffset[i]->setTime(QTimeS(value)); else cswitchOffset[i]->setValue(value); diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index 39a513e88..fbe4011f6 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -813,6 +813,10 @@ getvalue_t convert8bitsTelemValue(uint8_t channel, ls_telemetry_value_t value) break; case TELEM_CELL: case TELEM_HDG: + case TELEM_ASPEED: + case TELEM_MAX_ASPEED: + case TELEM_SPEED: + case TELEM_MAX_SPEED: result = value * 2; break; case TELEM_DIST: From 6ef4134b2d559b4192d8e7b31ed4c158858c0ad3 Mon Sep 17 00:00:00 2001 From: bsongis Date: Thu, 19 Jun 2014 10:55:23 +0200 Subject: [PATCH 05/10] Display of an unit in Logical Switches --- companion/src/eeprominterface.cpp | 19 +++++++++++++++++++ companion/src/eeprominterface.h | 2 +- companion/src/modeledit/logicalswitches.cpp | 15 +++++++++++---- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/companion/src/eeprominterface.cpp b/companion/src/eeprominterface.cpp index 3d99fd0c5..6305540e2 100644 --- a/companion/src/eeprominterface.cpp +++ b/companion/src/eeprominterface.cpp @@ -113,6 +113,7 @@ RawSourceRange RawSource::getRange(bool singleprec) result.step = 0.1; result.decimals = 1; result.max = 25.5; + result.unit = QObject::tr("V"); break; case TELEMETRY_SOURCE_TX_TIME: result.step = 1; @@ -122,6 +123,7 @@ RawSourceRange RawSource::getRange(bool singleprec) case TELEMETRY_SOURCE_TIMER2: result.step = singleprec ? 5 : 1; result.max = singleprec ? 255*5 : 60*60; + result.unit = QObject::tr("s"); break; case TELEMETRY_SOURCE_RSSI_TX: case TELEMETRY_SOURCE_RSSI_RX: @@ -142,6 +144,7 @@ RawSourceRange RawSource::getRange(bool singleprec) result.step = ratio / 255; result.min = channel.offset * result.step; result.max = ratio + result.min; + result.unit = QObject::tr("V"); } break; case TELEMETRY_SOURCE_ALT: @@ -149,6 +152,7 @@ RawSourceRange RawSource::getRange(bool singleprec) result.step = singleprec ? 8 : 1; result.min = -500; result.max = singleprec ? 1540 : 3000; + result.unit = QObject::tr("m"); break; case TELEMETRY_SOURCE_T1: case TELEMETRY_SOURCE_T1_MAX: @@ -156,11 +160,13 @@ RawSourceRange RawSource::getRange(bool singleprec) case TELEMETRY_SOURCE_T2_MAX: result.min = -30; result.max = 225; + result.unit = QObject::tr("°C"); break; case TELEMETRY_SOURCE_HDG: result.step = singleprec ? 2 : 1; result.max = 360; if (singleprec) result.offset = 256; + result.unit = QObject::tr("°"); break; case TELEMETRY_SOURCE_RPM: case TELEMETRY_SOURCE_RPM_MAX: @@ -169,6 +175,7 @@ RawSourceRange RawSource::getRange(bool singleprec) break; case TELEMETRY_SOURCE_FUEL: result.max = 100; + result.unit = QObject::tr("%"); break; case TELEMETRY_SOURCE_ASPEED: case TELEMETRY_SOURCE_ASPEED_MAX: @@ -179,6 +186,10 @@ RawSourceRange RawSource::getRange(bool singleprec) if (model && !model->frsky.imperial) { result.step *= 1.852; result.max *= 1.852; + result.unit = QObject::tr("km/h"); + } + else { + result.unit = QObject::tr("MPH"); } break; case TELEMETRY_SOURCE_VERTICAL_SPEED: @@ -186,17 +197,20 @@ RawSourceRange RawSource::getRange(bool singleprec) result.min = -12.5; result.max = 13.0; result.decimals = 1; + result.unit = QObject::tr("m/s"); break; case TELEMETRY_SOURCE_DIST: case TELEMETRY_SOURCE_DIST_MAX: result.step = singleprec ? 8 : 1; result.max = singleprec ? 2040 : 10000; + result.unit = QObject::tr("m"); break; case TELEMETRY_SOURCE_CELL: case TELEMETRY_SOURCE_CELL_MIN: result.step = singleprec ? 0.02 : 0.01; result.max = 5.1; result.decimals = 2; + result.unit = QObject::tr("V"); break; case TELEMETRY_SOURCE_CELLS_SUM: case TELEMETRY_SOURCE_CELLS_MIN: @@ -205,21 +219,25 @@ RawSourceRange RawSource::getRange(bool singleprec) result.step = 0.1; result.max = 25.5; result.decimals = 1; + result.unit = QObject::tr("V"); break; case TELEMETRY_SOURCE_CURRENT: case TELEMETRY_SOURCE_CURRENT_MAX: result.step = singleprec ? 0.5 : 0.1; result.max = singleprec ? 127.5 : 200.0; result.decimals = 1; + result.unit = QObject::tr("A"); break; case TELEMETRY_SOURCE_CONSUMPTION: result.step = singleprec ? 100 : 1; result.max = singleprec ? 25500 : 10000; + result.unit = QObject::tr("mAh"); break; case TELEMETRY_SOURCE_POWER: case TELEMETRY_SOURCE_POWER_MAX: result.step = singleprec ? 5 : 1; result.max = singleprec ? 1275 : 2000; + result.unit = QObject::tr("W"); break; case TELEMETRY_SOURCE_ACCX: case TELEMETRY_SOURCE_ACCY: @@ -227,6 +245,7 @@ RawSourceRange RawSource::getRange(bool singleprec) result.step = 0.01; result.decimals = 2; result.max = 2.55; + result.unit = QObject::tr("g"); break; default: result.max = 125; diff --git a/companion/src/eeprominterface.h b/companion/src/eeprominterface.h index ea7aed2cb..4197c9271 100644 --- a/companion/src/eeprominterface.h +++ b/companion/src/eeprominterface.h @@ -327,7 +327,7 @@ class RawSourceRange double max; double step; double offset; - + QString unit; }; class RawSource { diff --git a/companion/src/modeledit/logicalswitches.cpp b/companion/src/modeledit/logicalswitches.cpp index cae87ffce..522b56356 100644 --- a/companion/src/modeledit/logicalswitches.cpp +++ b/companion/src/modeledit/logicalswitches.cpp @@ -144,7 +144,7 @@ void LogicalSwitchesPanel::v1Edited(int value) model.customSw[i].val2 = (cswitchOffset[i]->value() / range.step); } else { - model.customSw[i].val2 = (cswitchOffset[i]->value() - range.offset) / range.step/* TODO - source.getRawOffset(model)*/; + model.customSw[i].val2 = (cswitchOffset[i]->value() - range.offset) / range.step; } setSwitchWidgetVisibility(i); } @@ -232,8 +232,10 @@ void LogicalSwitchesPanel::edited() model.customSw[i].val2 = round((value-range.offset)/range.step);; value = model.customSw[i].val2*range.step + range.offset; } - if (source.isTimeBased()) cswitchTOffset[i]->setTime(QTimeS(value)); - else cswitchOffset[i]->setValue(value); + if (source.isTimeBased()) + cswitchTOffset[i]->setTime(QTimeS(value)); + else + cswitchOffset[i]->setValue(value); break; } case LS_FAMILY_TIMER: @@ -306,7 +308,8 @@ void LogicalSwitchesPanel::setSwitchWidgetVisibility(int i) /*TODO: is this delta function value set correctly*/ maxTime = range.step*127; value = range.step*model.customSw[i].val2; - } else { + } + else { maxTime = range.max; value = range.step*(model.customSw[i].val2/* TODO+source.getRawOffset(model)*/)+range.offset; } @@ -316,6 +319,10 @@ void LogicalSwitchesPanel::setSwitchWidgetVisibility(int i) } else { mask |= VALUE2_VISIBLE; + if (range.unit.isEmpty()) + cswitchOffset[i]->setSuffix(""); + else + cswitchOffset[i]->setSuffix(" " + range.unit); if (model.customSw[i].isDeltaFunction()) { /*TODO: is this delta function value set correctly*/ cswitchOffset[i]->setMinimum(range.step*-127); From ed90015503f984b479ec9e76cc8527ceab46414c Mon Sep 17 00:00:00 2001 From: bsongis Date: Thu, 19 Jun 2014 11:59:18 +0200 Subject: [PATCH 06/10] Fixes #1272 --- companion/src/comparedialog.cpp | 9 +- companion/src/comparedialog.h | 1 + companion/src/eeprominterface.cpp | 89 +++-- companion/src/eeprominterface.h | 23 +- companion/src/firmwares/er9x/er9xeeprom.cpp | 1 - .../src/firmwares/ersky9x/ersky9xeeprom.cpp | 2 - .../firmwares/opentx/open9xStockeeprom.cpp | 2 - .../src/firmwares/opentx/opentxeeprom.cpp | 4 +- .../src/firmwares/opentx/opentxinterface.cpp | 5 + companion/src/helpers.cpp | 35 +- companion/src/modeledit/expodialog.cpp | 4 +- companion/src/modeledit/inputs.cpp | 4 +- companion/src/modeledit/logicalswitches.cpp | 12 +- companion/src/modeledit/mixerdialog.cpp | 2 +- companion/src/modeledit/mixes.cpp | 12 +- companion/src/modeledit/telemetry.cpp | 24 +- companion/src/modeledit/telemetry.h | 1 - companion/src/modeledit/telemetry.ui | 375 +++++++----------- companion/src/printdialog.cpp | 21 +- companion/src/simulation/simulatordialog.cpp | 3 +- companion/src/wizarddata.cpp | 2 +- 21 files changed, 260 insertions(+), 371 deletions(-) diff --git a/companion/src/comparedialog.cpp b/companion/src/comparedialog.cpp index 29551220a..29a60f2cf 100644 --- a/companion/src/comparedialog.cpp +++ b/companion/src/comparedialog.cpp @@ -803,7 +803,7 @@ void CompareDialog::printMixers() break; }; str += QString(" %1").arg(getGVarString(md->weight)).rightJustified(6, ' '); - str += md->srcRaw.toString(); + str += md->srcRaw.toString(*g_model1); if (md->swtch.type) str += " " + tr("Switch") + QString("(%1)").arg(md->swtch.toString()); if (md->carryTrim) str += " " + tr("noTrim"); if (md->sOffset) str += " "+ tr("Offset") + QString(" (%1%)").arg(getGVarString(md->sOffset)); @@ -881,7 +881,7 @@ void CompareDialog::printMixers() break; }; str += QString(" %1").arg(getGVarString(md->weight)).rightJustified(6, ' '); - str += md->srcRaw.toString(); + str += md->srcRaw.toString(*g_model2); if (md->swtch.type) str += " " + tr("Switch") + QString("(%1)").arg(md->swtch.toString()); if (md->carryTrim) str += " " + tr("noTrim"); if (md->sOffset) str += " "+ tr("Offset") + QString(" (%1%)").arg(getGVarString(md->sOffset)); @@ -1025,8 +1025,9 @@ void CompareDialog::printSwitches() str.append("

"+tr("Logical Switches")+"

"); str.append(""); for (int i=0; igetCapability(LogicalSwitches); i++) { - QString sw1 = g_model1->customSw[i].toString(*g_model1); - QString sw2 = g_model2->customSw[i].toString(*g_model2); + GeneralSettings settings; + QString sw1 = g_model1->customSw[i].toString(*g_model1, settings); + QString sw2 = g_model2->customSw[i].toString(*g_model2, settings); if (!(sw1.isEmpty() && sw2.isEmpty())) { str.append(""); color=getColor1(sw1,sw2); diff --git a/companion/src/comparedialog.h b/companion/src/comparedialog.h index 6f1c83875..ef6a5aec1 100644 --- a/companion/src/comparedialog.h +++ b/companion/src/comparedialog.h @@ -19,6 +19,7 @@ class CompareDialog : public QDialog ~CompareDialog(); protected: + GeneralSettings * settings; ModelData * g_model1; ModelData * g_model2; ModelData * modeltemp; diff --git a/companion/src/eeprominterface.cpp b/companion/src/eeprominterface.cpp index 6305540e2..67d710c1f 100644 --- a/companion/src/eeprominterface.cpp +++ b/companion/src/eeprominterface.cpp @@ -92,11 +92,12 @@ QString getGVarString(int16_t val, bool sign) } } -RawSourceRange RawSource::getRange(bool singleprec) +RawSourceRange RawSource::getRange(const ModelData & model, const GeneralSettings & settings, bool singleprec) { RawSourceRange result; - int board = GetEepromInterface()->getBoard(); + FirmwareInterface * firmware = GetCurrentFirmware(); + int board = firmware->getBoard(); if (!singleprec && !IS_ARM(board)) { singleprec = true; @@ -134,25 +135,33 @@ RawSourceRange RawSource::getRange(bool singleprec) case TELEMETRY_SOURCE_A2: case TELEMETRY_SOURCE_A3: case TELEMETRY_SOURCE_A4: - if (model) { - const FrSkyChannelData & channel = model->frsky.channels[index-TELEMETRY_SOURCE_A1]; - float ratio = channel.getRatio(); - if (channel.type==0 || channel.type==1 || channel.type==2) - result.decimals = 2; - else - result.decimals = 0; - result.step = ratio / 255; - result.min = channel.offset * result.step; - result.max = ratio + result.min; - result.unit = QObject::tr("V"); - } + { + const FrSkyChannelData & channel = model.frsky.channels[index-TELEMETRY_SOURCE_A1]; + float ratio = channel.getRatio(); + if (channel.type==0 || channel.type==1 || channel.type==2) + result.decimals = 2; + else + result.decimals = 0; + result.step = ratio / 255; + result.min = channel.offset * result.step; + result.max = ratio + result.min; + result.unit = QObject::tr("V"); break; + } case TELEMETRY_SOURCE_ALT: case TELEMETRY_SOURCE_GPS_ALT: result.step = singleprec ? 8 : 1; result.min = -500; result.max = singleprec ? 1540 : 3000; - result.unit = QObject::tr("m"); + if (firmware->getCapability(Imperial) || settings.imperial) { + result.step = (result.step * 105) / 32; + result.min = (result.min * 105) / 32; + result.max = (result.max * 105) / 32; + result.unit = QObject::tr("ft"); + } + else { + result.unit = QObject::tr("m"); + } break; case TELEMETRY_SOURCE_T1: case TELEMETRY_SOURCE_T1_MAX: @@ -183,14 +192,14 @@ RawSourceRange RawSource::getRange(bool singleprec) case TELEMETRY_SOURCE_SPEED_MAX: result.step = singleprec ? 2 : 1; result.max = singleprec ? (2*255) : 2000; - if (model && !model->frsky.imperial) { + if (firmware->getCapability(Imperial) || settings.imperial) { + result.unit = QObject::tr("MPH"); + } + else { result.step *= 1.852; result.max *= 1.852; result.unit = QObject::tr("km/h"); } - else { - result.unit = QObject::tr("MPH"); - } break; case TELEMETRY_SOURCE_VERTICAL_SPEED: result.step = 0.1; @@ -258,7 +267,7 @@ RawSourceRange RawSource::getRange(bool singleprec) break; default: - result.max = (model && model->extendedLimits ? 125 : 100); + result.max = (model.extendedLimits ? 125 : 100); result.min = -result.max; break; } @@ -284,7 +293,7 @@ QString RotaryEncoderString(int index) return CHECK_IN_ARRAY(rotary, index); } -QString RawSource::toString() +QString RawSource::toString(const ModelData & model) { static const QString trims[] = { QObject::tr("TrmR"), QObject::tr("TrmE"), QObject::tr("TrmT"), QObject::tr("TrmA") @@ -319,8 +328,8 @@ QString RawSource::toString() case SOURCE_TYPE_VIRTUAL_INPUT: { QString result = QObject::tr("[I%1]").arg(index+1); - if (model && strlen(model->inputNames[index]) > 0) { - result += QString(model->inputNames[index]); + if (strlen(model.inputNames[index]) > 0) { + result += QString(model.inputNames[index]); } return result; } @@ -541,7 +550,7 @@ QString LogicalSwitchData::funcToString() } } -QString LogicalSwitchData::toString(const ModelData & model) +QString LogicalSwitchData::toString(const ModelData & model, const GeneralSettings & settings) { QString result = ""; @@ -562,11 +571,11 @@ QString LogicalSwitchData::toString(const ModelData & model) result += QObject::tr("Timer(%1, %2)").arg(ValToTim(val1)).arg(ValToTim(val2)); break; case LS_FAMILY_VOFS: { - RawSource source = RawSource(val1, &model); - RawSourceRange range = source.getRange(); + RawSource source = RawSource(val1); + RawSourceRange range = source.getRange(model, settings); QString res; if (val1) - res += source.toString(); + res += source.toString(model); else res += "0"; res.remove(" "); @@ -609,7 +618,7 @@ QString LogicalSwitchData::toString(const ModelData & model) case LS_FAMILY_VCOMP: if (val1) - result += RawSource(val1).toString(); + result += RawSource(val1).toString(model); else result += "0"; switch (func) { @@ -637,7 +646,7 @@ QString LogicalSwitchData::toString(const ModelData & model) break; } if (val2) - result += RawSource(val2).toString(); + result += RawSource(val2).toString(model); else result += "0"; break; @@ -747,8 +756,9 @@ QStringList FuncSwData::toStringList() QString FuncSwData::funcToString() { + ModelData model; if (func >= FuncSafetyCh1 && func <= FuncSafetyCh32) - return QObject::tr("Safety %1").arg(RawSource(SOURCE_TYPE_CH, func).toString()); + return QObject::tr("Safety %1").arg(RawSource(SOURCE_TYPE_CH, func).toString(model)); else if (func == FuncTrainer) return QObject::tr("Trainer"); else if (func == FuncTrainerRUD) @@ -827,7 +837,8 @@ QString FuncSwData::paramToString() } else if ((func==FuncVolume)|| (func==FuncPlayValue)) { RawSource item(param); - return item.toString(); + ModelData model; + return item.toString(model); } else if ((func==FuncPlayPrompt) || (func==FuncPlayBoth)) { if ( GetCurrentFirmware()->getCapability(VoicesAsNumbers)) { @@ -837,15 +848,16 @@ QString FuncSwData::paramToString() } } else if ((func>FuncBackgroundMusicPause) && (funcmode = INPUT_MODE_BOTH; expo->srcRaw = settings.getDefaultSource(i); expo->weight = 100; - strncpy(inputNames[i], expo->srcRaw.toString().toLatin1().constData(), sizeof(inputNames[i])-1); + strncpy(inputNames[i], expo->srcRaw.toString(*this).toLatin1().constData(), sizeof(inputNames[i])-1); } } } @@ -1180,7 +1185,7 @@ void ModelData::setDefaultMixes(const GeneralSettings & settings) mix->destCh = i+1; mix->weight = 100; if (IS_TARANIS(GetEepromInterface()->getBoard())) { - mix->srcRaw = RawSource(SOURCE_TYPE_VIRTUAL_INPUT, i, this); + mix->srcRaw = RawSource(SOURCE_TYPE_VIRTUAL_INPUT, i); } else { mix->srcRaw = RawSource(SOURCE_TYPE_STICK, i); diff --git a/companion/src/eeprominterface.h b/companion/src/eeprominterface.h index 4197c9271..50a0cdf85 100644 --- a/companion/src/eeprominterface.h +++ b/companion/src/eeprominterface.h @@ -330,26 +330,24 @@ class RawSourceRange QString unit; }; +class GeneralSettings; class RawSource { public: RawSource(): type(SOURCE_TYPE_NONE), - index(0), - model(NULL) + index(0) { } - RawSource(int value, const ModelData * model=NULL): + RawSource(int value): type(RawSourceType(abs(value)/65536)), - index(value >= 0 ? abs(value)%65536 : -(abs(value)%65536)), - model(model) + index(value >= 0 ? abs(value)%65536 : -(abs(value)%65536)) { } - RawSource(RawSourceType type, int index=0, const ModelData * model=NULL): + RawSource(RawSourceType type, int index=0): type(type), - index(index), - model(model) + index(index) { } @@ -358,9 +356,9 @@ class RawSource { return index >= 0 ? (type * 65536 + index) : -(type * 65536 - index); } - QString toString(); + QString toString(const ModelData & model); - RawSourceRange getRange(bool singleprec=false); + RawSourceRange getRange(const ModelData & model, const GeneralSettings & settings, bool singleprec=false); bool operator == ( const RawSource & other) { return (this->type == other.type) && (this->index == other.index); @@ -377,7 +375,6 @@ class RawSource { RawSourceType type; int index; - const ModelData * model; }; enum RawSwitchType { @@ -717,7 +714,7 @@ class LogicalSwitchData { // Logical Switches data CSFunctionFamily getFunctionFamily(); bool isDeltaFunction(); QString funcToString(); - QString toString(const ModelData & model); + QString toString(const ModelData & model, const GeneralSettings & settings); }; enum AssignFunc { @@ -888,7 +885,6 @@ class FrSkyData { FrSkyData() { clear(); } FrSkyChannelData channels[4]; unsigned int usrProto; - unsigned int imperial; int blades; unsigned int voltsSource; bool altitudeDisplayed; @@ -1064,6 +1060,7 @@ enum Capability { FlightModes, FlightModesName, FlightModesHaveFades, + Imperial, Mixes, Timers, TimeDivisions, diff --git a/companion/src/firmwares/er9x/er9xeeprom.cpp b/companion/src/firmwares/er9x/er9xeeprom.cpp index abc644ae9..b65cbf7a7 100644 --- a/companion/src/firmwares/er9x/er9xeeprom.cpp +++ b/companion/src/firmwares/er9x/er9xeeprom.cpp @@ -468,7 +468,6 @@ t_Er9xModelData::operator ModelData () c9x.frsky = frsky; c9x.frsky.usrProto=FrSkyUsrProto; - c9x.frsky.imperial=FrSkyImperial; c9x.frsky.FrSkyGpsAlt=FrSkyGpsAlt; return c9x; } diff --git a/companion/src/firmwares/ersky9x/ersky9xeeprom.cpp b/companion/src/firmwares/ersky9x/ersky9xeeprom.cpp index 94f26496f..ddb94c0fd 100644 --- a/companion/src/firmwares/ersky9x/ersky9xeeprom.cpp +++ b/companion/src/firmwares/ersky9x/ersky9xeeprom.cpp @@ -596,7 +596,6 @@ t_Ersky9xModelData_v10::operator ModelData () c9x.frsky = frsky; c9x.frsky.usrProto=FrSkyUsrProto; - c9x.frsky.imperial=FrSkyImperial; c9x.frsky.FrSkyGpsAlt=FrSkyGpsAlt; return c9x; } @@ -715,7 +714,6 @@ t_Ersky9xModelData_v11::operator ModelData () c9x.frsky = frsky; c9x.frsky.usrProto=FrSkyUsrProto; - c9x.frsky.imperial=FrSkyImperial; c9x.frsky.FrSkyGpsAlt=FrSkyGpsAlt; // for (int i=0; i<8; i++) { // c9x.frskyalarms[i].frskyAlarmLimit=frskyAlarms.alarmData[i].frskyAlarmLimit; diff --git a/companion/src/firmwares/opentx/open9xStockeeprom.cpp b/companion/src/firmwares/opentx/open9xStockeeprom.cpp index a6cd3c4f1..898743af1 100644 --- a/companion/src/firmwares/opentx/open9xStockeeprom.cpp +++ b/companion/src/firmwares/opentx/open9xStockeeprom.cpp @@ -842,7 +842,6 @@ t_Open9xFrSkyData_v204::operator FrSkyData () c9x.channels[0] = channels[0]; c9x.channels[1] = channels[1]; c9x.usrProto = usrProto; - c9x.imperial = imperial; c9x.blades = blades+2; c9x.screens[0].type = 1; for (int i=0; i<4; i++) @@ -856,7 +855,6 @@ t_Open9xFrSkyData_v205::operator FrSkyData () c9x.channels[0] = channels[0]; c9x.channels[1] = channels[1]; c9x.usrProto = usrProto; - c9x.imperial = imperial; c9x.blades = blades+2; c9x.screens[0].type = 1; for (int i=0; i<4; i++) diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index dd4dd8f3b..1ac4d84fc 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -1009,7 +1009,7 @@ class MixField: public TransformedField { if (IS_TARANIS(board) && version < 216) { if (mix.srcRaw.type == SOURCE_TYPE_STICK && mix.srcRaw.index < NUM_STICKS) { if (!mix.noExpo) { - mix.srcRaw = RawSource(SOURCE_TYPE_VIRTUAL_INPUT, mix.srcRaw.index, model); + mix.srcRaw = RawSource(SOURCE_TYPE_VIRTUAL_INPUT, mix.srcRaw.index); } } } @@ -1548,7 +1548,7 @@ class LogicalSwitchField: public TransformedField { else if (csw.func != LS_FN_OFF) { sourcesConversionTable->importValue((uint8_t)v1, csw.val1); csw.val2 = v2; - RawSource val1(csw.val1, model); + RawSource val1(csw.val1); if (IS_ARM(board) && version < 216 && val1.type == SOURCE_TYPE_TELEMETRY) { switch (val1.index) { case TELEMETRY_SOURCE_TIMER1: diff --git a/companion/src/firmwares/opentx/opentxinterface.cpp b/companion/src/firmwares/opentx/opentxinterface.cpp index 7631bcd40..ab630585d 100644 --- a/companion/src/firmwares/opentx/opentxinterface.cpp +++ b/companion/src/firmwares/opentx/opentxinterface.cpp @@ -468,6 +468,11 @@ FirmwareInterface * OpenTxFirmware::getFirmwareVariant(const QString & id) int OpenTxFirmware::getCapability(const Capability capability) { switch (capability) { + case Imperial: + if (IS_ARM(board)) + return 0; + else + return id.contains("imperial") ? 1 : 0; case ModelImage: if (IS_TARANIS(board)) return 1; diff --git a/companion/src/helpers.cpp b/companion/src/helpers.cpp index b78ae41e5..6288305ae 100644 --- a/companion/src/helpers.cpp +++ b/companion/src/helpers.cpp @@ -72,7 +72,7 @@ QString getInputStr(ModelData & model, int index) } } else { - result = RawSource(SOURCE_TYPE_STICK, index).toString(); + result = RawSource(SOURCE_TYPE_STICK, index).toString(model); } return result; @@ -553,7 +553,7 @@ void populateSourceCB(QComboBox *b, const RawSource & source, const ModelData & if (flags & POPULATE_SOURCES) { item = RawSource(SOURCE_TYPE_NONE); - b->addItem(item.toString(), item.toValue()); + b->addItem(item.toString(model), item.toValue()); if (item == source) b->setCurrentIndex(b->count()-1); } @@ -561,8 +561,8 @@ void populateSourceCB(QComboBox *b, const RawSource & source, const ModelData & int virtualInputs = GetCurrentFirmware()->getCapability(VirtualInputs); for (int i=0; iaddItem(item.toString(), item.toValue()); + item = RawSource(SOURCE_TYPE_VIRTUAL_INPUT, i); + b->addItem(item.toString(model), item.toValue()); if (item == source) b->setCurrentIndex(b->count()-1); } } @@ -571,12 +571,12 @@ void populateSourceCB(QComboBox *b, const RawSource & source, const ModelData & if (flags & POPULATE_SOURCES) { for (int i=0; i<4+GetCurrentFirmware()->getCapability(Pots); i++) { item = RawSource(SOURCE_TYPE_STICK, i); - b->addItem(item.toString(), item.toValue()); + b->addItem(item.toString(model), item.toValue()); if (item == source) b->setCurrentIndex(b->count()-1); } for (int i=0; igetCapability(RotaryEncoders); i++) { item = RawSource(SOURCE_TYPE_ROTARY_ENCODER, i); - b->addItem(item.toString(), item.toValue()); + b->addItem(item.toString(model), item.toValue()); if (item == source) b->setCurrentIndex(b->count()-1); } } @@ -584,27 +584,27 @@ void populateSourceCB(QComboBox *b, const RawSource & source, const ModelData & if (flags & POPULATE_TRIMS) { for (int i=0; i<4; i++) { item = RawSource(SOURCE_TYPE_TRIM, i); - b->addItem(item.toString(), item.toValue()); + b->addItem(item.toString(model), item.toValue()); if (item == source) b->setCurrentIndex(b->count()-1); } } if (flags & POPULATE_SOURCES) { item = RawSource(SOURCE_TYPE_MAX); - b->addItem(item.toString(), item.toValue()); + b->addItem(item.toString(model), item.toValue()); if (item == source) b->setCurrentIndex(b->count()-1); } if (flags & POPULATE_SWITCHES) { for (int i=0; igetCapability(Switches); i++) { item = RawSource(SOURCE_TYPE_SWITCH, i); - b->addItem(item.toString(), item.toValue()); + b->addItem(item.toString(model), item.toValue()); if (item == source) b->setCurrentIndex(b->count()-1); } for (int i=0; igetCapability(LogicalSwitches); i++) { item = RawSource(SOURCE_TYPE_CUSTOM_SWITCH, i); - b->addItem(item.toString(), item.toValue()); + b->addItem(item.toString(model), item.toValue()); if (item == source) b->setCurrentIndex(b->count()-1); } } @@ -612,19 +612,19 @@ void populateSourceCB(QComboBox *b, const RawSource & source, const ModelData & if (flags & POPULATE_SOURCES) { for (int i=0; iaddItem(item.toString(), item.toValue()); + b->addItem(item.toString(model), item.toValue()); if (item == source) b->setCurrentIndex(b->count()-1); } for (int i=0; igetCapability(TrainerInputs); i++) { item = RawSource(SOURCE_TYPE_PPM, i); - b->addItem(item.toString(), item.toValue()); + b->addItem(item.toString(model), item.toValue()); if (item == source) b->setCurrentIndex(b->count()-1); } for (int i=0; igetCapability(Outputs); i++) { item = RawSource(SOURCE_TYPE_CH, i); - b->addItem(item.toString(), item.toValue()); + b->addItem(item.toString(model), item.toValue()); if (item == source) b->setCurrentIndex(b->count()-1); } } @@ -634,7 +634,7 @@ void populateSourceCB(QComboBox *b, const RawSource & source, const ModelData & if (i==TELEMETRY_SOURCE_RSSI_TX && IS_TARANIS(GetCurrentFirmware()->getBoard())) continue; item = RawSource(SOURCE_TYPE_TELEMETRY, i); - b->addItem(item.toString(), item.toValue()); + b->addItem(item.toString(model), item.toValue()); if (item == source) b->setCurrentIndex(b->count()-1); } } @@ -643,7 +643,7 @@ void populateSourceCB(QComboBox *b, const RawSource & source, const ModelData & if (i==TELEMETRY_SOURCE_RSSI_TX && IS_TARANIS(GetCurrentFirmware()->getBoard())) continue; item = RawSource(SOURCE_TYPE_TELEMETRY, i); - b->addItem(item.toString(), item.toValue()); + b->addItem(item.toString(model), item.toValue()); if (item == source) b->setCurrentIndex(b->count()-1); } } @@ -651,7 +651,7 @@ void populateSourceCB(QComboBox *b, const RawSource & source, const ModelData & if (flags & POPULATE_GVARS) { for (int i=0; igetCapability(Gvars); i++) { item = RawSource(SOURCE_TYPE_GVAR, i); - b->addItem(item.toString(), item.toValue()); + b->addItem(item.toString(model), item.toValue()); if (item == source) b->setCurrentIndex(b->count()-1); } } @@ -777,7 +777,8 @@ QString getFrSkyMeasure(int units) QString getFrSkySrc(int index) { - return RawSource(SOURCE_TYPE_TELEMETRY, index-1).toString(); + ModelData model; + return RawSource(SOURCE_TYPE_TELEMETRY, index-1).toString(model); } QString getTrimInc(ModelData * g_model) diff --git a/companion/src/modeledit/expodialog.cpp b/companion/src/modeledit/expodialog.cpp index ff0f788f1..3ae8177cb 100644 --- a/companion/src/modeledit/expodialog.cpp +++ b/companion/src/modeledit/expodialog.cpp @@ -122,7 +122,7 @@ ExpoDialog::~ExpoDialog() void ExpoDialog::updateScale() { if (firmware->getCapability(VirtualInputs) && ed->srcRaw.type == SOURCE_TYPE_TELEMETRY) { - RawSourceRange range = ed->srcRaw.getRange(); + RawSourceRange range = ed->srcRaw.getRange(model, generalSettings); ui->scaleLabel->show(); ui->scale->show(); ui->scale->setDecimals(range.decimals); @@ -146,7 +146,7 @@ void ExpoDialog::valuesChanged() updateScale(); } - RawSourceRange range = srcRaw.getRange(); + RawSourceRange range = srcRaw.getRange(model, generalSettings); ed->scale = round(float(ui->scale->value()) / range.step); ed->carryTrim = 1 - ui->trimCB->currentIndex(); ed->swtch = RawSwitch(ui->switchesCB->itemData(ui->switchesCB->currentIndex()).toInt()); diff --git a/companion/src/modeledit/inputs.cpp b/companion/src/modeledit/inputs.cpp index 0c0718974..6ffa4c972 100644 --- a/companion/src/modeledit/inputs.cpp +++ b/companion/src/modeledit/inputs.cpp @@ -165,12 +165,12 @@ QString InputsPanel::getInputText(int dest, bool * new_ch) if (md->offset) str += " " + tr("Offset(%1)").arg(getGVarString(md->offset)); if (firmware->getCapability(VirtualInputs)) { - str += " " + tr("Source(%1)").arg(md->srcRaw.toString()); + str += " " + tr("Source(%1)").arg(md->srcRaw.toString(model)); if (md->carryTrim>0) { str += " " + tr("NoTrim"); } else if (md->carryTrim<0) { - str += " " + RawSource(SOURCE_TYPE_TRIM, (-(md->carryTrim)-1)).toString(); + str += " " + RawSource(SOURCE_TYPE_TRIM, (-(md->carryTrim)-1)).toString(model); } } diff --git a/companion/src/modeledit/logicalswitches.cpp b/companion/src/modeledit/logicalswitches.cpp index 522b56356..136e34813 100644 --- a/companion/src/modeledit/logicalswitches.cpp +++ b/companion/src/modeledit/logicalswitches.cpp @@ -138,8 +138,8 @@ void LogicalSwitchesPanel::v1Edited(int value) int i = sender()->property("index").toInt(); model.customSw[i].val1 = cswitchSource1[i]->itemData(value).toInt(); if (model.customSw[i].getFunctionFamily() == LS_FAMILY_VOFS) { - RawSource source = RawSource(model.customSw[i].val1, &model); - RawSourceRange range = source.getRange(); + RawSource source = RawSource(model.customSw[i].val1); + RawSourceRange range = source.getRange(model, generalSettings); if (model.customSw[i].isDeltaFunction()) { model.customSw[i].val2 = (cswitchOffset[i]->value() / range.step); } @@ -220,8 +220,8 @@ void LogicalSwitchesPanel::edited() { case LS_FAMILY_VOFS: { - source = RawSource(model.customSw[i].val1, &model); - RawSourceRange range = source.getRange(); + source = RawSource(model.customSw[i].val1); + RawSourceRange range = source.getRange(model, generalSettings); int value = source.isTimeBased() ? QTimeS(cswitchTOffset[i]->time()).seconds() : cswitchOffset[i]->value(); if (model.customSw[i].isDeltaFunction()) { /*TODO: is this delta function value set correctly*/ @@ -290,8 +290,8 @@ void LogicalSwitchesPanel::setSwitchWidgetVisibility(int i) lock = true; unsigned int mask = 0; - RawSource source = RawSource(model.customSw[i].val1, &model); - RawSourceRange range = source.getRange(); + RawSource source = RawSource(model.customSw[i].val1); + RawSourceRange range = source.getRange(model, generalSettings); switch (model.customSw[i].getFunctionFamily()) { diff --git a/companion/src/modeledit/mixerdialog.cpp b/companion/src/modeledit/mixerdialog.cpp index 33140c8df..1312c1255 100644 --- a/companion/src/modeledit/mixerdialog.cpp +++ b/companion/src/modeledit/mixerdialog.cpp @@ -142,7 +142,7 @@ void MixerDialog::valuesChanged() if (!lock) { lock = true; QCheckBox * cb_fp[] = {ui->cb_FP0,ui->cb_FP1,ui->cb_FP2,ui->cb_FP3,ui->cb_FP4,ui->cb_FP5,ui->cb_FP6,ui->cb_FP7,ui->cb_FP8 }; - md->srcRaw = RawSource(ui->sourceCB->itemData(ui->sourceCB->currentIndex()).toInt(), &model); + md->srcRaw = RawSource(ui->sourceCB->itemData(ui->sourceCB->currentIndex()).toInt()); if (firmware->getCapability(HasNoExpo)) { bool drVisible = (md->srcRaw.type == SOURCE_TYPE_STICK && md->srcRaw.index < NUM_STICKS); ui->MixDR_CB->setEnabled(drVisible); diff --git a/companion/src/modeledit/mixes.cpp b/companion/src/modeledit/mixes.cpp index a6b6459d9..946668b1d 100644 --- a/companion/src/modeledit/mixes.cpp +++ b/companion/src/modeledit/mixes.cpp @@ -170,16 +170,12 @@ QString MixesPanel::getMixerText(int dest, bool * new_ch) default: str += " "; break; }; - //set mixer src model if it is unset (srcRaw needs this to generate proper toString() for input source type) - if (md->srcRaw.model == 0) - md->srcRaw.model = &model; - - //highlight source if needed + // highlight source if needed if ( (md->srcRaw.type == SOURCE_TYPE_CH) && (md->srcRaw.index+1 == (int)highlightedSource) ) { - str += " " + Qt::escape(md->srcRaw.toString()) + ""; + str += " " + Qt::escape(md->srcRaw.toString(model)) + ""; } else { - str += " " + Qt::escape(md->srcRaw.toString()); + str += " " + Qt::escape(md->srcRaw.toString(model)); } str += " " + Qt::escape(tr("Weight(%1)").arg(getGVarString(md->weight, true))); @@ -192,7 +188,7 @@ QString MixesPanel::getMixerText(int dest, bool * new_ch) } if (md->carryTrim>0) str += " " + Qt::escape(tr("NoTrim")); - else if (md->carryTrim<0) str += " " + RawSource(SOURCE_TYPE_TRIM, (-(md->carryTrim)-1)).toString(); + else if (md->carryTrim<0) str += " " + RawSource(SOURCE_TYPE_TRIM, (-(md->carryTrim)-1)).toString(model); if (firmware->getCapability(HasNoExpo) && md->noExpo) str += " " + Qt::escape(tr("No DR/Expo")); if (md->sOffset) str += " " + Qt::escape(tr("Offset(%1)").arg(getGVarString(md->sOffset))); diff --git a/companion/src/modeledit/telemetry.cpp b/companion/src/modeledit/telemetry.cpp index e5048772a..1e37aa5b3 100644 --- a/companion/src/modeledit/telemetry.cpp +++ b/companion/src/modeledit/telemetry.cpp @@ -335,10 +335,10 @@ void TelemetryCustomScreen::populateTelemetrySourceCB(QComboBox *b, unsigned int int telem_hub[] = {0,0,0,0,0,0,0,0,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,0,0,2,2,1,1,1,1,1,1}; b->clear(); - b->addItem(RawSource(SOURCE_TYPE_NONE, 0).toString()); + 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()); + b->addItem(RawSource(SOURCE_TYPE_TELEMETRY, i).toString(model)); if (!firmware->isTelemetrySourceAvailable(i)) { //disable item QModelIndex index = b->model()->index(i+1, 0); @@ -407,8 +407,8 @@ void TelemetryCustomScreen::updateBar(int line) int index = screen.body.bars[line].source; barsCB[line]->setCurrentIndex(index); if (index) { - RawSource source = RawSource(SOURCE_TYPE_TELEMETRY, index-1, &model); - RawSourceRange range = source.getRange(true); + RawSource source = RawSource(SOURCE_TYPE_TELEMETRY, index-1); + RawSourceRange range = source.getRange(model, generalSettings, true); int max = round((range.max - range.min) / range.step); if (int(255-screen.body.bars[line].barMax) > max) screen.body.bars[line].barMax = 255 - max; @@ -619,15 +619,6 @@ void TelemetryPanel::setup() ui->altimetryGB->setVisible(firmware->getCapability(HasAltitudeSel) || firmware->getCapability(HasVario)), ui->frskyProtoCB->setDisabled(firmware->getCapability(NoTelemetryProtocol)); - if (!firmware->getCapability(TelemetryUnits)) { - ui->frskyUnitsCB->setDisabled(true); - int index=0; - if (firmware_id.contains("imperial")) { - index=1; - } - ui->frskyUnitsCB->setCurrentIndex(index); - } - if (firmware->getCapability(Telemetry) & TM_HASWSHH) { ui->frskyProtoCB->addItem(tr("Winged Shadow How High")); } @@ -662,7 +653,6 @@ void TelemetryPanel::setup() } ui->frskyProtoCB->setCurrentIndex(model.frsky.usrProto); - ui->frskyUnitsCB->setCurrentIndex(model.frsky.imperial); ui->bladesCount->setValue(model.frsky.blades); populateVoltsSource(); @@ -727,12 +717,6 @@ void TelemetryPanel::onAnalogModified() emit modified(); } -void TelemetryPanel::on_frskyUnitsCB_currentIndexChanged(int index) -{ - model.frsky.imperial = index; - emit modified(); -} - void TelemetryPanel::on_bladesCount_editingFinished() { model.frsky.blades = ui->bladesCount->value(); diff --git a/companion/src/modeledit/telemetry.h b/companion/src/modeledit/telemetry.h index 8cecffc7d..e28ff6387 100644 --- a/companion/src/modeledit/telemetry.h +++ b/companion/src/modeledit/telemetry.h @@ -86,7 +86,6 @@ class TelemetryPanel : public ModelPanel void on_telemetryProtocol_currentIndexChanged(int index); void onAnalogModified(); void on_frskyProtoCB_currentIndexChanged(int index); - void on_frskyUnitsCB_currentIndexChanged(int index); void on_bladesCount_editingFinished(); void on_AltitudeToolbar_ChkB_toggled(bool checked); void on_rssiAlarm1CB_currentIndexChanged(int index); diff --git a/companion/src/modeledit/telemetry.ui b/companion/src/modeledit/telemetry.ui index 24ca7eb31..9a5facdf5 100644 --- a/companion/src/modeledit/telemetry.ui +++ b/companion/src/modeledit/telemetry.ui @@ -61,7 +61,7 @@ - + @@ -188,221 +188,6 @@ - - - - - 0 - 0 - - - - - 0 - - - 0 - - - 0 - - - 3 - - - 3 - - - - - 9 - - - 0 - - - - - - 0 - 0 - - - - Volt source - - - - - - - - 0 - 0 - - - - - Metric - - - - - Imperial - - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - Current source - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - Protocol - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - None - - - - - FrSky Sensor Hub - - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - Units - - - - - - - - 0 - 0 - - - - Blades - - - - - - - - 75 - true - - - - Serial Protocol - - - - - - - - 0 - 0 - - - - 0 - - - 2.000000000000000 - - - 5.000000000000000 - - - 2.000000000000000 - - - - - - - - @@ -738,21 +523,121 @@ 0 - + 3 0 - + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + Volt source + + + + + + + + 0 + 0 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Current source + + + + + + + + 0 + 0 + + + + 0 + + + 2.000000000000000 + + + 5.000000000000000 + + + 2.000000000000000 + + + + + + + + 0 + 0 + + + + Blades + + + + mAh count - + @@ -768,7 +653,7 @@ - + @@ -793,7 +678,7 @@ - + @@ -806,26 +691,13 @@ - + Persistent mAh - - - - Qt::Horizontal - - - - 40 - 20 - - - - @@ -845,6 +717,39 @@ + + + + + 75 + true + + + + Serial Protocol + + + + + + + + 0 + 0 + + + + + None + + + + + FrSky Sensor Hub + + + + diff --git a/companion/src/printdialog.cpp b/companion/src/printdialog.cpp index 990f8c1d1..ec67f7533 100644 --- a/companion/src/printdialog.cpp +++ b/companion/src/printdialog.cpp @@ -238,9 +238,9 @@ void PrintDialog::printInputs() str += " " + tr("Weight") + QString("(%1)").arg(getGVarString(ed->weight,true)); if (firmware->getCapability(VirtualInputs)) { - str += " " + tr("Source") + QString("(%1)").arg(ed->srcRaw.toString()); + str += " " + tr("Source") + QString("(%1)").arg(ed->srcRaw.toString(*g_model)); if (ed->carryTrim>0) str += " " + tr("NoTrim"); - else if (ed->carryTrim<0) str += " " + RawSource(SOURCE_TYPE_TRIM, (-(ed->carryTrim)-1)).toString(); + else if (ed->carryTrim<0) str += " " + RawSource(SOURCE_TYPE_TRIM, (-(ed->carryTrim)-1)).toString(*g_model); } if (ed->curve.value) str += " " + Qt::escape(ed->curve.toString()); @@ -321,11 +321,8 @@ void PrintDialog::printMixes() case (2): str += " R"; break; default: str += "  "; break; }; - //set mixer src model if it is unset (srcRaw needs this to generate proper toString() for input source type) - if (md->srcRaw.model == 0) - md->srcRaw.model = g_model; - str += " " + md->srcRaw.toString(); + str += " " + md->srcRaw.toString(*g_model); str += " " + Qt::escape(tr("Weight(%1)").arg(getGVarString(md->weight, true))); QString phasesStr = getPhasesStr(md->phases, *g_model); @@ -335,8 +332,10 @@ void PrintDialog::printMixes() str += " " + Qt::escape(tr("Switch(%1)").arg(md->swtch.toString())); } - if (md->carryTrim>0) str += " " + Qt::escape(tr("NoTrim")); - else if (md->carryTrim<0) str += " " + RawSource(SOURCE_TYPE_TRIM, (-(md->carryTrim)-1)).toString(); + if (md->carryTrim>0) + str += " " + Qt::escape(tr("NoTrim")); + else if (md->carryTrim<0) + str += " " + RawSource(SOURCE_TYPE_TRIM, (-(md->carryTrim)-1)).toString(*g_model); if (firmware->getCapability(HasNoExpo) && md->noExpo) str += " " + Qt::escape(tr("No DR/Expo")); if (md->sOffset) str += " " + Qt::escape(tr("Offset(%1)").arg(getGVarString(md->sOffset))); @@ -350,7 +349,8 @@ void PrintDialog::printMixes() str += Qt::escape(tr(" Delay(u%1:d%2)").arg((double)md->delayUp/scale).arg((double)md->delayDown/scale)); if (md->speedDown || md->speedUp) str += Qt::escape(tr(" Slow(u%1:d%2)").arg((double)md->speedUp/scale).arg((double)md->speedDown/scale)); - if (md->mixWarn) str += Qt::escape(tr(" Warn(%1)").arg(md->mixWarn)); + if (md->mixWarn) + str += Qt::escape(tr(" Warn(%1)").arg(md->mixWarn)); if (firmware->getCapability(HasMixerNames)) { QString MixerName; MixerName.append(md->name); @@ -588,7 +588,7 @@ void PrintDialog::printSwitches() if (g_model->customSw[i].func) { str.append(""); str.append("").arg(i+1)); - QString tstr = g_model->customSw[i].toString(*g_model); + QString tstr = g_model->customSw[i].toString(*g_model, *g_eeGeneral); str.append(doTL(tstr,"green")); str.append(""); sc++; @@ -754,7 +754,6 @@ void PrintDialog::printFrSky() str.append(""); str.append(""); str.append(""); - str.append(""); str.append(""); str.append("
"+tr("L")+QString("%1
"+getFrSkyAlarmType(fd->rssiAlarms[1].level)+"<"+QString::number(fd->rssiAlarms[1].value,10)+"
"+tr("Frsky serial protocol")+""+getFrSkyProtocol(fd->usrProto)+"
"+tr("Units system")+""+getFrSkyMeasure(fd->imperial)+"
"+tr("Blades")+""+fd->blades+"
"); } diff --git a/companion/src/simulation/simulatordialog.cpp b/companion/src/simulation/simulatordialog.cpp index 69f85346f..b3a6580a1 100644 --- a/companion/src/simulation/simulatordialog.cpp +++ b/companion/src/simulation/simulatordialog.cpp @@ -361,7 +361,8 @@ void SimulatorDialog::initUi(T * ui) int column = i / (outputs/2); int line = i % (outputs/2); QLabel * label = new QLabel(tabWidget); - label->setText(RawSource(SOURCE_TYPE_CH, i).toString()); + ModelData model; + label->setText(RawSource(SOURCE_TYPE_CH, i).toString(model)); channelsLayout->addWidget(label, line, column == 0 ? 0 : 5, 1, 1); QSlider * slider = new QSlider(tabWidget); diff --git a/companion/src/wizarddata.cpp b/companion/src/wizarddata.cpp index bcdc4dd16..62a9f1c7c 100644 --- a/companion/src/wizarddata.cpp +++ b/companion/src/wizarddata.cpp @@ -60,7 +60,7 @@ void WizMix::addMix(ModelData &model, Input input, int weight, int channel, int mix.destCh = channel+1; if (isTaranis){ int channel = settings.getDefaultChannel(input-1); - mix.srcRaw = RawSource(SOURCE_TYPE_VIRTUAL_INPUT, channel, &model); + mix.srcRaw = RawSource(SOURCE_TYPE_VIRTUAL_INPUT, channel); } else mix.srcRaw = RawSource(SOURCE_TYPE_STICK, input-1); From 7b1edb58a41d8d8d1805b2cefd601201ec3c9415 Mon Sep 17 00:00:00 2001 From: bsongis Date: Thu, 19 Jun 2014 12:29:22 +0200 Subject: [PATCH 07/10] Fixes #1306 --- companion/src/firmwares/opentx/opentxM128simulator.cpp | 2 ++ companion/src/firmwares/opentx/opentxeeprom.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/companion/src/firmwares/opentx/opentxM128simulator.cpp b/companion/src/firmwares/opentx/opentxM128simulator.cpp index b5ba97093..d92eae2b3 100644 --- a/companion/src/firmwares/opentx/opentxM128simulator.cpp +++ b/companion/src/firmwares/opentx/opentxM128simulator.cpp @@ -46,6 +46,8 @@ #define GPS #define FAI_CHOICE #define FRSKY_STICKS +#define DSM2 +#define DSM2_PPM #define EEPROM_VARIANT SIMU_M128_VARIANTS #define GAUGES diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index 1ac4d84fc..d17afe577 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -2424,7 +2424,7 @@ OpenTxModelData::OpenTxModelData(ModelData & modelData, BoardEnum board, unsigne if (IS_ARM(board)) internalField.Append(new UnsignedField<3>(modelData.telemetryProtocol)); else - internalField.Append(new ConversionField< SignedField<3> >(modelData.moduleData[0].protocol, &protocolsConversionTable, "Protocol", ::QObject::tr("OpenTX doesn't accept this protocol"))); + internalField.Append(new ConversionField< UnsignedField<3> >((unsigned int &)modelData.moduleData[0].protocol, &protocolsConversionTable, "Protocol", ::QObject::tr("OpenTX doesn't accept this protocol"))); internalField.Append(new BoolField<1>(modelData.thrTrim)); From a5647ed7bc9247b2fd7a5f1d7975c04cb01425c4 Mon Sep 17 00:00:00 2001 From: bsongis Date: Thu, 19 Jun 2014 14:47:26 +0200 Subject: [PATCH 08/10] Fixes #1309 --- radio/src/gui/menu_model.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/radio/src/gui/menu_model.cpp b/radio/src/gui/menu_model.cpp index 657efab88..7008d6fa6 100644 --- a/radio/src/gui/menu_model.cpp +++ b/radio/src/gui/menu_model.cpp @@ -1350,7 +1350,17 @@ void menuModelSetup(uint8_t event) lcd_putsLeft(y, STR_BEEPCTR); for (uint8_t i=0; i POT3) { + x -= FW; + } +#endif + lcd_putsiAtt(x, y, STR_RETA123, i, ((m_posHorz==i) && attr) ? BLINK|INVERS : (((g_model.beepANACenter & ((BeepANACenter)1< Date: Thu, 19 Jun 2014 15:04:17 +0200 Subject: [PATCH 09/10] Fixes #1311 - Speed and AirSpeed maxima are now 2000kts in OpenTX --- radio/src/opentx.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index fbe4011f6..17dc11616 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -745,6 +745,11 @@ ls_telemetry_value_t maxTelemValue(uint8_t channel) case TELEM_HDG: return 180; #if defined(CPUARM) + case TELEM_SPEED: + case TELEM_MAX_SPEED: + case TELEM_ASPEED: + case TELEM_MAX_ASPEED: + return 2000; default: return 30000; #else From a9ad37cab95a5388679d4f36dc08b1d6995618f0 Mon Sep 17 00:00:00 2001 From: bsongis Date: Thu, 19 Jun 2014 15:09:09 +0200 Subject: [PATCH 10/10] Fixes #1304 - A1, A2, A3, A4, RSSI, SWR and Telemetry State alarms are now Critical alarms and are played in "Alarm" mode. --- radio/src/audio_arm.cpp | 28 ++++++++++++++-------------- radio/src/opentx.h | 30 +++++++++++++++--------------- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/radio/src/audio_arm.cpp b/radio/src/audio_arm.cpp index a194e6a1c..1b69b1783 100644 --- a/radio/src/audio_arm.cpp +++ b/radio/src/audio_arm.cpp @@ -155,6 +155,19 @@ const char * audioFilenames[] = { "eeformat", "lowbatt", "inactiv", + "a1_org", + "a1_red", + "a2_org", + "a2_red", + "a3_org", + "a3_red", + "a4_org", + "a4_red", + "rssi_org", + "rssi_red", + "swr_red", + "telemko", + "telemok", #if defined(PCBSKY9X) "highmah", "hightemp", @@ -189,20 +202,7 @@ const char * audioFilenames[] = { "timer00", "timer10", "timer20", - "timer30", - "a1_org", - "a1_red", - "a2_org", - "a2_red", - "a3_org", - "a3_red", - "a4_org", - "a4_red", - "rssi_org", - "rssi_red", - "swr_red", - "telemko", - "telemok" + "timer30" }; uint64_t sdAvailableSystemAudioFiles = 0; diff --git a/radio/src/opentx.h b/radio/src/opentx.h index 8ed24badd..f730f72ad 100644 --- a/radio/src/opentx.h +++ b/radio/src/opentx.h @@ -1318,6 +1318,21 @@ enum AUDIO_SOUNDS { #endif AU_TX_BATTERY_LOW, AU_INACTIVITY, +#if defined(CPUARM) + AU_A1_ORANGE, + AU_A1_RED, + AU_A2_ORANGE, + AU_A2_RED, + AU_A3_ORANGE, + AU_A3_RED, + AU_A4_ORANGE, + AU_A4_RED, + AU_RSSI_ORANGE, + AU_RSSI_RED, + AU_SWR_RED, + AU_TELEMETRY_LOST, + AU_TELEMETRY_BACK, +#endif #if defined(PCBSKY9X) AU_TX_MAH_HIGH, AU_TX_TEMP_HIGH, @@ -1361,21 +1376,6 @@ enum AUDIO_SOUNDS { AU_TIMER_LT10, AU_TIMER_20, AU_TIMER_30, -#if defined(CPUARM) - AU_A1_ORANGE, - AU_A1_RED, - AU_A2_ORANGE, - AU_A2_RED, - AU_A3_ORANGE, - AU_A3_RED, - AU_A4_ORANGE, - AU_A4_RED, - AU_RSSI_ORANGE, - AU_RSSI_RED, - AU_SWR_RED, - AU_TELEMETRY_LOST, - AU_TELEMETRY_BACK, -#endif AU_FRSKY_FIRST, AU_FRSKY_BEEP1 = AU_FRSKY_FIRST, AU_FRSKY_BEEP2,