1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-25 01:05:10 +03:00

Telemetry totalizer started ...

This commit is contained in:
bsongis 2015-03-24 21:45:16 +01:00
parent ce38605c11
commit a6e86089ec
5 changed files with 27 additions and 6 deletions

View file

@ -14,8 +14,10 @@ void TelemetryItem::gpsReceived()
lastReceived = now();
}
void TelemetryItem::setValue(const TelemetrySensor & sensor, int32_t newVal, uint32_t unit, uint32_t prec)
void TelemetryItem::setValue(const TelemetrySensor & sensor, int32_t val, uint32_t unit, uint32_t prec)
{
int32_t newVal = val;
if (unit == UNIT_CELLS) {
uint32_t data = uint32_t(newVal);
uint8_t cellIndex = data & 0xF;
@ -216,6 +218,15 @@ void TelemetryItem::setValue(const TelemetrySensor & sensor, int32_t newVal, uin
}
}
for (int i=0; i<TELEM_VALUES_MAX; i++) {
TelemetrySensor & it = g_model.telemetrySensors[i];
if (it.type == TELEM_TYPE_CALCULATED && it.formula == TELEM_FORMULA_TOTALIZE && &g_model.telemetrySensors[it.consumption.source-1] == &sensor) {
TelemetryItem & item = telemetryItems[i];
int32_t increment = it.getValue(val, unit, prec);
item.setValue(it, item.value+increment, it.unit, it.prec);
}
}
value = newVal;
lastReceived = now();
}