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:
parent
97a46aa0e9
commit
d666151188
9 changed files with 27 additions and 9 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue