Input scale now added in Companion. I have broken all getStep / getMin /
getMax / getOffset used for custom switches and telemetry bars. Everything needs to be tested again ...
This commit is contained in:
@@ -146,36 +146,43 @@ void CustomSwitchesPanel::edited()
|
||||
{
|
||||
case (CS_FAMILY_VOFS):
|
||||
if (model.customSw[i].val1 != cswitchSource1[i]->itemData(cswitchSource1[i]->currentIndex()).toInt()) {
|
||||
source=RawSource(model.customSw[i].val1);
|
||||
source = RawSource(model.customSw[i].val1, &model);
|
||||
model.customSw[i].val1 = cswitchSource1[i]->itemData(cswitchSource1[i]->currentIndex()).toInt();
|
||||
RawSource newSource = RawSource(model.customSw[i].val1);
|
||||
RawSource newSource = RawSource(model.customSw[i].val1, &model);
|
||||
if (newSource.type == SOURCE_TYPE_TELEMETRY) {
|
||||
if (model.customSw[i].func>CS_FN_ELESS && model.customSw[i].func<CS_FN_VEQUAL) {
|
||||
model.customSw[i].val2 = 0;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
model.customSw[i].val2 = -128;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
RawSourceRange range = source.getRange();
|
||||
if (model.customSw[i].func>CS_FN_ELESS && model.customSw[i].func<CS_FN_VEQUAL) {
|
||||
model.customSw[i].val2 = (cswitchOffset[i]->value()/source.getStep(model));
|
||||
} else {
|
||||
model.customSw[i].val2 = ((cswitchOffset[i]->value()-source.getOffset(model))/source.getStep(model))-source.getRawOffset(model);
|
||||
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)*/;
|
||||
}
|
||||
}
|
||||
setSwitchWidgetVisibility(i);
|
||||
} else {
|
||||
source=RawSource(model.customSw[i].val1);
|
||||
}
|
||||
else {
|
||||
source = RawSource(model.customSw[i].val1, &model);
|
||||
RawSourceRange range = source.getRange();
|
||||
if (model.customSw[i].func>CS_FN_ELESS && model.customSw[i].func<CS_FN_VEQUAL) {
|
||||
model.customSw[i].val2 = (cswitchOffset[i]->value()/source.getStep(model));
|
||||
cswitchOffset[i]->setValue(model.customSw[i].val2*source.getStep(model));
|
||||
} else {
|
||||
model.customSw[i].val2 = ((cswitchOffset[i]->value()-source.getOffset(model))/source.getStep(model))-source.getRawOffset(model);
|
||||
cswitchOffset[i]->setValue((model.customSw[i].val2 +source.getRawOffset(model))*source.getStep(model)+source.getOffset(model));
|
||||
model.customSw[i].val2 = (cswitchOffset[i]->value() / range.step);
|
||||
cswitchOffset[i]->setValue(model.customSw[i].val2*range.step);
|
||||
}
|
||||
else {
|
||||
model.customSw[i].val2 = ((cswitchOffset[i]->value()-range.offset)/range.step)/* TODO - source.getRawOffset(model)*/;
|
||||
cswitchOffset[i]->setValue((model.customSw[i].val2 /* + TODO source.getRawOffset(model)*/)*range.step+range.offset);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case (CS_FAMILY_TIMERS): {
|
||||
value=cswitchOffset[i]->value();
|
||||
value = cswitchOffset[i]->value();
|
||||
newval=TimToVal(value);
|
||||
if (newval>model.customSw[i].val2) {
|
||||
if (value >=60) {
|
||||
@@ -246,7 +253,9 @@ void CustomSwitchesPanel::edited()
|
||||
|
||||
void CustomSwitchesPanel::setSwitchWidgetVisibility(int i)
|
||||
{
|
||||
RawSource source = RawSource(model.customSw[i].val1);
|
||||
RawSource source = RawSource(model.customSw[i].val1, &model);
|
||||
RawSourceRange range = source.getRange();
|
||||
|
||||
switch (getCSFunctionFamily(model.customSw[i].func))
|
||||
{
|
||||
case CS_FAMILY_VOFS:
|
||||
@@ -255,16 +264,16 @@ void CustomSwitchesPanel::setSwitchWidgetVisibility(int i)
|
||||
cswitchValue[i]->setVisible(false);
|
||||
cswitchOffset[i]->setVisible(true);
|
||||
populateSourceCB(cswitchSource1[i], source, model, POPULATE_SOURCES | POPULATE_VIRTUAL_INPUTS | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (GetEepromInterface()->getCapability(GvarsInCS) ? POPULATE_GVARS : 0));
|
||||
cswitchOffset[i]->setDecimals(source.getDecimals(model));
|
||||
cswitchOffset[i]->setSingleStep(source.getStep(model));
|
||||
cswitchOffset[i]->setDecimals(range.decimals);
|
||||
cswitchOffset[i]->setSingleStep(range.step);
|
||||
if (model.customSw[i].func>CS_FN_ELESS && model.customSw[i].func<CS_FN_VEQUAL) {
|
||||
cswitchOffset[i]->setMinimum(source.getStep(model)*-127);
|
||||
cswitchOffset[i]->setMaximum(source.getStep(model)*127);
|
||||
cswitchOffset[i]->setValue(source.getStep(model)*model.customSw[i].val2);
|
||||
cswitchOffset[i]->setMinimum(range.step*-127);
|
||||
cswitchOffset[i]->setMaximum(range.step*127);
|
||||
cswitchOffset[i]->setValue(range.step*model.customSw[i].val2);
|
||||
} else {
|
||||
cswitchOffset[i]->setMinimum(source.getMin(model));
|
||||
cswitchOffset[i]->setMaximum(source.getMax(model));
|
||||
cswitchOffset[i]->setValue(source.getStep(model)*(model.customSw[i].val2+source.getRawOffset(model))+source.getOffset(model));
|
||||
cswitchOffset[i]->setMinimum(range.min);
|
||||
cswitchOffset[i]->setMaximum(range.max);
|
||||
cswitchOffset[i]->setValue(range.step*(model.customSw[i].val2/* TODO+source.getRawOffset(model)*/)+range.offset);
|
||||
}
|
||||
break;
|
||||
case CS_FAMILY_VBOOL:
|
||||
|
||||
@@ -48,7 +48,7 @@ ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, i
|
||||
ui->sideLabel->hide();
|
||||
ui->sideCB->hide();
|
||||
ui->inputName->setMaxLength(4);
|
||||
populateSourceCB(ui->sourceCB, ed->srcRaw, model, POPULATE_SOURCES | POPULATE_SWITCHES | POPULATE_TRIMS | (GetEepromInterface()->getCapability(GvarsAsSources) ? POPULATE_GVARS : 0));
|
||||
populateSourceCB(ui->sourceCB, ed->srcRaw, model, POPULATE_SOURCES | POPULATE_SWITCHES | POPULATE_TRIMS | POPULATE_TELEMETRY);
|
||||
ui->sourceCB->removeItem(0);
|
||||
}
|
||||
else {
|
||||
@@ -56,8 +56,6 @@ ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, i
|
||||
ui->inputName->hide();
|
||||
ui->sourceLabel->hide();
|
||||
ui->sourceCB->hide();
|
||||
ui->scaleLabel->hide();
|
||||
ui->scaleSB->hide();
|
||||
ui->trimLabel->hide();
|
||||
ui->trimCB->hide();
|
||||
}
|
||||
@@ -83,13 +81,15 @@ ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, i
|
||||
ui->lineName->setValidator(new QRegExpValidator(rx, this));
|
||||
ui->lineName->setText(ed->name);
|
||||
|
||||
updateScale();
|
||||
valuesChanged();
|
||||
|
||||
connect(ui->lineName,SIGNAL(editingFinished()), this, SLOT(valuesChanged()));
|
||||
connect(ui->sourceCB,SIGNAL(currentIndexChanged(int)), this, SLOT(valuesChanged()));
|
||||
connect(ui->trimCB,SIGNAL(currentIndexChanged(int)), this, SLOT(valuesChanged()));
|
||||
connect(ui->switchesCB,SIGNAL(currentIndexChanged(int)), this, SLOT(valuesChanged()));
|
||||
connect(ui->sideCB,SIGNAL(currentIndexChanged(int)), this, SLOT(valuesChanged()));
|
||||
connect(ui->lineName, SIGNAL(editingFinished()), this, SLOT(valuesChanged()));
|
||||
connect(ui->sourceCB, SIGNAL(currentIndexChanged(int)), this, SLOT(valuesChanged()));
|
||||
connect(ui->scale, SIGNAL(editingFinished()), this, SLOT(valuesChanged()));
|
||||
connect(ui->trimCB, SIGNAL(currentIndexChanged(int)), this, SLOT(valuesChanged()));
|
||||
connect(ui->switchesCB, SIGNAL(currentIndexChanged(int)), this, SLOT(valuesChanged()));
|
||||
connect(ui->sideCB, SIGNAL(currentIndexChanged(int)), this, SLOT(valuesChanged()));
|
||||
for (int i=0; i<9; i++) {
|
||||
connect(cb_fp[i], SIGNAL(toggled(bool)), this, SLOT(valuesChanged()));
|
||||
}
|
||||
@@ -103,23 +103,35 @@ ExpoDialog::~ExpoDialog()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void ExpoDialog::changeEvent(QEvent *e)
|
||||
void ExpoDialog::updateScale()
|
||||
{
|
||||
QDialog::changeEvent(e);
|
||||
switch (e->type()) {
|
||||
case QEvent::LanguageChange:
|
||||
ui->retranslateUi(this);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (GetEepromInterface()->getCapability(VirtualInputs) && ed->srcRaw.type == SOURCE_TYPE_TELEMETRY) {
|
||||
RawSourceRange range = ed->srcRaw.getRange();
|
||||
ui->scaleLabel->show();
|
||||
ui->scale->show();
|
||||
ui->scale->setDecimals(range.decimals);
|
||||
ui->scale->setMinimum(range.min);
|
||||
ui->scale->setMaximum(range.max);
|
||||
ui->scale->setValue(round(range.step * ed->scale));
|
||||
}
|
||||
else {
|
||||
ui->scaleLabel->hide();
|
||||
ui->scale->hide();
|
||||
}
|
||||
}
|
||||
|
||||
void ExpoDialog::valuesChanged()
|
||||
{
|
||||
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 };
|
||||
|
||||
ed->srcRaw = RawSource(ui->sourceCB->itemData(ui->sourceCB->currentIndex()).toInt());
|
||||
RawSource srcRaw = RawSource(ui->sourceCB->itemData(ui->sourceCB->currentIndex()).toInt());
|
||||
if (ed->srcRaw != srcRaw) {
|
||||
ed->srcRaw = srcRaw;
|
||||
updateScale();
|
||||
}
|
||||
|
||||
RawSourceRange range = srcRaw.getRange();
|
||||
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());
|
||||
ed->mode = ui->sideCB->currentIndex() + 1;
|
||||
@@ -173,5 +185,5 @@ void ExpoDialog::valuesChanged()
|
||||
|
||||
void ExpoDialog::shrink()
|
||||
{
|
||||
resize(0,0);
|
||||
resize(0, 0);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ class ExpoDialog : public QDialog {
|
||||
~ExpoDialog();
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e);
|
||||
void updateScale();
|
||||
|
||||
private slots:
|
||||
void valuesChanged();
|
||||
|
||||
@@ -330,7 +330,7 @@ If blank then the input is considered to be "ON" all the time.</string
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QDoubleSpinBox" name="scaleSB">
|
||||
<widget class="QDoubleSpinBox" name="scale">
|
||||
<property name="whatsThis">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
@@ -441,6 +441,32 @@ p, li { white-space: pre-wrap; }
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>inputName</tabstop>
|
||||
<tabstop>lineName</tabstop>
|
||||
<tabstop>sourceCB</tabstop>
|
||||
<tabstop>scale</tabstop>
|
||||
<tabstop>trimCB</tabstop>
|
||||
<tabstop>weightGV</tabstop>
|
||||
<tabstop>weightSB</tabstop>
|
||||
<tabstop>weightCB</tabstop>
|
||||
<tabstop>curveTypeCB</tabstop>
|
||||
<tabstop>curveGVarCB</tabstop>
|
||||
<tabstop>curveValueCB</tabstop>
|
||||
<tabstop>curveValueSB</tabstop>
|
||||
<tabstop>cb_FP0</tabstop>
|
||||
<tabstop>cb_FP1</tabstop>
|
||||
<tabstop>cb_FP2</tabstop>
|
||||
<tabstop>cb_FP3</tabstop>
|
||||
<tabstop>cb_FP4</tabstop>
|
||||
<tabstop>cb_FP5</tabstop>
|
||||
<tabstop>cb_FP6</tabstop>
|
||||
<tabstop>cb_FP7</tabstop>
|
||||
<tabstop>cb_FP8</tabstop>
|
||||
<tabstop>switchesCB</tabstop>
|
||||
<tabstop>sideCB</tabstop>
|
||||
<tabstop>buttonBox</tabstop>
|
||||
</tabstops>
|
||||
<resources>
|
||||
<include location="../companion.qrc"/>
|
||||
</resources>
|
||||
|
||||
@@ -20,7 +20,7 @@ MixerDialog::MixerDialog(QWidget *parent, ModelData & model, MixData *mixdata, i
|
||||
else
|
||||
this->setWindowTitle(tr("DEST -> CH%1%2").arg(md->destCh/10).arg(md->destCh%10));
|
||||
|
||||
populateSourceCB(ui->sourceCB, md->srcRaw, model, POPULATE_SOURCES | POPULATE_VIRTUAL_INPUTS | POPULATE_SWITCHES | POPULATE_TRIMS | (GetEepromInterface()->getCapability(GvarsAsSources) ? POPULATE_GVARS : 0));
|
||||
populateSourceCB(ui->sourceCB, md->srcRaw, model, POPULATE_SOURCES | POPULATE_VIRTUAL_INPUTS | POPULATE_SWITCHES | POPULATE_TRIMS);
|
||||
ui->sourceCB->removeItem(0);
|
||||
|
||||
int limit = GetEepromInterface()->getCapability(OffsetWeight);
|
||||
|
||||
@@ -530,44 +530,27 @@ void TelemetryPanel::setup()
|
||||
int screen = j/4;
|
||||
int field = j%4;
|
||||
populateCustomScreenFieldCB(barsCB[j], model.frsky.screens[screen].body.bars[field].source, false, model.frsky.usrProto);
|
||||
switch (model.frsky.screens[screen].body.bars[field].source-1) {
|
||||
case TELEMETRY_SOURCE_TX_BATT:
|
||||
case TELEMETRY_SOURCE_A1:
|
||||
case TELEMETRY_SOURCE_A1_MIN:
|
||||
case TELEMETRY_SOURCE_A2:
|
||||
case TELEMETRY_SOURCE_A2_MIN:
|
||||
case TELEMETRY_SOURCE_CELLS_SUM:
|
||||
case TELEMETRY_SOURCE_VFAS:
|
||||
case TELEMETRY_SOURCE_CURRENT_MAX:
|
||||
case TELEMETRY_SOURCE_CURRENT:
|
||||
minSB[j]->setDecimals(1);
|
||||
maxSB[j]->setDecimals(1);
|
||||
break;
|
||||
case TELEMETRY_SOURCE_CELL:
|
||||
minSB[j]->setDecimals(2);
|
||||
maxSB[j]->setDecimals(2);
|
||||
break;
|
||||
default:
|
||||
minSB[j]->setDecimals(0);
|
||||
maxSB[j]->setDecimals(0);
|
||||
}
|
||||
minSB[j]->setMinimum(getBarValue(model.frsky.screens[screen].body.bars[field].source, 0, &model.frsky));
|
||||
minSB[j]->setMaximum(getBarValue(model.frsky.screens[screen].body.bars[field].source, 255, &model.frsky));
|
||||
minSB[j]->setSingleStep(getBarStep(model.frsky.screens[screen].body.bars[field].source));
|
||||
minSB[j]->setValue(getBarValue(model.frsky.screens[screen].body.bars[field].source, model.frsky.screens[screen].body.bars[field].barMin, &model.frsky));
|
||||
maxSB[j]->setMinimum(getBarValue(model.frsky.screens[screen].body.bars[field].source, 0, &model.frsky));
|
||||
maxSB[j]->setMaximum(getBarValue(model.frsky.screens[screen].body.bars[field].source, 255, &model.frsky));
|
||||
maxSB[j]->setSingleStep(getBarStep(model.frsky.screens[screen].body.bars[field].source));
|
||||
maxSB[j]->setValue(getBarValue(model.frsky.screens[screen].body.bars[field].source, (255-model.frsky.screens[screen].body.bars[field].barMax), &model.frsky));
|
||||
|
||||
RawSource source = RawSource(SOURCE_TYPE_TELEMETRY, model.frsky.screens[screen].body.bars[field].source, &model);
|
||||
RawSourceRange range = source.getRange();
|
||||
minSB[j]->setDecimals(range.decimals);
|
||||
minSB[j]->setMinimum(range.min);
|
||||
minSB[j]->setMaximum(range.max);
|
||||
minSB[j]->setSingleStep(range.step);
|
||||
minSB[j]->setValue(range.getValue(model.frsky.screens[screen].body.bars[field].barMin));
|
||||
maxSB[j]->setDecimals(range.decimals);
|
||||
maxSB[j]->setMinimum(range.min);
|
||||
maxSB[j]->setMaximum(range.max);
|
||||
maxSB[j]->setSingleStep(range.step);
|
||||
maxSB[j]->setValue(range.getValue(255 - model.frsky.screens[screen].body.bars[field].barMax));
|
||||
if (model.frsky.screens[screen].body.bars[field].source==0 || model.frsky.screens[screen].type==0) {
|
||||
minSB[j]->setDisabled(true);
|
||||
maxSB[j]->setDisabled(true);
|
||||
}
|
||||
connect(barsCB[j],SIGNAL(currentIndexChanged(int)),this,SLOT(telBarCBcurrentIndexChanged(int)));
|
||||
connect(maxSB[j],SIGNAL(editingFinished()),this,SLOT(telMaxSBeditingFinished()));
|
||||
connect(minSB[j],SIGNAL(editingFinished()),this,SLOT(telMinSBeditingFinished()));
|
||||
connect(barsCB[j], SIGNAL(currentIndexChanged(int)), this, SLOT(telBarCBcurrentIndexChanged(int)));
|
||||
connect(maxSB[j], SIGNAL(editingFinished()), this, SLOT(telMaxSBeditingFinished()));
|
||||
connect(minSB[j], SIGNAL(editingFinished()), this, SLOT(telMinSBeditingFinished()));
|
||||
}
|
||||
|
||||
lock=false;
|
||||
}
|
||||
|
||||
@@ -770,14 +753,16 @@ void TelemetryPanel::telBarUpdate()
|
||||
int screen=i/4;
|
||||
index=barsCB[i]->currentIndex();
|
||||
if (index==TELEMETRY_SOURCE_A1 || index==TELEMETRY_SOURCE_A1 || index==TELEMETRY_SOURCE_A1_MIN || index==TELEMETRY_SOURCE_A2_MIN) {
|
||||
minSB[i]->setMinimum(getBarValue(index, 0, &model.frsky));
|
||||
minSB[i]->setMaximum(getBarValue(index, 255, &model.frsky));
|
||||
minSB[i]->setSingleStep(getBarStep(index));
|
||||
maxSB[i]->setMinimum(getBarValue(index, 0, &model.frsky));
|
||||
maxSB[i]->setMaximum(getBarValue(index, 255, &model.frsky));
|
||||
maxSB[i]->setSingleStep(getBarStep(index));
|
||||
minSB[i]->setValue(getBarValue(index, model.frsky.screens[screen].body.bars[i%4].barMin, &model.frsky));
|
||||
maxSB[i]->setValue(getBarValue(index, 255-model.frsky.screens[screen].body.bars[i%4].barMax, &model.frsky));
|
||||
RawSource source = RawSource(SOURCE_TYPE_TELEMETRY, index, &model);
|
||||
RawSourceRange range = source.getRange();
|
||||
minSB[i]->setMinimum(range.min);
|
||||
minSB[i]->setMaximum(range.max);
|
||||
minSB[i]->setSingleStep(range.step);
|
||||
maxSB[i]->setMinimum(range.min);
|
||||
maxSB[i]->setMaximum(range.max);
|
||||
maxSB[i]->setSingleStep(range.step);
|
||||
minSB[i]->setValue(range.getValue(model.frsky.screens[screen].body.bars[i%4].barMin));
|
||||
maxSB[i]->setValue(range.getValue(255 - model.frsky.screens[screen].body.bars[i%4].barMax));
|
||||
}
|
||||
}
|
||||
lock=false;
|
||||
@@ -785,116 +770,110 @@ void TelemetryPanel::telBarUpdate()
|
||||
|
||||
void TelemetryPanel::ScreenTypeCBcurrentIndexChanged(int index)
|
||||
{
|
||||
if (lock) return;
|
||||
|
||||
if (!lock) {
|
||||
lock = true;
|
||||
QComboBox *comboBox = qobject_cast<QComboBox*>(sender());
|
||||
int screen = comboBox->objectName().right(1).toInt() -1;
|
||||
lock=true;
|
||||
model.frsky.screens[screen].type=index;
|
||||
|
||||
model.frsky.screens[screen].type = index;
|
||||
for (int i=0; i<3; i++) {
|
||||
bool isNum = (model.frsky.screens[i].type==0);
|
||||
barsGB[i]->setVisible(!isNum);
|
||||
numsGB[i]->setVisible(isNum);
|
||||
}
|
||||
|
||||
lock=false;
|
||||
lock = false;
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
|
||||
void TelemetryPanel::telBarCBcurrentIndexChanged(int index)
|
||||
{
|
||||
if (lock) return;
|
||||
if (!lock) {
|
||||
lock = true;
|
||||
QComboBox *comboBox = qobject_cast<QComboBox*>(sender());
|
||||
int screenId = comboBox->objectName().mid(8,1).toInt() - 1;
|
||||
int barId = comboBox->objectName().mid(10,1).toInt() - 1;
|
||||
int bar=barId+screenId*4;
|
||||
model.frsky.screens[screenId].body.bars[barId].source=index;
|
||||
lock=true;
|
||||
if (index==0) {
|
||||
model.frsky.screens[screenId].body.bars[barId].barMin=0;
|
||||
model.frsky.screens[screenId].body.bars[barId].barMax=0;
|
||||
minSB[bar]->setDisabled(true);
|
||||
maxSB[bar]->setDisabled(true);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
minSB[bar]->setEnabled(true);
|
||||
maxSB[bar]->setEnabled(true);
|
||||
}
|
||||
switch (index-1) {
|
||||
case TELEMETRY_SOURCE_TX_BATT:
|
||||
case TELEMETRY_SOURCE_A1:
|
||||
case TELEMETRY_SOURCE_A1_MIN:
|
||||
case TELEMETRY_SOURCE_A2:
|
||||
case TELEMETRY_SOURCE_A2_MIN:
|
||||
case TELEMETRY_SOURCE_CELLS_SUM:
|
||||
case TELEMETRY_SOURCE_VFAS:
|
||||
case TELEMETRY_SOURCE_CURRENT_MAX:
|
||||
case TELEMETRY_SOURCE_CURRENT:
|
||||
minSB[bar]->setDecimals(1);
|
||||
maxSB[bar]->setDecimals(1);
|
||||
break;
|
||||
case TELEMETRY_SOURCE_CELL:
|
||||
minSB[bar]->setDecimals(2);
|
||||
maxSB[bar]->setDecimals(2);
|
||||
break;
|
||||
default:
|
||||
minSB[bar]->setDecimals(0);
|
||||
maxSB[bar]->setDecimals(0);
|
||||
}
|
||||
minSB[bar]->setMinimum(getBarValue(index, 0, &model.frsky));
|
||||
minSB[bar]->setMaximum(getBarValue(index, 255, &model.frsky));
|
||||
minSB[bar]->setSingleStep(getBarStep(index));
|
||||
maxSB[bar]->setMinimum(getBarValue(index, 0, &model.frsky));
|
||||
maxSB[bar]->setMaximum(getBarValue(index, 255, &model.frsky));
|
||||
maxSB[bar]->setSingleStep(getBarStep(index));
|
||||
minSB[bar]->setValue(getBarValue(index, model.frsky.screens[screenId].body.bars[barId].barMin, &model.frsky));
|
||||
maxSB[bar]->setValue(getBarValue(index, 255-model.frsky.screens[screenId].body.bars[barId].barMax, &model.frsky));
|
||||
lock=false;
|
||||
RawSource source = RawSource(SOURCE_TYPE_TELEMETRY, index-1, &model);
|
||||
RawSourceRange range = source.getRange();
|
||||
minSB[bar]->setDecimals(range.decimals);
|
||||
minSB[bar]->setMinimum(range.min);
|
||||
minSB[bar]->setMaximum(range.max);
|
||||
minSB[bar]->setSingleStep(range.step);
|
||||
maxSB[bar]->setDecimals(range.decimals);
|
||||
maxSB[bar]->setMinimum(range.min);
|
||||
maxSB[bar]->setMaximum(range.max);
|
||||
maxSB[bar]->setSingleStep(range.step);
|
||||
minSB[bar]->setValue(range.getValue(model.frsky.screens[screenId].body.bars[barId].barMin));
|
||||
maxSB[bar]->setValue(range.getValue(255 - model.frsky.screens[screenId].body.bars[barId].barMax));
|
||||
lock = false;
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
|
||||
void TelemetryPanel::telMinSBeditingFinished()
|
||||
{
|
||||
if (lock) return;
|
||||
if (!lock) {
|
||||
lock = true;
|
||||
QDoubleSpinBox *spinBox = qobject_cast<QDoubleSpinBox*>(sender());
|
||||
int screenId = spinBox->objectName().mid(8,1).toInt() - 1;
|
||||
int barId = spinBox->objectName().right(1).toInt() - 1;
|
||||
int minId = barId+screenId*4;
|
||||
lock=true;
|
||||
RawSource source = RawSource(SOURCE_TYPE_TELEMETRY, model.frsky.screens[screenId].body.bars[barId].source, &model);
|
||||
RawSourceRange range = source.getRange();
|
||||
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())/getBarStep(model.frsky.screens[screenId].body.bars[barId].source));
|
||||
} else if (model.frsky.screens[screenId].body.bars[minId].source==TELEMETRY_SOURCE_A2 || model.frsky.screens[screenId].body.bars[minId].source==TELEMETRY_SOURCE_A2_MIN) {
|
||||
model.frsky.screens[screenId].body.bars[barId].barMin=round((minSB[minId]->value()-analogs[1]->ui->CalibSB->value())/getBarStep(model.frsky.screens[screenId].body.bars[barId].source));
|
||||
} else {
|
||||
model.frsky.screens[screenId].body.bars[barId].barMin=round((minSB[minId]->value()-getBarValue(model.frsky.screens[screenId].body.bars[barId].source, 0, &model.frsky))/getBarStep(model.frsky.screens[screenId].body.bars[barId].source));
|
||||
model.frsky.screens[screenId].body.bars[barId].barMin = round((minSB[minId]->value()-analogs[0]->ui->CalibSB->value())/range.step);
|
||||
}
|
||||
spinBox->setValue(getBarValue(model.frsky.screens[screenId].body.bars[barId].source, model.frsky.screens[screenId].body.bars[barId].barMin, &model.frsky));
|
||||
else if (model.frsky.screens[screenId].body.bars[minId].source==TELEMETRY_SOURCE_A2 || model.frsky.screens[screenId].body.bars[minId].source==TELEMETRY_SOURCE_A2_MIN) {
|
||||
model.frsky.screens[screenId].body.bars[barId].barMin = round((minSB[minId]->value()-analogs[1]->ui->CalibSB->value())/range.step);
|
||||
}
|
||||
else {
|
||||
model.frsky.screens[screenId].body.bars[barId].barMin = round((minSB[minId]->value()-range.getValue(0))/range.step);
|
||||
}
|
||||
spinBox->setValue(range.getValue(model.frsky.screens[screenId].body.bars[barId].barMin));
|
||||
if (maxSB[minId]->value()<minSB[minId]->value()) {
|
||||
model.frsky.screens[screenId].body.bars[minId].barMax=(255-model.frsky.screens[screenId].body.bars[barId].barMin+1);
|
||||
maxSB[minId]->setValue(getBarValue(model.frsky.screens[screenId].body.bars[barId].source, 255-model.frsky.screens[screenId].body.bars[barId].barMax, &model.frsky));
|
||||
model.frsky.screens[screenId].body.bars[minId].barMax = (255-model.frsky.screens[screenId].body.bars[barId].barMin+1);
|
||||
maxSB[minId]->setValue(range.getValue(255 - model.frsky.screens[screenId].body.bars[barId].barMax));
|
||||
}
|
||||
maxSB[minId]->setMinimum(getBarValue(model.frsky.screens[screenId].body.bars[barId].source, (model.frsky.screens[screenId].body.bars[barId].barMin+1), &model.frsky));
|
||||
lock=false;
|
||||
maxSB[minId]->setMinimum(range.getValue((model.frsky.screens[screenId].body.bars[barId].barMin+1)));
|
||||
|
||||
lock = false;
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
|
||||
void TelemetryPanel::telMaxSBeditingFinished()
|
||||
{
|
||||
if (lock) return;
|
||||
if (!lock) {
|
||||
QDoubleSpinBox *spinBox = qobject_cast<QDoubleSpinBox*>(sender());
|
||||
int screenId = spinBox->objectName().mid(8,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);
|
||||
RawSourceRange range = source.getRange();
|
||||
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())/getBarStep(model.frsky.screens[screenId].body.bars[barId].source)));
|
||||
} else if (model.frsky.screens[screenId].body.bars[barId].source==6) {
|
||||
model.frsky.screens[screenId].body.bars[barId].barMax = (255-round((spinBox->value()-analogs[1]->ui->CalibSB->value())/getBarStep(model.frsky.screens[screenId].body.bars[barId].source)));
|
||||
} else {
|
||||
model.frsky.screens[screenId].body.bars[barId].barMax = (255-round((spinBox->value()-getBarValue(model.frsky.screens[screenId].body.bars[barId].source, 0, &model.frsky))/getBarStep(model.frsky.screens[screenId].body.bars[barId].source) ));
|
||||
model.frsky.screens[screenId].body.bars[barId].barMax = (255-round((spinBox->value()-analogs[0]->ui->CalibSB->value())/range.step));
|
||||
}
|
||||
spinBox->setValue(getBarValue(model.frsky.screens[screenId].body.bars[barId].source, (255-model.frsky.screens[screenId].body.bars[barId].barMax), &model.frsky));
|
||||
lock=false;
|
||||
else if (model.frsky.screens[screenId].body.bars[barId].source==6) {
|
||||
model.frsky.screens[screenId].body.bars[barId].barMax = (255-round((spinBox->value()-analogs[1]->ui->CalibSB->value())/range.step));
|
||||
}
|
||||
else {
|
||||
model.frsky.screens[screenId].body.bars[barId].barMax = (255-round((spinBox->value()-range.getValue(0))/range.step));
|
||||
}
|
||||
spinBox->setValue(range.getValue(255-model.frsky.screens[screenId].body.bars[barId].barMax));
|
||||
lock = false;
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
|
||||
void TelemetryPanel::customFieldEdited()
|
||||
@@ -902,7 +881,7 @@ void TelemetryPanel::customFieldEdited()
|
||||
if (!lock) {
|
||||
lock = true;
|
||||
|
||||
int cols=GetEepromInterface()->getCapability(TelemetryColsCSFields);
|
||||
int cols = GetEepromInterface()->getCapability(TelemetryColsCSFields);
|
||||
if (cols==0) cols=2;
|
||||
|
||||
for (int i=0; i<GetEepromInterface()->getCapability(TelemetryCSFields); i++) {
|
||||
@@ -913,74 +892,9 @@ void TelemetryPanel::customFieldEdited()
|
||||
model.frsky.screens[screen].body.lines[r].source[c]=csf[i]->currentIndex();
|
||||
}
|
||||
}
|
||||
emit modified();
|
||||
|
||||
lock = false;
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
|
||||
float TelemetryPanel::getBarStep(int barId)
|
||||
{
|
||||
switch (barId-1) {
|
||||
case TELEMETRY_SOURCE_TX_BATT:
|
||||
return 0.1;
|
||||
break;
|
||||
case TELEMETRY_SOURCE_TIMER1:
|
||||
case TELEMETRY_SOURCE_TIMER2:
|
||||
return 3;
|
||||
break;
|
||||
case TELEMETRY_SOURCE_A1:
|
||||
case TELEMETRY_SOURCE_A1_MIN:
|
||||
return (analogs[0]->ui->RatioSB->value()/255);
|
||||
break;
|
||||
case TELEMETRY_SOURCE_A2:
|
||||
case TELEMETRY_SOURCE_A2_MIN:
|
||||
return (analogs[1]->ui->RatioSB->value()/255);
|
||||
break;
|
||||
case TELEMETRY_SOURCE_ALT:
|
||||
case TELEMETRY_SOURCE_GPS_ALT:
|
||||
case TELEMETRY_SOURCE_ALT_MAX:
|
||||
case TELEMETRY_SOURCE_ALT_MIN:
|
||||
return 8;
|
||||
break;
|
||||
case TELEMETRY_SOURCE_RPM:
|
||||
case TELEMETRY_SOURCE_RPM_MAX:
|
||||
return 50;
|
||||
break;
|
||||
case TELEMETRY_SOURCE_CELLS_SUM:
|
||||
case TELEMETRY_SOURCE_VFAS:
|
||||
return 0.1;
|
||||
break;
|
||||
case TELEMETRY_SOURCE_CELL:
|
||||
return 0.02;
|
||||
break;
|
||||
case TELEMETRY_SOURCE_HDG:
|
||||
return 2;
|
||||
break;
|
||||
case TELEMETRY_SOURCE_DIST:
|
||||
case TELEMETRY_SOURCE_DIST_MAX:
|
||||
return 8;
|
||||
break;
|
||||
case TELEMETRY_SOURCE_CURRENT_MAX:
|
||||
case TELEMETRY_SOURCE_CURRENT:
|
||||
return 0.5;
|
||||
break;
|
||||
case TELEMETRY_SOURCE_POWER:
|
||||
return 5;
|
||||
break;
|
||||
case TELEMETRY_SOURCE_CONSUMPTION:
|
||||
return 20;
|
||||
break;
|
||||
case TELEMETRY_SOURCE_SPEED:
|
||||
case TELEMETRY_SOURCE_SPEED_MAX:
|
||||
if (model.frsky.imperial==1) {
|
||||
return 1;
|
||||
} else {
|
||||
return 1.852;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +94,6 @@ class TelemetryPanel : public ModelPanel
|
||||
QComboBox* csf[36];
|
||||
|
||||
void setup();
|
||||
float getBarStep(int barId);
|
||||
void telBarUpdate();
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user