24typedef uint8_t(*mapFn_t)(uint16_t, uint16_t, uint16_t);
37 Battery(uint16_t minVoltage, uint16_t maxVoltage, uint8_t sensePin, uint8_t adcBits = 10);
47 void begin(uint16_t refVoltage,
float dividerRatio, mapFn_t = 0);
57 void onDemand(uint8_t activationPin, uint8_t activationMode = LOW);
75 uint16_t
voltage(uint8_t delay = 2);
83 uint8_t activationPin;
84 uint8_t activationMode;
101static inline uint8_t sigmoidal(uint16_t voltage, uint16_t minVoltage, uint16_t maxVoltage) {
109 uint8_t result = 105 - (105 / (1 + pow(1.724 * (voltage - minVoltage)/(maxVoltage - minVoltage), 5.5)));
110 return result >= 100 ? 100 : result;
119static inline uint8_t asigmoidal(uint16_t voltage, uint16_t minVoltage, uint16_t maxVoltage) {
120 uint8_t result = 101 - (101 / pow(1 + pow(1.33 * (voltage - minVoltage)/(maxVoltage - minVoltage) ,4.5), 3));
121 return result >= 100 ? 100 : result;
130static inline uint8_t linear(uint16_t voltage, uint16_t minVoltage, uint16_t maxVoltage) {
131 return (
unsigned long)(voltage - minVoltage) * 100 / (maxVoltage - minVoltage);
uint8_t level()
Definition: Battery.cpp:45
uint16_t voltage(uint8_t delay=2)
Definition: Battery.cpp:59
Battery(uint16_t minVoltage, uint16_t maxVoltage, uint8_t sensePin, uint8_t adcBits=10)
Definition: Battery.cpp:22
static const uint8_t ON_DEMAND_DISABLE
Definition: Battery.h:62
void onDemand(uint8_t activationPin, uint8_t activationMode=LOW)
Definition: Battery.cpp:36
void begin(uint16_t refVoltage, float dividerRatio, mapFn_t=0)
Definition: Battery.cpp:29