Telemetry totalizer started ...
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user