libPlayingWithFusion 2026.2.09
Playing With Fusion driver library for FRC roboRIO
Loading...
Searching...
No Matches
pwf::BattFuelGauge Class Reference

High-level C++ wrapper class for accessing battery fuel gauge data. More...

#include <BattFuelGauge.h>

Inheritance diagram for pwf::BattFuelGauge:

Public Types

enum  ChargeState {
  kInit = 0 , kDischarge = 1 , kConstICharge = 2 , kConstVCharge = 3 ,
  kTrickleCharge = 4 , kIdle = 5 , kMeasureOCV = 6
}
 
enum  BattMfg {
  kDuracell = 0 , kEnergizer = 1 , kInterstate = 2 , kMightyMax = 3 ,
  kMKPowered = 4 , kPowerSonic = 5 , kNumMfgs = 6
}
 

Public Member Functions

 BattFuelGauge (uint8_t sensorID)
 
virtual ~BattFuelGauge ()
 
 BattFuelGauge (const BattFuelGauge &)=delete
 
BattFuelGaugeoperator= (const BattFuelGauge &)=delete
 
 BattFuelGauge (BattFuelGauge &&)=default
 
BattFuelGaugeoperator= (BattFuelGauge &&)=default
 
void IdentifySensor ()
 
uint32_t GetFirmwareVersion () const
 
uint32_t GetSerialNumber () const
 
ChargeState GetBatteryState () const
 Get the battery charge/discharge state.
 
float GetCurrent () const
 Get the battery discharge current.
 
float GetVoltage () const
 Get the current battery voltage.
 
float GetDodAh () const
 Get the current depth of discharge in ampere-hours.
 
float GetDodWh () const
 Get the current depth of discharge energy.
 
float GetRemainingChargePct () const
 Get the remaining charge as a percentage.
 
float GetEffectiveCapacityAh () const
 Get the effective (usable) capacity of the battery.
 
float GetBatteryAgeDays () const
 Get the age of the battery.
 
float GetCapacityAh () const
 Get the current (estimated) battery capacity.
 
float GetRatedCapacityAh () const
 Get the original rated capacity when the battery was new.
 
int GetNumCycles () const
 Get the total number of charge/discharge cycles.
 
std::string GetNickname () const
 Get the user-defined nickname of the battery.
 
BattMfg GetManufacturer () const
 Get the battery manufacturer identifier.
 
void SetNickname (std::string newNickname) const
 Set the user-defined nickname of the battery.
 
void SetManufacturer (BattMfg newMfg) const
 Set the battery manufacturer.
 
float GetCycleRmsDischargeCurrent () const
 RMS discharge current during the last complete charge cycle.
 
float GetCycleMaxCurrent () const
 Maximum charging current observed during the last charge cycle.
 
float GetCycleMinCurrent () const
 Maximum discharge current observed during the last charge cycle.
 
float GetCycleMinVoltage () const
 Minimum voltage observed during the last charge cycle.
 
float GetCycleMaxVoltage () const
 Maximum voltage observed during the last charge cycle.
 
float GetCycleMinDodAh () const
 Minimum depth of discharge reached during the last charge cycle.
 
float GetCycleMaxDodAh () const
 Maximum depth of discharge reached during the last charge cycle.
 
float GetCycleMinDodWh () const
 Minimum energy discharged during the last charge cycle.
 
float GetCycleMaxDodWh () const
 Maximum energy discharged during the last charge cycle.
 
float GetCycleChargeTime () const
 Total time spent charging during the last charge cycle.
 
float GetCycleDischargeTime () const
 Total time spent discharging during the last charge cycle.
 
float GetCycleStartingVoltage () const
 Starting voltage at the beginning of the last charge cycle.
 
float GetMatchRmsDischargeCurrent () const
 RMS discharge current during the last robot match.
 
float GetMatchMaxCurrent () const
 Maximum current (any direction) during the last robot match.
 
float GetMatchMinCurrent () const
 Minimum current (most negative discharge) during the last match.
 
float GetMatchMinVoltage () const
 Minimum voltage observed during the last robot match.
 
float GetMatchMaxVoltage () const
 Maximum voltage observed during the last robot match.
 
float GetMatchMinDodAh () const
 Minimum depth of discharge reached during the last robot match.
 
float GetMatchMaxDodAh () const
 Maximum depth of discharge reached during the last robot match.
 
float GetMatchChargeTime () const
 Total charging time during the last robot match (if any).
 
float GetMatchDischargeTime () const
 Total discharging time during the last robot match.
 
float GetMatchStartingVoltage () const
 Battery voltage at the start of the last robot match.
 
float GetMatchStartingEnergy () const
 Energy stored at the beginning of the last robot match.
 
float GetMatchEndingEnergy () const
 Energy remaining at the end of the last robot match.
 
float GetMatchStartingCharge () const
 Charge stored at the beginning of the last robot match.
 
float GetMatchEndingCharge () const
 Charge remaining at the end of the last robot match.
 
float GetMatchDuration () const
 Duration of the last robot match.
 

Detailed Description

High-level C++ wrapper class for accessing battery fuel gauge data.

This class provides a clean, object-oriented interface to the battery fuel gauge functionality. It forwards calls to the underlying C-style API functions defined in BattFuelGaugeApi.h.

All getter methods are const-qualified and return current values from the underlying implementation. The internal handle is assumed to remain valid for the lifetime of this object.

Member Enumeration Documentation

◆ BattMfg

Battery manufacturer enumeration

Enumerator
kDuracell 
kEnergizer 
kInterstate 
kMightyMax 
kMKPowered 
kPowerSonic 
kNumMfgs 

◆ ChargeState

Battery charge state enumeration

Enumerator
kInit 

Unknown charge/discharge state

kDischarge 

Battery finished charging and has started discharging

kConstICharge 

Constant current charging

kConstVCharge 

Constant voltage charging

kTrickleCharge 

Trickle (top-off) charging

kIdle 

Charging complete

kMeasureOCV 

Open circuit (no-load connected to battery). State of charge based on open circuit voltage.

Constructor & Destructor Documentation

◆ BattFuelGauge() [1/3]

BattFuelGauge::BattFuelGauge ( uint8_t sensorID)
explicit

◆ ~BattFuelGauge()

BattFuelGauge::~BattFuelGauge ( )
virtual

◆ BattFuelGauge() [2/3]

pwf::BattFuelGauge::BattFuelGauge ( const BattFuelGauge & )
delete

◆ BattFuelGauge() [3/3]

pwf::BattFuelGauge::BattFuelGauge ( BattFuelGauge && )
default

Member Function Documentation

◆ GetBatteryAgeDays()

float BattFuelGauge::GetBatteryAgeDays ( ) const

Get the age of the battery.

Returns
Battery age in days

◆ GetBatteryState()

BattFuelGauge::ChargeState BattFuelGauge::GetBatteryState ( ) const

Get the battery charge/discharge state.

Returns
Battery state enumeration

◆ GetCapacityAh()

float BattFuelGauge::GetCapacityAh ( ) const

Get the current (estimated) battery capacity.

Returns
Battery capacity in Ah

◆ GetCurrent()

float BattFuelGauge::GetCurrent ( ) const

Get the battery discharge current.

Returns
Battery Discharge Current in Amps (A)

◆ GetCycleChargeTime()

float BattFuelGauge::GetCycleChargeTime ( ) const

Total time spent charging during the last charge cycle.

Returns
Charging time in seconds

◆ GetCycleDischargeTime()

float BattFuelGauge::GetCycleDischargeTime ( ) const

Total time spent discharging during the last charge cycle.

Returns
Discharging time in seconds

◆ GetCycleMaxCurrent()

float BattFuelGauge::GetCycleMaxCurrent ( ) const

Maximum charging current observed during the last charge cycle.

Returns
Max charging current in Amps (A)

◆ GetCycleMaxDodAh()

float BattFuelGauge::GetCycleMaxDodAh ( ) const

Maximum depth of discharge reached during the last charge cycle.

Returns
Maximum depth of discharge in Ah

◆ GetCycleMaxDodWh()

float BattFuelGauge::GetCycleMaxDodWh ( ) const

Maximum energy discharged during the last charge cycle.

Returns
Maximum depth of discharge energy in Wh

◆ GetCycleMaxVoltage()

float BattFuelGauge::GetCycleMaxVoltage ( ) const

Maximum voltage observed during the last charge cycle.

Returns
Maximum battery voltage in Volts (V)

◆ GetCycleMinCurrent()

float BattFuelGauge::GetCycleMinCurrent ( ) const

Maximum discharge current observed during the last charge cycle.

Returns
Max discharge current in Amps (A)

◆ GetCycleMinDodAh()

float BattFuelGauge::GetCycleMinDodAh ( ) const

Minimum depth of discharge reached during the last charge cycle.

Returns
Minimum depth of discharge in Ah

◆ GetCycleMinDodWh()

float BattFuelGauge::GetCycleMinDodWh ( ) const

Minimum energy discharged during the last charge cycle.

Returns
Minimum depth of discharge energy in Wh

◆ GetCycleMinVoltage()

float BattFuelGauge::GetCycleMinVoltage ( ) const

Minimum voltage observed during the last charge cycle.

Returns
Minimum battery voltage in Volts (V)

◆ GetCycleRmsDischargeCurrent()

float BattFuelGauge::GetCycleRmsDischargeCurrent ( ) const

RMS discharge current during the last complete charge cycle.

Returns
RMS discharge current in Amps (A)

◆ GetCycleStartingVoltage()

float BattFuelGauge::GetCycleStartingVoltage ( ) const

Starting voltage at the beginning of the last charge cycle.

Returns
Starting voltage in Volts (V)

◆ GetDodAh()

float BattFuelGauge::GetDodAh ( ) const

Get the current depth of discharge in ampere-hours.

Returns
Depth-Of-Discharge in Ah

◆ GetDodWh()

float BattFuelGauge::GetDodWh ( ) const

Get the current depth of discharge energy.

Returns
Depth-Of-Discharge Energy in Watt-hours (Wh)

◆ GetEffectiveCapacityAh()

float BattFuelGauge::GetEffectiveCapacityAh ( ) const

Get the effective (usable) capacity of the battery.

Returns
Effective Capacity in Ah

◆ GetFirmwareVersion()

uint32_t BattFuelGauge::GetFirmwareVersion ( ) const

Determine the sensor firmware version

Returns
The sensor firmware version

◆ GetManufacturer()

BattFuelGauge::BattMfg BattFuelGauge::GetManufacturer ( ) const

Get the battery manufacturer identifier.

Returns
Enum value representing the battery manufacturer

◆ GetMatchChargeTime()

float BattFuelGauge::GetMatchChargeTime ( ) const

Total charging time during the last robot match (if any).

Returns
Charging time in seconds

◆ GetMatchDischargeTime()

float BattFuelGauge::GetMatchDischargeTime ( ) const

Total discharging time during the last robot match.

Returns
Discharging time in seconds

◆ GetMatchDuration()

float BattFuelGauge::GetMatchDuration ( ) const

Duration of the last robot match.

Returns
Match duration in seconds

◆ GetMatchEndingCharge()

float BattFuelGauge::GetMatchEndingCharge ( ) const

Charge remaining at the end of the last robot match.

Returns
Ending charge in Ampere-hours (Ah)

◆ GetMatchEndingEnergy()

float BattFuelGauge::GetMatchEndingEnergy ( ) const

Energy remaining at the end of the last robot match.

Returns
Ending energy in Watt-hours (Wh)

◆ GetMatchMaxCurrent()

float BattFuelGauge::GetMatchMaxCurrent ( ) const

Maximum current (any direction) during the last robot match.

Returns
Max current in Amps (A)

◆ GetMatchMaxDodAh()

float BattFuelGauge::GetMatchMaxDodAh ( ) const

Maximum depth of discharge reached during the last robot match.

Returns
Maximum depth of discharge in Ah

◆ GetMatchMaxVoltage()

float BattFuelGauge::GetMatchMaxVoltage ( ) const

Maximum voltage observed during the last robot match.

Returns
Maximum voltage in Volts (V)

◆ GetMatchMinCurrent()

float BattFuelGauge::GetMatchMinCurrent ( ) const

Minimum current (most negative discharge) during the last match.

Returns
Min current in Amps (A)

◆ GetMatchMinDodAh()

float BattFuelGauge::GetMatchMinDodAh ( ) const

Minimum depth of discharge reached during the last robot match.

Returns
Minimum depth of discharge in Ah

◆ GetMatchMinVoltage()

float BattFuelGauge::GetMatchMinVoltage ( ) const

Minimum voltage observed during the last robot match.

Returns
Minimum voltage in Volts (V)

◆ GetMatchRmsDischargeCurrent()

float BattFuelGauge::GetMatchRmsDischargeCurrent ( ) const

RMS discharge current during the last robot match.

Returns
RMS discharge current in Amps (A)

◆ GetMatchStartingCharge()

float BattFuelGauge::GetMatchStartingCharge ( ) const

Charge stored at the beginning of the last robot match.

Returns
Starting charge in Ampere-hours (Ah)

◆ GetMatchStartingEnergy()

float BattFuelGauge::GetMatchStartingEnergy ( ) const

Energy stored at the beginning of the last robot match.

Returns
Starting energy in Watt-hours (Wh)

◆ GetMatchStartingVoltage()

float BattFuelGauge::GetMatchStartingVoltage ( ) const

Battery voltage at the start of the last robot match.

Returns
Starting voltage in Volts (V)

◆ GetNickname()

std::string BattFuelGauge::GetNickname ( ) const

Get the user-defined nickname of the battery.

Returns
Battery nickname as a string (empty string if not set or unavailable)

◆ GetNumCycles()

int BattFuelGauge::GetNumCycles ( ) const

Get the total number of charge/discharge cycles.

Returns
Number of charge/discharge cycles

◆ GetRatedCapacityAh()

float BattFuelGauge::GetRatedCapacityAh ( ) const

Get the original rated capacity when the battery was new.

Returns
Rated capacity in Ah

◆ GetRemainingChargePct()

float BattFuelGauge::GetRemainingChargePct ( ) const

Get the remaining charge as a percentage.

Returns
Charge Remaining in Percent (0–100%)

◆ GetSerialNumber()

uint32_t BattFuelGauge::GetSerialNumber ( ) const

Determine the sensor hardware serial number

Returns
The sensor hardware serial number

◆ GetVoltage()

float BattFuelGauge::GetVoltage ( ) const

Get the current battery voltage.

Returns
Battery Voltage in Volts (V)

◆ IdentifySensor()

void BattFuelGauge::IdentifySensor ( )

Dispay 'Identification' page on the BFG OLED display to indicate the sensor asscioated with this instance of software

◆ operator=() [1/2]

BattFuelGauge & pwf::BattFuelGauge::operator= ( BattFuelGauge && )
default

◆ operator=() [2/2]

BattFuelGauge & pwf::BattFuelGauge::operator= ( const BattFuelGauge & )
delete

◆ SetManufacturer()

void BattFuelGauge::SetManufacturer ( BattFuelGauge::BattMfg newMfg) const

Set the battery manufacturer.

Parameters
newMfgEnum value representing the battery manufacturer

◆ SetNickname()

void BattFuelGauge::SetNickname ( std::string newNickname) const

Set the user-defined nickname of the battery.

Parameters
newNicknameNew battery nickname

The documentation for this class was generated from the following files: