diff --git a/companion/src/eeprominterface.cpp b/companion/src/eeprominterface.cpp index 711b68764..f1978755f 100644 --- a/companion/src/eeprominterface.cpp +++ b/companion/src/eeprominterface.cpp @@ -126,7 +126,9 @@ RawSourceRange RawSource::getRange(bool singleprec) result.max = singleprec ? 1540 : 3000; break; case TELEMETRY_SOURCE_T1: + case TELEMETRY_SOURCE_T1_MAX: case TELEMETRY_SOURCE_T2: + case TELEMETRY_SOURCE_T2_MAX: result.min = -30; result.max = 225; break; @@ -150,17 +152,21 @@ RawSourceRange RawSource::getRange(bool singleprec) result.max = singleprec ? 2040 : 10000; break; case TELEMETRY_SOURCE_CELL: + case TELEMETRY_SOURCE_CELL_MIN: result.step = singleprec ? 0.02 : 0.01; result.max = 5.1; result.decimals = 2; break; case TELEMETRY_SOURCE_CELLS_SUM: + case TELEMETRY_SOURCE_CELLS_MIN: case TELEMETRY_SOURCE_VFAS: + case TELEMETRY_SOURCE_VFAS_MIN: result.step = 0.1; result.max = 25.5; result.decimals = 1; 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; @@ -170,6 +176,7 @@ RawSourceRange RawSource::getRange(bool singleprec) result.max = singleprec ? 5100 : 10000; break; case TELEMETRY_SOURCE_POWER: + case TELEMETRY_SOURCE_POWER_MAX: result.step = singleprec ? 5 : 1; result.max = singleprec ? 1275 : 2000; break; @@ -221,12 +228,12 @@ QString RawSource::toString() QObject::tr("A1"), QObject::tr("A2"), QObject::tr("A3"), QObject::tr("A4"), QObject::tr("Alt"), QObject::tr("Rpm"), QObject::tr("Fuel"), QObject::tr("T1"), QObject::tr("T2"), QObject::tr("Speed"), QObject::tr("Dist"), QObject::tr("GPS Alt"), - QObject::tr("Cell"), QObject::tr("Cels"), QObject::tr("Vfas"), QObject::tr("Curr"), QObject::tr("Cnsp"), QObject::tr("Powr"), + QObject::tr("Cell"), QObject::tr("Cells"), QObject::tr("Vfas"), QObject::tr("Curr"), QObject::tr("Cnsp"), QObject::tr("Powr"), QObject::tr("AccX"), QObject::tr("AccY"), QObject::tr("AccZ"), QObject::tr("HDG "), QObject::tr("VSpd"), QObject::tr("ASpd"), QObject::tr("dTE"), QObject::tr("A1-"), QObject::tr("A2-"), QObject::tr("A3-"), QObject::tr("A4-"), - QObject::tr("Alt-"), QObject::tr("Alt+"), QObject::tr("Rpm+"), QObject::tr("T1+"), QObject::tr("T2+"), QObject::tr("Spd+"), QObject::tr("Dst+"), - QObject::tr("Cel-"), QObject::tr("Cels-"), QObject::tr("Vfs-"), QObject::tr("Cur+"), QObject::tr("Pwr+"), + QObject::tr("Alt-"), QObject::tr("Alt+"), QObject::tr("Rpm+"), QObject::tr("T1+"), QObject::tr("T2+"), QObject::tr("Speed+"), QObject::tr("Dist+"), + QObject::tr("Cell-"), QObject::tr("Cells-"), QObject::tr("Vfas-"), QObject::tr("Curr+"), QObject::tr("Powr+"), QObject::tr("ACC"), QObject::tr("Time"), }; diff --git a/companion/src/eeprominterface.h b/companion/src/eeprominterface.h index f4a2bc7dc..98804b3d1 100644 --- a/companion/src/eeprominterface.h +++ b/companion/src/eeprominterface.h @@ -217,6 +217,7 @@ enum TelemetrySource { TELEMETRY_SOURCE_CELL_MIN, TELEMETRY_SOURCE_CELLS_MIN, TELEMETRY_SOURCE_VFAS_MIN, + TELEMETRY_SOURCE_CURRENT_MAX, TELEMETRY_SOURCE_POWER_MAX, TELEMETRY_SOURCE_ACC, TELEMETRY_SOURCE_GPS_TIME, diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index 8a9744bc0..6317cdc71 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -384,8 +384,12 @@ class TelemetrySourcesConversionTable: public ConversionTable { addConversion(1+TELEMETRY_SOURCE_T2_MAX, val++); addConversion(1+TELEMETRY_SOURCE_SPEED_MAX, val++); addConversion(1+TELEMETRY_SOURCE_DIST_MAX, val++); - addConversion(1+TELEMETRY_SOURCE_CELL_MIN, val++); - addConversion(1+TELEMETRY_SOURCE_VFAS_MIN, val++); + if (version >= 216) { + addConversion(1+TELEMETRY_SOURCE_CELL_MIN, val++); + addConversion(1+TELEMETRY_SOURCE_CELLS_MIN, val++); + addConversion(1+TELEMETRY_SOURCE_VFAS_MIN, val++); + } + addConversion(1+TELEMETRY_SOURCE_CURRENT_MAX, val++); addConversion(1+TELEMETRY_SOURCE_POWER_MAX, val++); if (IS_ARM(board) && version >= 216) { for (int i=0; i<5; i++) diff --git a/companion/src/helpers.cpp b/companion/src/helpers.cpp index 536921de1..52871a32e 100644 --- a/companion/src/helpers.cpp +++ b/companion/src/helpers.cpp @@ -95,31 +95,6 @@ void populateRotEncCB(QComboBox *b, int value, int renumber) b->setCurrentIndex(value); } -void populateCustomScreenFieldCB(QComboBox *b, unsigned int value, bool last=false, int hubproto=0) -{ - 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()); - - for (unsigned int i = 0; i <= (last ? TELEMETRY_SOURCES_DISPLAY_COUNT : TELEMETRY_SOURCES_STATUS_COUNT); i++) { - b->addItem(RawSource(SOURCE_TYPE_TELEMETRY, i).toString()); - if (!(i>=sizeof(telem_hub)/sizeof(int) || telem_hub[i]==0 || ((telem_hub[i]>=hubproto) && hubproto!=0))) { - QModelIndex index = b->model()->index(i, 0); - QVariant v(0); - b->model()->setData(index, v, Qt::UserRole - 1); - } - } - - if (value>=sizeof(telem_hub)/sizeof(int)) - b->setCurrentIndex(0); - else if (telem_hub[value]==0 || ((telem_hub[value]>=hubproto) && hubproto!=0)) { - b->setCurrentIndex(value); - } - - b->setMaxVisibleItems(10); -} - QString getProtocolStr(const int proto) { static const char *strings[] = { "OFF", diff --git a/companion/src/helpers.h b/companion/src/helpers.h index 857d66749..53bff4d2f 100644 --- a/companion/src/helpers.h +++ b/companion/src/helpers.h @@ -88,7 +88,6 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr= void populatePhasesCB(QComboBox *b, int value); void populateGvarUseCB(QComboBox *b, unsigned int phase); -void populateCustomScreenFieldCB(QComboBox *b, unsigned int value, bool last, int hubproto); QString getProtocolStr(const int proto); QString getPhasesStr(unsigned int phases, ModelData & model); diff --git a/companion/src/modeledit/telemetry.cpp b/companion/src/modeledit/telemetry.cpp index 675b9a2be..a30a508b4 100644 --- a/companion/src/modeledit/telemetry.cpp +++ b/companion/src/modeledit/telemetry.cpp @@ -291,7 +291,7 @@ 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)); - populateCustomScreenFieldCB(fieldsCB[l][c], screen.body.lines[l].source[c], (l<4), model.frsky.usrProto); + 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))); } @@ -300,7 +300,7 @@ TelemetryCustomScreen::TelemetryCustomScreen(QWidget *parent, ModelData & model, for (int l=0; l<4; l++) { barsCB[l] = new QComboBox(this); barsCB[l]->setProperty("index", l); - populateCustomScreenFieldCB(barsCB[l], screen.body.bars[l].source, false, model.frsky.usrProto); + 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); @@ -326,6 +326,31 @@ TelemetryCustomScreen::TelemetryCustomScreen(QWidget *parent, ModelData & model, update(); } +void TelemetryCustomScreen::populateTelemetrySourceCB(QComboBox *b, unsigned int value, bool last, int hubproto) +{ + 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()); + + for (unsigned int i = 0; i < (last ? TELEMETRY_SOURCES_STATUS_COUNT : TELEMETRY_SOURCES_DISPLAY_COUNT); i++) { + b->addItem(RawSource(SOURCE_TYPE_TELEMETRY, i).toString()); + if (!(i>=sizeof(telem_hub)/sizeof(int) || telem_hub[i]==0 || ((telem_hub[i]>=hubproto) && hubproto!=0))) { + QModelIndex index = b->model()->index(i, 0); + QVariant v(0); + b->model()->setData(index, v, Qt::UserRole - 1); + } + } + + if (value>=sizeof(telem_hub)/sizeof(int)) + b->setCurrentIndex(0); + else if (telem_hub[value]==0 || ((telem_hub[value]>=hubproto) && hubproto!=0)) { + b->setCurrentIndex(value); + } + + b->setMaxVisibleItems(10); +} + TelemetryCustomScreen::~TelemetryCustomScreen() { delete ui; diff --git a/companion/src/modeledit/telemetry.h b/companion/src/modeledit/telemetry.h index 44233f79c..cd804465a 100644 --- a/companion/src/modeledit/telemetry.h +++ b/companion/src/modeledit/telemetry.h @@ -61,6 +61,9 @@ class TelemetryCustomScreen : public ModelPanel void barMinChanged(double value); void barMaxChanged(double value); + protected: + void populateTelemetrySourceCB(QComboBox *b, unsigned int value, bool last, int hubproto); + private: void updateBar(int line); Ui::TelemetryCustomScreen * ui;