1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-25 17:25:20 +03:00

Don't check batteryConfig fields from the telemetry, call APIs instead

This makes the telemetry code less dependendant on the battery
implementation.

New functions introduced:
    isBatteryVoltageAvailable()
    isAmperageAvailable()
This commit is contained in:
Alberto García Hierro 2017-12-04 16:40:04 +00:00
parent 97a46aa0e9
commit d666151188
9 changed files with 27 additions and 9 deletions

View file

@ -450,6 +450,11 @@ void batteryUpdateAlarms(void)
}
}
bool isBatteryVoltageAvailable(void)
{
return batteryConfig()->voltageMeterSource != VOLTAGE_METER_NONE && getBatteryCellCount() > 0;
}
uint16_t getBatteryVoltage(void)
{
return voltageMeter.filtered;
@ -470,6 +475,11 @@ uint16_t getBatteryAverageCellVoltage(void)
return voltageMeter.filtered / batteryCellCount;
}
bool isAmperageAvailable(void)
{
return batteryConfig()->currentMeterSource != CURRENT_METER_NONE;
}
int32_t getAmperage(void) {
return currentMeter.amperage;
}

View file

@ -77,11 +77,13 @@ struct rxConfig_s;
float calculateVbatPidCompensation(void);
uint8_t calculateBatteryPercentageRemaining(void);
bool isBatteryVoltageAvailable(void);
uint16_t getBatteryVoltage(void);
uint16_t getBatteryVoltageLatest(void);
uint8_t getBatteryCellCount(void);
uint16_t getBatteryAverageCellVoltage(void);
bool isAmperageAvailable(void);
int32_t getAmperage(void);
int32_t getAmperageLatest(void);
int32_t getMAhDrawn(void);