improve battery tracking
This commit is contained in:
@@ -73,13 +73,28 @@ class Battery {
|
||||
*/
|
||||
uint8_t getBatteryPercent() {return this->batteryPercent;}
|
||||
|
||||
/**
|
||||
* @brief Checks if the battery is low.
|
||||
*
|
||||
* The function will also return false if the battery voltage is
|
||||
* absurd low. This is for the case that the uController is powered
|
||||
* by usb and no battery is connected.
|
||||
*
|
||||
* @param percent the limit the battery have to
|
||||
* @return true if the battery is low
|
||||
* @return false if the battery is high
|
||||
*/
|
||||
bool isBatteryLow(uint8_t percent);
|
||||
|
||||
private:
|
||||
double readInputVoltage();
|
||||
void calculateBatteryVoltage();
|
||||
void calculateBatteryPercent();
|
||||
|
||||
uint8_t absurdLowVoltage = 5;
|
||||
uint8_t pin;
|
||||
uint8_t batteryPercent;
|
||||
uint8_t batteryLowPercent = 10;
|
||||
uint16_t delay = 20000;
|
||||
uint32_t r1;
|
||||
uint32_t r2;
|
||||
|
||||
Reference in New Issue
Block a user