Implement setting sensor values from LUA (#3977)

* Implement setting sensor values from LUA

* Fix name of lua sensors
This commit is contained in:
Arne Schwabe
2016-11-02 12:48:11 +01:00
committed by Bertrand Songis
parent 2974af5018
commit 54a9393588
4 changed files with 61 additions and 5 deletions
+12 -3
View File
@@ -429,7 +429,7 @@ int lastUsedTelemetryIndex()
return -1;
}
void setTelemetryValue(TelemetryProtocol protocol, uint16_t id, uint8_t subId, uint8_t instance, int32_t value, uint32_t unit, uint32_t prec)
int setTelemetryValue(TelemetryProtocol protocol, uint16_t id, uint8_t subId, uint8_t instance, int32_t value, uint32_t unit, uint32_t prec)
{
bool available = false;
@@ -443,7 +443,7 @@ void setTelemetryValue(TelemetryProtocol protocol, uint16_t id, uint8_t subId, u
}
if (available || !allowNewSensors) {
return;
return -1;
}
int index = availableTelemetryIndex();
@@ -468,15 +468,24 @@ void setTelemetryValue(TelemetryProtocol protocol, uint16_t id, uint8_t subId, u
case TELEM_PROTO_SPEKTRUM:
spektrumSetDefault(index, id, subId, instance);
break;
#endif
#if defined(LUA)
case TELEM_PROTO_LUA:
// Sensor will be initialized by calling function
// This drops the first value
return index;
#endif
default:
return;
return index;
}
telemetryItems[index].setValue(g_model.telemetrySensors[index], value, unit, prec);
return index;
}
else {
POPUP_WARNING(STR_TELEMETRYFULL);
return -1;
}
}
void TelemetrySensor::init(const char * label, uint8_t unit, uint8_t prec)