Hotwheels-Cluster 1.2
Creation of Cluster APP for SEA:ME project.
 
Loading...
Searching...
No Matches
BatteryController Class Reference

Class that manages the battery of the vehicle. More...

#include <BatteryController.hpp>

Public Member Functions

 BatteryController (II2CController *i2cController=nullptr)
 Construct a new BatteryController object.
 
 ~BatteryController () override
 Destroy the BatteryController object.
 
float getBatteryPercentage () override
 Get the battery percentage.
 
- Public Member Functions inherited from IBatteryController
virtual ~IBatteryController ()=default
 

Private Member Functions

void setCalibration32V2A ()
 Set the calibration for 32V and 2A.
 
float getBusVoltage_V ()
 Get the bus voltage in volts.
 
float getShuntVoltage_V ()
 Get the shunt voltage in volts.
 

Private Attributes

II2CControllerm_i2cController
 
bool m_ownI2CController
 

Detailed Description

Class that manages the battery of the vehicle.

Definition at line 27 of file BatteryController.hpp.

Constructor & Destructor Documentation

◆ BatteryController()

BatteryController::BatteryController ( II2CController * i2cController = nullptr)
explicit

Construct a new BatteryController object.

Parameters
i2cControllerThe I2C controller to use for communication with the INA219. If nullptr, a default I2C controller is created.

This constructor initializes the BatteryController object with the specified I2C controller and address. If i2cController is nullptr, a default I2C controller is created.

Definition at line 38 of file BatteryController.cpp.

Here is the call graph for this function:

◆ ~BatteryController()

BatteryController::~BatteryController ( )
override

Destroy the BatteryController object.

This destructor releases any resources allocated by the BatteryController object. If the object created its own I2C controller, it is deleted.

Definition at line 51 of file BatteryController.cpp.

Member Function Documentation

◆ getBatteryPercentage()

float BatteryController::getBatteryPercentage ( )
overridevirtual

Get the battery percentage.

Returns
float The battery percentage.

This function calculates the battery percentage based on the bus and shunt voltages.

Implements IBatteryController.

Definition at line 103 of file BatteryController.cpp.

Here is the call graph for this function:

◆ getBusVoltage_V()

float BatteryController::getBusVoltage_V ( )
private

Get the bus voltage in volts.

Returns
float The bus voltage in volts.

This function reads the raw bus voltage register value from the INA219 sensor, shifts it to align with the measurement resolution, and converts it to volts.

Definition at line 78 of file BatteryController.cpp.

Here is the caller graph for this function:

◆ getShuntVoltage_V()

float BatteryController::getShuntVoltage_V ( )
private

Get the shunt voltage in volts.

Returns
float The shunt voltage in volts.

This function reads the raw shunt voltage register value from the INA219 sensor, shifts it to align with the measurement resolution, and converts it to volts.

Definition at line 91 of file BatteryController.cpp.

Here is the caller graph for this function:

◆ setCalibration32V2A()

void BatteryController::setCalibration32V2A ( )
private

Set the calibration for 32V and 2A.

This function writes a predefined calibration value to the calibration register of the INA219 sensor to configure it for a voltage range of 32V and a maximum current of 2A.

Definition at line 65 of file BatteryController.cpp.

Here is the caller graph for this function:

Field Documentation

◆ m_i2cController

II2CController* BatteryController::m_i2cController
private

Definition at line 40 of file BatteryController.hpp.

◆ m_ownI2CController

bool BatteryController::m_ownI2CController
private

Definition at line 41 of file BatteryController.hpp.


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