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("
");
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("| "+tr("L")+QString("%1 | ").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(""+getFrSkyAlarmType(fd->rssiAlarms[1].level)+" | < | "+QString::number(fd->rssiAlarms[1].value,10)+" | ");
str.append(" | ");
str.append("| "+tr("Frsky serial protocol")+" | "+getFrSkyProtocol(fd->usrProto)+" | ");
- str.append("| "+tr("Units system")+" | "+getFrSkyMeasure(fd->imperial)+" | ");
str.append("| "+tr("Blades")+" | "+fd->blades+" | ");
str.append(" | ");
}
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);
|