mirror of
https://github.com/opentx/opentx.git
synced 2025-07-26 01:35:21 +03:00
Merge pull request #2548 from opentx/bsongis/bad_sport_sensors
#2538 - Proposal for a fix.
This commit is contained in:
commit
545f54a89c
8 changed files with 30 additions and 11 deletions
|
@ -775,6 +775,7 @@ class FrSkyData {
|
||||||
bool mAhPersistent;
|
bool mAhPersistent;
|
||||||
unsigned int storedMah;
|
unsigned int storedMah;
|
||||||
int fasOffset;
|
int fasOffset;
|
||||||
|
bool ignoreSensorIds;
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
};
|
};
|
||||||
|
|
|
@ -2949,7 +2949,7 @@ OpenTxModelData::OpenTxModelData(ModelData & modelData, BoardEnum board, unsigne
|
||||||
if (IS_ARM(board) && version >= 217) {
|
if (IS_ARM(board) && version >= 217) {
|
||||||
internalField.Append(new BoolField<1>(modelData.noGlobalFunctions));
|
internalField.Append(new BoolField<1>(modelData.noGlobalFunctions));
|
||||||
internalField.Append(new UnsignedField<2>(modelData.trimsDisplay));
|
internalField.Append(new UnsignedField<2>(modelData.trimsDisplay));
|
||||||
internalField.Append(new SpareBitsField<1>());
|
internalField.Append(new BoolField<1>(modelData.frsky.ignoreSensorIds));
|
||||||
}
|
}
|
||||||
else if (IS_TARANIS(board) || (IS_ARM(board) && version >= 216)) {
|
else if (IS_TARANIS(board) || (IS_ARM(board) && version >= 216)) {
|
||||||
internalField.Append(new SpareBitsField<4>());
|
internalField.Append(new SpareBitsField<4>());
|
||||||
|
|
|
@ -795,10 +795,12 @@ void TelemetryPanel::setup()
|
||||||
ui->telemetryProtocol->addItem(tr("FrSky D (cable)"), 2);
|
ui->telemetryProtocol->addItem(tr("FrSky D (cable)"), 2);
|
||||||
}
|
}
|
||||||
ui->telemetryProtocol->setCurrentIndex(model->telemetryProtocol);
|
ui->telemetryProtocol->setCurrentIndex(model->telemetryProtocol);
|
||||||
|
ui->ignoreSensorIds->setField(model->frsky.ignoreSensorIds);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ui->telemetryProtocolLabel->hide();
|
ui->telemetryProtocolLabel->hide();
|
||||||
ui->telemetryProtocol->hide();
|
ui->telemetryProtocol->hide();
|
||||||
|
ui->ignoreSensorIds->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
ui->rssiAlarm1SB->setValue(model->frsky.rssiAlarms[0].value);
|
ui->rssiAlarm1SB->setValue(model->frsky.rssiAlarms[0].value);
|
||||||
|
|
|
@ -896,7 +896,7 @@
|
||||||
<property name="margin">
|
<property name="margin">
|
||||||
<number>4</number>
|
<number>4</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="0" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="sensorsLabel">
|
<widget class="QLabel" name="sensorsLabel">
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
|
@ -909,6 +909,13 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="AutoCheckBox" name="ignoreSensorIds">
|
||||||
|
<property name="text">
|
||||||
|
<string>Disable multi sensor handling</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
@ -29,7 +29,7 @@ class AutoCheckBox: public QCheckBox
|
||||||
{
|
{
|
||||||
lock = true;
|
lock = true;
|
||||||
if (field) {
|
if (field) {
|
||||||
setChecked((int)*field);
|
setChecked(*field);
|
||||||
}
|
}
|
||||||
lock = false;
|
lock = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,6 +74,7 @@ enum menuModelTelemetryItems {
|
||||||
ITEM_TELEMETRY_SENSOR31,
|
ITEM_TELEMETRY_SENSOR31,
|
||||||
ITEM_TELEMETRY_SENSOR32,
|
ITEM_TELEMETRY_SENSOR32,
|
||||||
ITEM_TELEMETRY_NEWSENSOR,
|
ITEM_TELEMETRY_NEWSENSOR,
|
||||||
|
ITEM_TELEMETRY_IGNORE_SENSORID,
|
||||||
#if defined(VARIO)
|
#if defined(VARIO)
|
||||||
ITEM_TELEMETRY_VARIO_LABEL,
|
ITEM_TELEMETRY_VARIO_LABEL,
|
||||||
ITEM_TELEMETRY_VARIO_SOURCE,
|
ITEM_TELEMETRY_VARIO_SOURCE,
|
||||||
|
@ -120,7 +121,7 @@ enum menuModelTelemetryItems {
|
||||||
#define IS_RANGE_DEFINED(k) (g_model.frsky.channels[k].ratio > 0)
|
#define IS_RANGE_DEFINED(k) (g_model.frsky.channels[k].ratio > 0)
|
||||||
|
|
||||||
#define SENSOR_ROWS(x) (isTelemetryFieldAvailable(x) ? (uint8_t)0 : HIDDEN_ROW)
|
#define SENSOR_ROWS(x) (isTelemetryFieldAvailable(x) ? (uint8_t)0 : HIDDEN_ROW)
|
||||||
#define SENSORS_ROWS LABEL(Sensors), SENSOR_ROWS(0), SENSOR_ROWS(1), SENSOR_ROWS(2), SENSOR_ROWS(3), SENSOR_ROWS(4), SENSOR_ROWS(5), SENSOR_ROWS(6), SENSOR_ROWS(7), SENSOR_ROWS(8), SENSOR_ROWS(9), SENSOR_ROWS(10), SENSOR_ROWS(11), SENSOR_ROWS(12), SENSOR_ROWS(13), SENSOR_ROWS(14), SENSOR_ROWS(15), SENSOR_ROWS(16), SENSOR_ROWS(17), SENSOR_ROWS(18), SENSOR_ROWS(19), SENSOR_ROWS(20), SENSOR_ROWS(21), SENSOR_ROWS(22), SENSOR_ROWS(23), SENSOR_ROWS(24), SENSOR_ROWS(25), SENSOR_ROWS(26), SENSOR_ROWS(27), SENSOR_ROWS(28), SENSOR_ROWS(29), SENSOR_ROWS(30), SENSOR_ROWS(31), 0,
|
#define SENSORS_ROWS LABEL(Sensors), SENSOR_ROWS(0), SENSOR_ROWS(1), SENSOR_ROWS(2), SENSOR_ROWS(3), SENSOR_ROWS(4), SENSOR_ROWS(5), SENSOR_ROWS(6), SENSOR_ROWS(7), SENSOR_ROWS(8), SENSOR_ROWS(9), SENSOR_ROWS(10), SENSOR_ROWS(11), SENSOR_ROWS(12), SENSOR_ROWS(13), SENSOR_ROWS(14), SENSOR_ROWS(15), SENSOR_ROWS(16), SENSOR_ROWS(17), SENSOR_ROWS(18), SENSOR_ROWS(19), SENSOR_ROWS(20), SENSOR_ROWS(21), SENSOR_ROWS(22), SENSOR_ROWS(23), SENSOR_ROWS(24), SENSOR_ROWS(25), SENSOR_ROWS(26), SENSOR_ROWS(27), SENSOR_ROWS(28), SENSOR_ROWS(29), SENSOR_ROWS(30), SENSOR_ROWS(31), 0, 0,
|
||||||
#if defined(VARIO)
|
#if defined(VARIO)
|
||||||
#define VARIO_ROWS LABEL(Vario), 0, 1, 2,
|
#define VARIO_ROWS LABEL(Vario), 0, 1, 2,
|
||||||
#else
|
#else
|
||||||
|
@ -535,7 +536,7 @@ void menuModelTelemetry(uint8_t event)
|
||||||
lcd_putsAtt(TELEM_COL2, y, "---", 0); // TODO shortcut
|
lcd_putsAtt(TELEM_COL2, y, "---", 0); // TODO shortcut
|
||||||
}
|
}
|
||||||
TelemetrySensor * sensor = & g_model.telemetrySensors[index];
|
TelemetrySensor * sensor = & g_model.telemetrySensors[index];
|
||||||
if (sensor->type == TELEM_TYPE_CUSTOM) {
|
if (sensor->type == TELEM_TYPE_CUSTOM && !g_model.ignoreSensorIds) {
|
||||||
lcd_outdezAtt(TELEM_COL3, y, sensor->instance, LEFT);
|
lcd_outdezAtt(TELEM_COL3, y, sensor->instance, LEFT);
|
||||||
}
|
}
|
||||||
if (attr) {
|
if (attr) {
|
||||||
|
@ -561,8 +562,10 @@ void menuModelTelemetry(uint8_t event)
|
||||||
|
|
||||||
case ITEM_TELEMETRY_SENSORS_LABEL:
|
case ITEM_TELEMETRY_SENSORS_LABEL:
|
||||||
lcd_putsLeft(y, STR_TELEMETRY_SENSORS);
|
lcd_putsLeft(y, STR_TELEMETRY_SENSORS);
|
||||||
lcd_putsAtt(TELEM_COL2, y, STR_VALUE, 0);
|
if (!g_model.ignoreSensorIds) {
|
||||||
lcd_putsAtt(TELEM_COL3, y, STR_ID, 0);
|
lcd_putsAtt(TELEM_COL2, y, STR_VALUE, 0);
|
||||||
|
lcd_putsAtt(TELEM_COL3, y, STR_ID, 0);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ITEM_TELEMETRY_NEWSENSOR:
|
case ITEM_TELEMETRY_NEWSENSOR:
|
||||||
|
@ -580,6 +583,10 @@ void menuModelTelemetry(uint8_t event)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case ITEM_TELEMETRY_IGNORE_SENSORID:
|
||||||
|
ON_OFF_MENU_ITEM(g_model.ignoreSensorIds, TELEM_COL2, y, INDENT "Ignore IDs", attr, event);
|
||||||
|
break;
|
||||||
|
|
||||||
case ITEM_TELEMETRY_RSSI_LABEL:
|
case ITEM_TELEMETRY_RSSI_LABEL:
|
||||||
lcd_putsLeft(y, PSTR("RSSI"));
|
lcd_putsLeft(y, PSTR("RSSI"));
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1272,7 +1272,7 @@ enum TelemetrySensorFormula
|
||||||
|
|
||||||
PACK(typedef struct {
|
PACK(typedef struct {
|
||||||
union {
|
union {
|
||||||
uint16_t id; // data identifier, for FrSky we can reuse existing ones. Source unit is derived from type.
|
uint16_t id; // data identifier, for FrSky we can reuse existing ones. Source unit is derived from type.
|
||||||
uint16_t persistentValue;
|
uint16_t persistentValue;
|
||||||
};
|
};
|
||||||
union {
|
union {
|
||||||
|
@ -2130,7 +2130,7 @@ PACK(typedef struct {
|
||||||
AVR_FIELD(int8_t ppmNCH:4)
|
AVR_FIELD(int8_t ppmNCH:4)
|
||||||
ARM_FIELD(uint8_t noGlobalFunctions:1)
|
ARM_FIELD(uint8_t noGlobalFunctions:1)
|
||||||
ARM_FIELD(uint8_t displayTrims:2)
|
ARM_FIELD(uint8_t displayTrims:2)
|
||||||
ARM_FIELD(uint8_t spare2:1)
|
ARM_FIELD(uint8_t ignoreSensorIds:1)
|
||||||
int8_t trimInc:3; // Trim Increments
|
int8_t trimInc:3; // Trim Increments
|
||||||
uint8_t disableThrottleWarning:1;
|
uint8_t disableThrottleWarning:1;
|
||||||
ARM_FIELD(uint8_t displayChecklist:1)
|
ARM_FIELD(uint8_t displayChecklist:1)
|
||||||
|
|
|
@ -179,7 +179,9 @@ void TelemetryItem::setValue(const TelemetrySensor & sensor, int32_t val, uint32
|
||||||
newVal = 0;
|
newVal = 0;
|
||||||
}
|
}
|
||||||
else if (unit == UNIT_RPMS) {
|
else if (unit == UNIT_RPMS) {
|
||||||
newVal = (newVal * sensor.custom.offset) / sensor.custom.ratio;
|
if (sensor.custom.ratio != 0) {
|
||||||
|
newVal = (newVal * sensor.custom.offset) / sensor.custom.ratio;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
newVal = sensor.getValue(newVal, unit, prec);
|
newVal = sensor.getValue(newVal, unit, prec);
|
||||||
|
@ -486,7 +488,7 @@ void setTelemetryValue(TelemetryProtocol protocol, uint16_t id, uint8_t instance
|
||||||
|
|
||||||
for (int index=0; index<MAX_SENSORS; index++) {
|
for (int index=0; index<MAX_SENSORS; index++) {
|
||||||
TelemetrySensor & telemetrySensor = g_model.telemetrySensors[index];
|
TelemetrySensor & telemetrySensor = g_model.telemetrySensors[index];
|
||||||
if (telemetrySensor.type == TELEM_TYPE_CUSTOM && telemetrySensor.id == id && telemetrySensor.instance == instance) {
|
if (telemetrySensor.type == TELEM_TYPE_CUSTOM && telemetrySensor.id == id && (telemetrySensor.instance == instance || g_model.ignoreSensorIds)) {
|
||||||
telemetryItems[index].setValue(telemetrySensor, value, unit, prec);
|
telemetryItems[index].setValue(telemetrySensor, value, unit, prec);
|
||||||
available = true;
|
available = true;
|
||||||
// we continue search here, because more than one sensor can have the same id and instance
|
// we continue search here, because more than one sensor can have the same id and instance
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue