#include <core/BatteryMonitor.h>
|
| BatteryMonitor (uint8_t pin, uint16_t minVoltage=3000, uint16_t maxVoltage=4200, float scale=2 *3.3 *1000, unsigned(*mapping)(unsigned, unsigned, unsigned)=sigmoidal) |
| Creates an instance to monitor battery voltage and level. More...
|
|
bool | isBatteryPowered () |
|
bool | isBatteryPowered (uint32_t voltage) |
|
void | setRefreshCallback (uint32_t millis, void(*callback)()) |
|
void | setMapping (unsigned(*mapping)(unsigned, unsigned, unsigned)) |
|
unsigned | level () |
| Returns the current battery level as a number between 0 and 100, with 0 indicating an empty battery and 100 a full battery. More...
|
|
unsigned | level (uint32_t voltage) |
|
uint32_t | voltage () |
| Returns the current battery voltage in millivolts. More...
|
|
virtual void | animate () override |
| Subclasses must implement this function to run through a single frame of animation/activity. More...
|
|
| AnimatedEvent () |
| Default Constructor. More...
|
|
void | setLoopDoneCallback (AnimatedLoopDone loopProc) |
|
◆ BatteryMonitor()
BatteryMonitor::BatteryMonitor |
( |
uint8_t |
pin, |
|
|
uint16_t |
minVoltage = 3000 , |
|
|
uint16_t |
maxVoltage = 4200 , |
|
|
float |
scale = 2 * 3.3 * 1000 , |
|
|
unsigned(*)(unsigned, unsigned, unsigned) |
mapping = sigmoidal |
|
) |
| |
|
inline |
Creates an instance to monitor battery voltage and level.
Initialization parameters depend on battery type and configuration.
- Parameters
-
pin | is the analog pin used for sensing the battery voltage |
minVoltage | is the voltage, expressed in millivolts, corresponding to an empty battery |
maxVoltage | is the voltage, expressed in millivolts, corresponding to a full battery |
scale | is the multiplier used to obtain the real battery voltage in milli volts |
mapFunction | is a pointer to the function used to map the battery voltage to the remaining capacity percentage (defaults to linear mapping) |
◆ animate()
virtual void BatteryMonitor::animate |
( |
| ) |
|
|
inlineoverridevirtual |
Subclasses must implement this function to run through a single frame of animation/activity.
Subclasses should not call delay() or otherwise block.
Implements AnimatedEvent.
◆ asigmoidal()
static unsigned BatteryMonitor::asigmoidal |
( |
unsigned |
voltage, |
|
|
unsigned |
minVoltage, |
|
|
unsigned |
maxVoltage |
|
) |
| |
|
inlinestatic |
◆ isBatteryPowered() [1/2]
bool BatteryMonitor::isBatteryPowered |
( |
| ) |
|
|
inline |
◆ isBatteryPowered() [2/2]
bool BatteryMonitor::isBatteryPowered |
( |
uint32_t |
voltage | ) |
|
|
inline |
◆ level() [1/2]
unsigned BatteryMonitor::level |
( |
| ) |
|
|
inline |
Returns the current battery level as a number between 0 and 100, with 0 indicating an empty battery and 100 a full battery.
◆ level() [2/2]
unsigned BatteryMonitor::level |
( |
uint32_t |
voltage | ) |
|
|
inline |
◆ linear()
static unsigned BatteryMonitor::linear |
( |
unsigned |
voltage, |
|
|
unsigned |
minVoltage, |
|
|
unsigned |
maxVoltage |
|
) |
| |
|
inlinestatic |
◆ setMapping()
void BatteryMonitor::setMapping |
( |
unsigned(*)(unsigned, unsigned, unsigned) |
mapping | ) |
|
|
inline |
◆ setRefreshCallback()
void BatteryMonitor::setRefreshCallback |
( |
uint32_t |
millis, |
|
|
void(*)() |
callback |
|
) |
| |
|
inline |
◆ sigmoidal()
static unsigned BatteryMonitor::sigmoidal |
( |
unsigned |
voltage, |
|
|
unsigned |
minVoltage, |
|
|
unsigned |
maxVoltage |
|
) |
| |
|
inlinestatic |
◆ voltage()
uint32_t BatteryMonitor::voltage |
( |
| ) |
|
|
inline |
Returns the current battery voltage in millivolts.
The documentation for this class was generated from the following file: