Disabled battery current sensing if no battery is connected.
This commit is contained in:
parent
8555a65b1b
commit
33c020fcc3
|
@ -266,56 +266,61 @@ void updateConsumptionWarning(void)
|
|||
|
||||
void updateCurrentMeter(int32_t lastUpdateAt, rxConfig_t *rxConfig, uint16_t deadband3d_throttle)
|
||||
{
|
||||
switch(batteryConfig->currentMeterType) {
|
||||
case CURRENT_SENSOR_ADC:
|
||||
updateBatteryCurrent();
|
||||
if (getBatteryState() != BATTERY_NOT_PRESENT) {
|
||||
switch(batteryConfig->currentMeterType) {
|
||||
case CURRENT_SENSOR_ADC:
|
||||
updateBatteryCurrent();
|
||||
|
||||
updateCurrentDrawn(lastUpdateAt);
|
||||
updateCurrentDrawn(lastUpdateAt);
|
||||
|
||||
updateConsumptionWarning();
|
||||
updateConsumptionWarning();
|
||||
|
||||
break;
|
||||
case CURRENT_SENSOR_VIRTUAL:
|
||||
amperageLatest = (int32_t)batteryConfig->currentMeterOffset;
|
||||
if (ARMING_FLAG(ARMED)) {
|
||||
throttleStatus_e throttleStatus = calculateThrottleStatus(rxConfig, deadband3d_throttle);
|
||||
int throttleOffset = (int32_t)rcCommand[THROTTLE] - 1000;
|
||||
if (throttleStatus == THROTTLE_LOW && feature(FEATURE_MOTOR_STOP)) {
|
||||
throttleOffset = 0;
|
||||
}
|
||||
int throttleFactor = throttleOffset + (throttleOffset * throttleOffset / 50);
|
||||
amperageLatest += throttleFactor * (int32_t)batteryConfig->currentMeterScale / 1000;
|
||||
}
|
||||
amperage = amperageLatest;
|
||||
|
||||
updateCurrentDrawn(lastUpdateAt);
|
||||
|
||||
updateConsumptionWarning();
|
||||
|
||||
break;
|
||||
case CURRENT_SENSOR_ESC:
|
||||
#ifdef USE_ESC_SENSOR
|
||||
if (feature(FEATURE_ESC_SENSOR)) {
|
||||
escSensorData_t *escData = getEscSensorData(ESC_SENSOR_COMBINED);
|
||||
if (escData->dataAge <= MAX_ESC_BATTERY_AGE) {
|
||||
amperageLatest = escData->current;
|
||||
mAhDrawn = escData->consumption;
|
||||
} else {
|
||||
amperageLatest = 0;
|
||||
mAhDrawn = 0;
|
||||
break;
|
||||
case CURRENT_SENSOR_VIRTUAL:
|
||||
amperageLatest = (int32_t)batteryConfig->currentMeterOffset;
|
||||
if (ARMING_FLAG(ARMED)) {
|
||||
throttleStatus_e throttleStatus = calculateThrottleStatus(rxConfig, deadband3d_throttle);
|
||||
int throttleOffset = (int32_t)rcCommand[THROTTLE] - 1000;
|
||||
if (throttleStatus == THROTTLE_LOW && feature(FEATURE_MOTOR_STOP)) {
|
||||
throttleOffset = 0;
|
||||
}
|
||||
int throttleFactor = throttleOffset + (throttleOffset * throttleOffset / 50);
|
||||
amperageLatest += throttleFactor * (int32_t)batteryConfig->currentMeterScale / 1000;
|
||||
}
|
||||
amperage = amperageLatest;
|
||||
|
||||
updateCurrentDrawn(lastUpdateAt);
|
||||
|
||||
updateConsumptionWarning();
|
||||
}
|
||||
|
||||
break;
|
||||
#endif
|
||||
case CURRENT_SENSOR_NONE:
|
||||
amperage = 0;
|
||||
amperageLatest = 0;
|
||||
break;
|
||||
case CURRENT_SENSOR_ESC:
|
||||
#ifdef USE_ESC_SENSOR
|
||||
if (feature(FEATURE_ESC_SENSOR)) {
|
||||
escSensorData_t *escData = getEscSensorData(ESC_SENSOR_COMBINED);
|
||||
if (escData->dataAge <= MAX_ESC_BATTERY_AGE) {
|
||||
amperageLatest = escData->current;
|
||||
mAhDrawn = escData->consumption;
|
||||
} else {
|
||||
amperageLatest = 0;
|
||||
mAhDrawn = 0;
|
||||
}
|
||||
amperage = amperageLatest;
|
||||
|
||||
break;
|
||||
updateConsumptionWarning();
|
||||
}
|
||||
|
||||
break;
|
||||
#endif
|
||||
case CURRENT_SENSOR_NONE:
|
||||
amperage = 0;
|
||||
amperageLatest = 0;
|
||||
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
amperage = 0;
|
||||
amperageLatest = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue