Fixes #1844
This commit is contained in:
@@ -956,7 +956,7 @@ class SensorData {
|
||||
unsigned int index;
|
||||
|
||||
// for calculations
|
||||
unsigned int sources[4];
|
||||
int sources[4];
|
||||
|
||||
// for GPS dist
|
||||
unsigned int gps;
|
||||
|
||||
@@ -2671,7 +2671,7 @@ class SensorField: public TransformedField {
|
||||
if (sensor.formula == SensorData::FORMULA_CELL)
|
||||
_param = (sensor.source) + (sensor.index << 8);
|
||||
else if (sensor.formula == SensorData::FORMULA_ADD || sensor.formula == SensorData::FORMULA_MULTIPLY || sensor.formula == SensorData::FORMULA_MIN || sensor.formula == SensorData::FORMULA_MAX)
|
||||
_param = (sensor.sources[0]) + (sensor.sources[1] << 8) + (sensor.sources[2] << 16) + (sensor.sources[3] << 24);
|
||||
_param = ((uint8_t)sensor.sources[0]) + ((uint8_t)sensor.sources[1] << 8) + ((uint8_t)sensor.sources[2] << 16) + ((uint8_t)sensor.sources[3] << 24);
|
||||
else if (sensor.formula == SensorData::FORMULA_DIST)
|
||||
_param = (sensor.gps) + (sensor.alt << 8);
|
||||
else if (sensor.formula == SensorData::FORMULA_CONSUMPTION)
|
||||
|
||||
@@ -488,6 +488,12 @@ TelemetrySensorPanel::TelemetrySensorPanel(QWidget *parent, SensorData & sensor,
|
||||
ui->altSensor->setField(sensor.alt);
|
||||
ui->ampsSensor->setField(sensor.amps);
|
||||
ui->cellsSensor->setField(sensor.source);
|
||||
ui->cellsIndex->addItem(tr("Lowest"), 0);
|
||||
for (int i=1; i<=6; ++i)
|
||||
ui->cellsIndex->addItem(tr("Cell %1").arg(i), i);
|
||||
ui->cellsIndex->addItem(tr("Highest"), 0);
|
||||
ui->cellsIndex->addItem(tr("Delta"), 0);
|
||||
ui->cellsIndex->setField(sensor.index);
|
||||
ui->source1->setField(sensor.sources[0]);
|
||||
ui->source2->setField(sensor.sources[1]);
|
||||
ui->source3->setField(sensor.sources[2]);
|
||||
@@ -530,13 +536,14 @@ void TelemetrySensorPanel::update()
|
||||
consFieldsDisplayed = (sensor.formula == SensorData::FORMULA_CONSUMPTION);
|
||||
sources12FieldsDisplayed = (sensor.formula <= SensorData::FORMULA_MULTIPLY);
|
||||
sources34FieldsDisplayed = (sensor.formula < SensorData::FORMULA_MULTIPLY);
|
||||
updateSourcesComboBox(ui->source1);
|
||||
updateSourcesComboBox(ui->source2);
|
||||
updateSourcesComboBox(ui->source3);
|
||||
updateSourcesComboBox(ui->source4);
|
||||
updateSourcesComboBox(ui->gpsSensor);
|
||||
updateSourcesComboBox(ui->altSensor);
|
||||
updateSourcesComboBox(ui->ampsSensor);
|
||||
updateSourcesComboBox(ui->source1, true);
|
||||
updateSourcesComboBox(ui->source2, true);
|
||||
updateSourcesComboBox(ui->source3, true);
|
||||
updateSourcesComboBox(ui->source4, true);
|
||||
updateSourcesComboBox(ui->gpsSensor, false);
|
||||
updateSourcesComboBox(ui->altSensor, false);
|
||||
updateSourcesComboBox(ui->ampsSensor, false);
|
||||
updateSourcesComboBox(ui->cellsSensor, false);
|
||||
}
|
||||
else {
|
||||
ui->idLabel->show();
|
||||
@@ -573,19 +580,25 @@ void TelemetrySensorPanel::update()
|
||||
lock = false;
|
||||
}
|
||||
|
||||
void populateTelemetrySourcesComboBox(AutoComboBox * cb, const ModelData * model)
|
||||
void populateTelemetrySourcesComboBox(AutoComboBox * cb, const ModelData * model, bool negative)
|
||||
{
|
||||
cb->clear();
|
||||
if (negative) {
|
||||
for (int i=-C9X_MAX_SENSORS; i<0; ++i) {
|
||||
if (model->sensorData[-i-1].isAvailable())
|
||||
cb->addItem(QObject::tr("-%1").arg(model->sensorData[-i-1].label), i);
|
||||
}
|
||||
}
|
||||
cb->addItem("---", 0);
|
||||
for (int i=0; i<C9X_MAX_SENSORS; ++i) {
|
||||
if (model->sensorData[i].isAvailable())
|
||||
cb->addItem(model->sensorData[i].label, i+1);
|
||||
for (int i=1; i<=C9X_MAX_SENSORS; ++i) {
|
||||
if (model->sensorData[i-1].isAvailable())
|
||||
cb->addItem(model->sensorData[i-1].label, i);
|
||||
}
|
||||
}
|
||||
|
||||
void TelemetrySensorPanel::updateSourcesComboBox(AutoComboBox * cb)
|
||||
void TelemetrySensorPanel::updateSourcesComboBox(AutoComboBox * cb, bool negative)
|
||||
{
|
||||
populateTelemetrySourcesComboBox(cb, model);
|
||||
populateTelemetrySourcesComboBox(cb, model, negative);
|
||||
}
|
||||
|
||||
void TelemetrySensorPanel::on_name_editingFinished()
|
||||
@@ -712,8 +725,8 @@ void TelemetryPanel::update()
|
||||
ui->telemetryProtocol->setCurrentIndex(0);
|
||||
}
|
||||
|
||||
populateTelemetrySourcesComboBox(ui->voltsSource, model);
|
||||
populateTelemetrySourcesComboBox(ui->altitudeSource, model);
|
||||
populateTelemetrySourcesComboBox(ui->voltsSource, model, false);
|
||||
populateTelemetrySourcesComboBox(ui->altitudeSource, model, false);
|
||||
}
|
||||
|
||||
if (IS_ARM(firmware->getBoard())) {
|
||||
|
||||
@@ -95,7 +95,7 @@ class TelemetrySensorPanel: public ModelPanel
|
||||
void on_prec_editingFinished();
|
||||
|
||||
protected:
|
||||
void updateSourcesComboBox(AutoComboBox * cb);
|
||||
void updateSourcesComboBox(AutoComboBox * cb, bool negative);
|
||||
|
||||
private:
|
||||
Ui::TelemetrySensor * ui;
|
||||
|
||||
@@ -25,7 +25,7 @@ class AutoComboBox: public QComboBox
|
||||
lock = false;
|
||||
}
|
||||
|
||||
void addItem(const QString & item, unsigned int value)
|
||||
void addItem(const QString & item, int value)
|
||||
{
|
||||
lock = true;
|
||||
QComboBox::addItem(item, value);
|
||||
@@ -36,6 +36,17 @@ class AutoComboBox: public QComboBox
|
||||
}
|
||||
|
||||
void setField(unsigned int & field, ModelPanel * panel=NULL)
|
||||
{
|
||||
this->field = (int *)&field;
|
||||
this->panel = panel;
|
||||
for (int i=0; i<count(); ++i) {
|
||||
setItemData(i, i);
|
||||
if ((int)field == i)
|
||||
setCurrentIndex(i);
|
||||
}
|
||||
}
|
||||
|
||||
void setField(int & field, ModelPanel * panel=NULL)
|
||||
{
|
||||
this->field = &field;
|
||||
this->panel = panel;
|
||||
@@ -58,7 +69,7 @@ class AutoComboBox: public QComboBox
|
||||
}
|
||||
|
||||
protected:
|
||||
unsigned int * field;
|
||||
int * field;
|
||||
ModelPanel * panel;
|
||||
bool lock;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user