diff --git a/src/main/interface/settings.c b/src/main/interface/settings.c index f46dc13b25..dfa8d673e3 100644 --- a/src/main/interface/settings.c +++ b/src/main/interface/settings.c @@ -618,7 +618,7 @@ const clivalue_t valueTable[] = { // PG_CURRENT_SENSOR_ADC_CONFIG #ifdef USE_VIRTUAL_CURRENT_METER { "ibatv_scale", VAR_INT16 | MASTER_VALUE, .config.minmax = { -16000, 16000 }, PG_CURRENT_SENSOR_VIRTUAL_CONFIG, offsetof(currentSensorVirtualConfig_t, scale) }, - { "ibatv_offset", VAR_INT16 | MASTER_VALUE, .config.minmax = { -16000, 16000 }, PG_CURRENT_SENSOR_VIRTUAL_CONFIG, offsetof(currentSensorVirtualConfig_t, offset) }, + { "ibatv_offset", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, 16000 }, PG_CURRENT_SENSOR_VIRTUAL_CONFIG, offsetof(currentSensorVirtualConfig_t, offset) }, #endif #ifdef USE_BEEPER @@ -974,6 +974,7 @@ const clivalue_t valueTable[] = { #ifdef USE_ESC_SENSOR { "esc_sensor_halfduplex", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_ESC_SENSOR_CONFIG, offsetof(escSensorConfig_t, halfDuplex) }, + { "esc_sensor_offset", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, 16000 }, PG_ESC_SENSOR_CONFIG, offsetof(escSensorConfig_t, offset) }, #endif #ifdef USE_RX_FRSKY_SPI diff --git a/src/main/sensors/current.c b/src/main/sensors/current.c index 66fc00201c..4a8ec008b4 100644 --- a/src/main/sensors/current.c +++ b/src/main/sensors/current.c @@ -222,8 +222,8 @@ void currentMeterESCRefresh(int32_t lastUpdateAt) escSensorData_t *escData = getEscSensorData(ESC_SENSOR_COMBINED); if (escData && escData->dataAge <= ESC_BATTERY_AGE_MAX) { - currentMeterESCState.amperage = escData->current; - currentMeterESCState.mAhDrawn = escData->consumption; + currentMeterESCState.amperage = escData->current + escSensorConfig()->offset / 10; + currentMeterESCState.mAhDrawn = escData->consumption + escSensorConfig()->offset * millis() / (1000.0f * 3600); } else { currentMeterESCState.amperage = 0; currentMeterESCState.mAhDrawn = 0; diff --git a/src/main/sensors/esc_sensor.h b/src/main/sensors/esc_sensor.h index ffc096105c..bbee665f63 100644 --- a/src/main/sensors/esc_sensor.h +++ b/src/main/sensors/esc_sensor.h @@ -24,6 +24,8 @@ typedef struct escSensorConfig_s { uint8_t halfDuplex; // Set to false to listen on the TX pin for telemetry data + uint16_t offset; // offset consumed by the flight controller / VTX / cam / ... in milliampere + } escSensorConfig_t; PG_DECLARE(escSensorConfig_t, escSensorConfig);