Lamp-Da 0.1
A compact lantern project
Loading...
Searching...
No Matches
Functions | Variables
lampda::physical::battery Namespace Reference

Handle the battery measurments and gestion. More...

Functions

bool check_balancer_battery_voltage ()
 check the battery pack voltage, and individual cell voltages This should be the main used function.
 
bool check_charger_battery_voltage ()
 check the battery voltage from charging component
 
uint16_t get_raw_battery_voltage_mv ()
 Return the battery voltage and raise the battery incoherent alert if needed.
 
bool is_battery_usable_as_power_source ()
 return true if the battery pack can be used as a energy source This status is updated after calling get_raw_battery_voltage_mv
 
bool can_battery_be_charged ()
 Return true if this battery can be charged Check only for validity, not voltage. If this is false, starting a charge process can break the system This status is updated after calling get_raw_battery_voltage_mv.
 
uint16_t get_battery_minimum_cell_level ()
 Return the level of the cell of the stack with the minimum battery.
 
uint16_t get_battery_maximum_cell_level ()
 Return the level of the cell of the stack with the maximum battery.
 
uint16_t liion_mv_to_battery_percent (const uint16_t liionLevel_mv, const uint8_t batteryCountSerie)
 convert a single liion battery voltage to a percent level model
 
uint16_t get_level_percent (const uint16_t batteryVoltage_mV, const uint8_t cellCount=batteryCount)
 transform a battery voltage measurment to a percent * 100 estimate
 
uint16_t get_level_safe (const uint16_t battery_mv, const uint8_t cellCount=batteryCount)
 returns the battery level, mapped to the desired safe battery level
 
uint16_t get_battery_level ()
 returns the battery level, corresponding to user safe choice (0-10000)
 

Variables

static constexpr uint32_t noBatteryAlertRaiseTiming_ms = 1500
 
static uint16_t s_batteryVoltage_mV = 0
 

Detailed Description

Handle the battery measurments and gestion.

Function Documentation

◆ check_balancer_battery_voltage()

bool lampda::physical::battery::check_balancer_battery_voltage ( )

check the battery pack voltage, and individual cell voltages This should be the main used function.

Returns
false in case of a problem

◆ get_level_percent()

uint16_t lampda::physical::battery::get_level_percent ( const uint16_t  batteryVoltage_mV,
const uint8_t  cellCount = batteryCount 
)
inline

transform a battery voltage measurment to a percent * 100 estimate

Parameters
[in]batteryLevel_mVthe measured battery voltage
Returns
the battery level, in percent * 100

◆ get_raw_battery_voltage_mv()

uint16_t lampda::physical::battery::get_raw_battery_voltage_mv ( )

Return the battery voltage and raise the battery incoherent alert if needed.

get the battery voltage, untreated

◆ liion_mv_to_battery_percent()

uint16_t lampda::physical::battery::liion_mv_to_battery_percent ( const uint16_t  liionLevel_mv,
const uint8_t  batteryCountSerie 
)
inline

convert a single liion battery voltage to a percent level model

Parameters
[in]liionLevel_mvThe voltage of the whole battery
[in]batteryCountSerieHow many liion cells in serie
Returns
The battery percent, x100