1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-23 16:25:16 +03:00

Telemetry bars should be again ok in Companion

This commit is contained in:
Bertrand Songis 2014-01-28 23:51:37 +01:00
parent 7d88ff506e
commit 35659a09a4
3 changed files with 36 additions and 52 deletions

View file

@ -37,12 +37,16 @@ void getEEPROMString(char *dst, const char *src, int size)
} }
} }
RawSourceRange RawSource::getRange() RawSourceRange RawSource::getRange(bool singleprec)
{ {
RawSourceRange result; RawSourceRange result;
int board = GetEepromInterface()->getBoard(); int board = GetEepromInterface()->getBoard();
if (!singleprec && !IS_TARANIS(board)) {
singleprec = true;
}
switch (type) { switch (type) {
case SOURCE_TYPE_TELEMETRY: case SOURCE_TYPE_TELEMETRY:
switch (index) { switch (index) {
@ -53,12 +57,14 @@ RawSourceRange RawSource::getRange()
break; break;
case TELEMETRY_SOURCE_TIMER1: case TELEMETRY_SOURCE_TIMER1:
case TELEMETRY_SOURCE_TIMER2: case TELEMETRY_SOURCE_TIMER2:
result.step = IS_TARANIS(board) ? 1 : 3; result.step = singleprec ? 3 : 1;
result.max = 765; result.max = singleprec ? 765 : 7200;
result.offset = 128;
break; break;
case TELEMETRY_SOURCE_RSSI_TX: case TELEMETRY_SOURCE_RSSI_TX:
case TELEMETRY_SOURCE_RSSI_RX: case TELEMETRY_SOURCE_RSSI_RX:
result.max = 100; result.max = 100;
result.offset = 128;
break; break;
case TELEMETRY_SOURCE_A1: case TELEMETRY_SOURCE_A1:
case TELEMETRY_SOURCE_A2: case TELEMETRY_SOURCE_A2:
@ -78,12 +84,13 @@ RawSourceRange RawSource::getRange()
// result.offset = result.min; // result.offset = result.min;
} }
} }
result.offset = 128;
break; break;
case TELEMETRY_SOURCE_ALT: case TELEMETRY_SOURCE_ALT:
case TELEMETRY_SOURCE_GPS_ALT: case TELEMETRY_SOURCE_GPS_ALT:
result.step = IS_TARANIS(board) ? 1 : 8; result.step = singleprec ? 8 : 1;
result.min = -500; result.min = -500;
result.max = 1540; result.max = singleprec ? 1540 : 3000;
// result.offset = 524; // result.offset = 524;
break; break;
case TELEMETRY_SOURCE_T1: case TELEMETRY_SOURCE_T1:
@ -93,16 +100,17 @@ RawSourceRange RawSource::getRange()
// result.offset = 98; // result.offset = 98;
break; break;
case TELEMETRY_SOURCE_RPM: case TELEMETRY_SOURCE_RPM:
result.step = IS_TARANIS(board) ? 1 : 50; result.step = singleprec ? 50 : 1;
result.max = 12750; result.max = singleprec ? 12750 : 20000;
// result.offset = 6400; // result.offset = 6400;
break; break;
case TELEMETRY_SOURCE_FUEL: case TELEMETRY_SOURCE_FUEL:
result.max = 100; result.max = 100;
result.offset = 128;
break; break;
case TELEMETRY_SOURCE_SPEED: case TELEMETRY_SOURCE_SPEED:
result.step = IS_TARANIS(board) ? 1 : 4; result.step = singleprec ? 4 : 1;
result.max = 944; result.max = singleprec ? 944 : 2000;
// result.offset = 474; // result.offset = 474;
if (model && !model->frsky.imperial) { if (model && !model->frsky.imperial) {
result.step *= 1.852; result.step *= 1.852;
@ -110,12 +118,12 @@ RawSourceRange RawSource::getRange()
} }
break; break;
case TELEMETRY_SOURCE_DIST: case TELEMETRY_SOURCE_DIST:
result.step = IS_TARANIS(board) ? 1 : 8; result.step = singleprec ? 8 : 1;
result.max = 2040; result.max = singleprec ? 2040 : 10000;
// result.offset = 1024; // result.offset = 1024;
break; break;
case TELEMETRY_SOURCE_CELL: case TELEMETRY_SOURCE_CELL:
result.step = IS_TARANIS(board) ? 0.01 : 0.02; result.step = singleprec ? 0.02 : 0.01;
result.max = 5.1; result.max = 5.1;
result.decimals = 2; result.decimals = 2;
// result.offset = 2.56; // result.offset = 2.56;
@ -125,19 +133,23 @@ RawSourceRange RawSource::getRange()
result.step = 0.1; result.step = 0.1;
result.max = 25.5; result.max = 25.5;
result.decimals = 1; result.decimals = 1;
result.offset = 128;
break; break;
case TELEMETRY_SOURCE_CURRENT: case TELEMETRY_SOURCE_CURRENT:
result.step = IS_TARANIS(board) ? 0.1 : 0.5; result.step = singleprec ? 0.5 : 0.1;
result.max = 127.5; result.max = singleprec ? 127.5 : 200.0;
result.decimals = 1; result.decimals = 1;
result.offset = 128;
break; break;
case TELEMETRY_SOURCE_CONSUMPTION: case TELEMETRY_SOURCE_CONSUMPTION:
result.step = IS_TARANIS(board) ? 1 : 20; result.step = singleprec ? 20 : 1;
result.max = 5100; result.max = singleprec ? 5100 : 10000;
result.offset = 128;
break; break;
case TELEMETRY_SOURCE_POWER: case TELEMETRY_SOURCE_POWER:
result.step = IS_TARANIS(board) ? 1 : 5; result.step = singleprec ? 5 : 1;
result.max = 1275; result.max = singleprec ? 1275 : 2000;
result.offset = 128;
break; break;
default: default:
result.max = 125; result.max = 125;
@ -154,34 +166,6 @@ RawSourceRange RawSource::getRange()
return result; return result;
} }
#if 0
int RawSource::getRawOffset(const ModelData & Model)
{
switch (type) {
case SOURCE_TYPE_TELEMETRY:
switch (index) {
case TELEMETRY_SOURCE_TIMER1:
case TELEMETRY_SOURCE_TIMER2:
case TELEMETRY_SOURCE_RSSI_TX:
case TELEMETRY_SOURCE_RSSI_RX:
case TELEMETRY_SOURCE_A1:
case TELEMETRY_SOURCE_A2:
case TELEMETRY_SOURCE_FUEL:
case TELEMETRY_SOURCE_CELLS_SUM:
case TELEMETRY_SOURCE_VFAS:
case TELEMETRY_SOURCE_CURRENT:
case TELEMETRY_SOURCE_CONSUMPTION:
case TELEMETRY_SOURCE_POWER:
return 128;
default:
return 0;
}
default:
return 0;
}
}
#endif
QString AnalogString(int index) QString AnalogString(int index)
{ {
static const QString sticks[] = { QObject::tr("Rud"), QObject::tr("Ele"), QObject::tr("Thr"), QObject::tr("Ail") }; static const QString sticks[] = { QObject::tr("Rud"), QObject::tr("Ele"), QObject::tr("Thr"), QObject::tr("Ail") };

View file

@ -337,7 +337,7 @@ class RawSource {
QString toString(); QString toString();
RawSourceRange getRange(); RawSourceRange getRange(bool singleprec=false);
bool operator == ( const RawSource & other) { bool operator == ( const RawSource & other) {
return (this->type == other.type) && (this->index == other.index); return (this->type == other.type) && (this->index == other.index);

View file

@ -531,7 +531,7 @@ void TelemetryPanel::setup()
int field = j%4; int field = j%4;
populateCustomScreenFieldCB(barsCB[j], model.frsky.screens[screen].body.bars[field].source, false, model.frsky.usrProto); populateCustomScreenFieldCB(barsCB[j], model.frsky.screens[screen].body.bars[field].source, false, model.frsky.usrProto);
RawSource source = RawSource(SOURCE_TYPE_TELEMETRY, model.frsky.screens[screen].body.bars[field].source, &model); RawSource source = RawSource(SOURCE_TYPE_TELEMETRY, model.frsky.screens[screen].body.bars[field].source, &model);
RawSourceRange range = source.getRange(); RawSourceRange range = source.getRange(true);
minSB[j]->setDecimals(range.decimals); minSB[j]->setDecimals(range.decimals);
minSB[j]->setMinimum(range.min); minSB[j]->setMinimum(range.min);
minSB[j]->setMaximum(range.max); minSB[j]->setMaximum(range.max);
@ -754,7 +754,7 @@ void TelemetryPanel::telBarUpdate()
index=barsCB[i]->currentIndex(); index=barsCB[i]->currentIndex();
if (index==TELEMETRY_SOURCE_A1 || index==TELEMETRY_SOURCE_A1 || index==TELEMETRY_SOURCE_A1_MIN || index==TELEMETRY_SOURCE_A2_MIN) { if (index==TELEMETRY_SOURCE_A1 || index==TELEMETRY_SOURCE_A1 || index==TELEMETRY_SOURCE_A1_MIN || index==TELEMETRY_SOURCE_A2_MIN) {
RawSource source = RawSource(SOURCE_TYPE_TELEMETRY, index, &model); RawSource source = RawSource(SOURCE_TYPE_TELEMETRY, index, &model);
RawSourceRange range = source.getRange(); RawSourceRange range = source.getRange(true);
minSB[i]->setMinimum(range.min); minSB[i]->setMinimum(range.min);
minSB[i]->setMaximum(range.max); minSB[i]->setMaximum(range.max);
minSB[i]->setSingleStep(range.step); minSB[i]->setSingleStep(range.step);
@ -805,7 +805,7 @@ void TelemetryPanel::telBarCBcurrentIndexChanged(int index)
maxSB[bar]->setEnabled(true); maxSB[bar]->setEnabled(true);
} }
RawSource source = RawSource(SOURCE_TYPE_TELEMETRY, index-1, &model); RawSource source = RawSource(SOURCE_TYPE_TELEMETRY, index-1, &model);
RawSourceRange range = source.getRange(); RawSourceRange range = source.getRange(true);
minSB[bar]->setDecimals(range.decimals); minSB[bar]->setDecimals(range.decimals);
minSB[bar]->setMinimum(range.min); minSB[bar]->setMinimum(range.min);
minSB[bar]->setMaximum(range.max); minSB[bar]->setMaximum(range.max);
@ -830,7 +830,7 @@ void TelemetryPanel::telMinSBeditingFinished()
int barId = spinBox->objectName().right(1).toInt() - 1; int barId = spinBox->objectName().right(1).toInt() - 1;
int minId = barId+screenId*4; int minId = barId+screenId*4;
RawSource source = RawSource(SOURCE_TYPE_TELEMETRY, model.frsky.screens[screenId].body.bars[barId].source, &model); RawSource source = RawSource(SOURCE_TYPE_TELEMETRY, model.frsky.screens[screenId].body.bars[barId].source, &model);
RawSourceRange range = source.getRange(); RawSourceRange range = source.getRange(true);
if (model.frsky.screens[screenId].body.bars[barId].source==TELEMETRY_SOURCE_A1 || model.frsky.screens[screenId].body.bars[barId].source==TELEMETRY_SOURCE_A1_MIN) { if (model.frsky.screens[screenId].body.bars[barId].source==TELEMETRY_SOURCE_A1 || model.frsky.screens[screenId].body.bars[barId].source==TELEMETRY_SOURCE_A1_MIN) {
model.frsky.screens[screenId].body.bars[barId].barMin = round((minSB[minId]->value()-analogs[0]->ui->CalibSB->value())/range.step); model.frsky.screens[screenId].body.bars[barId].barMin = round((minSB[minId]->value()-analogs[0]->ui->CalibSB->value())/range.step);
} }
@ -860,7 +860,7 @@ void TelemetryPanel::telMaxSBeditingFinished()
int barId = spinBox->objectName().right(1).toInt() - 1; int barId = spinBox->objectName().right(1).toInt() - 1;
lock = true; lock = true;
RawSource source = RawSource(SOURCE_TYPE_TELEMETRY, model.frsky.screens[screenId].body.bars[barId].source, &model); RawSource source = RawSource(SOURCE_TYPE_TELEMETRY, model.frsky.screens[screenId].body.bars[barId].source, &model);
RawSourceRange range = source.getRange(); RawSourceRange range = source.getRange(true);
if (model.frsky.screens[screenId].body.bars[barId].source==5) { if (model.frsky.screens[screenId].body.bars[barId].source==5) {
model.frsky.screens[screenId].body.bars[barId].barMax = (255-round((spinBox->value()-analogs[0]->ui->CalibSB->value())/range.step)); model.frsky.screens[screenId].body.bars[barId].barMax = (255-round((spinBox->value()-analogs[0]->ui->CalibSB->value())/range.step));
} }