Merge pull request #2523 from opentx/projectkk2glider/issue_2513_duplicate_sensors
Fixes #2513: set value of duplicated telemetry sensors
This commit is contained in:
@@ -482,14 +482,21 @@ int lastUsedTelemetryIndex()
|
|||||||
|
|
||||||
void setTelemetryValue(TelemetryProtocol protocol, uint16_t id, uint8_t instance, int32_t value, uint32_t unit, uint32_t prec)
|
void setTelemetryValue(TelemetryProtocol protocol, uint16_t id, uint8_t instance, int32_t value, uint32_t unit, uint32_t prec)
|
||||||
{
|
{
|
||||||
|
bool available = false;
|
||||||
|
|
||||||
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) {
|
||||||
telemetryItems[index].setValue(telemetrySensor, value, unit, prec);
|
telemetryItems[index].setValue(telemetrySensor, value, unit, prec);
|
||||||
return;
|
available = true;
|
||||||
|
// we continue search here, because more than one sensor can have the same id and instance
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (available) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int index = availableTelemetryIndex();
|
int index = availableTelemetryIndex();
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
switch (protocol) {
|
switch (protocol) {
|
||||||
|
|||||||
Reference in New Issue
Block a user