44 static curve_t liionVoltagePercentToRealPercent({
45 curve_t::point_t {3000, 0},
46 curve_t::point_t {3210, 500},
47 curve_t::point_t {3350, 1000},
48 curve_t::point_t {3430, 1500},
49 curve_t::point_t {3470, 2000},
51 curve_t::point_t {4080, 9000},
52 curve_t::point_t {4110, 9500},
53 curve_t::point_t {4180, 10000}});
56 return liionVoltagePercentToRealPercent.
sample(liionLevel_mv / batteryCountSerie);
80 return lmpd_constrain<uint16_t>(
82 get_level_percent(battery_mv, cellCount), minSafeLevel_percent, maxSafeLevel_percent, 0, 10000),
Given a set of points, will fit multiple linear segments to it.
Definition: curves.h:36
U sample(const T x) const
Sample a point Y from a given x.
Definition: curves.h:83
Define curves types, that can be sampled.
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
Definition: battery.h:72
uint16_t get_raw_battery_voltage_mv()
Return the battery voltage and raise the battery incoherent alert if needed.
Definition: battery.cpp:54
uint16_t get_battery_minimum_cell_level()
Return the level of the cell of the stack with the minimum battery.
Definition: battery.cpp:90
uint16_t get_battery_level()
returns the battery level, corresponding to user safe choice (0-10000)
Definition: battery.h:88
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
Definition: battery.h:41
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 g...
Definition: battery.cpp:86
uint16_t get_battery_maximum_cell_level()
Return the level of the cell of the stack with the maximum battery.
Definition: battery.cpp:119
bool can_battery_be_charged()
Return true if this battery can be charged Check only for validity, not voltage. If this is false,...
Definition: battery.cpp:88
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
Definition: battery.h:64
Program scope.
Definition: control_fixed_modes.hpp:12
static constexpr uint8_t batteryCount
number of batteries for this model
Definition: constants.h:54
static constexpr uint16_t batteryMaxVoltageSafe_mV
max voltage of a li-ion cell to maximise lifetime
Definition: constants.h:111
static constexpr uint16_t batteryMinVoltageSafe_mV
min voltage of a li-ion cell to maximise lifetime
Definition: constants.h:117