changed isBatteryLow function to check voltage
instead of percent
This commit is contained in:
@@ -45,8 +45,8 @@ double Battery::getBatteryVoltage() {
|
|||||||
return (int)(res*100+0.5)/100.0;
|
return (int)(res*100+0.5)/100.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Battery::isBatteryLow(uint8_t percent) {
|
bool Battery::isBatteryLow(double voltage) {
|
||||||
if (this->getBatteryPercent() <= percent && this->batteryVoltage > this->absurdLowVoltage)
|
if (this->getBatteryVoltage() <= voltage && this->batteryVoltage > this->absurdLowVoltage)
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,11 +83,11 @@ class Battery {
|
|||||||
* absurd low. This is for the case that the uController is powered
|
* absurd low. This is for the case that the uController is powered
|
||||||
* by usb and no battery is connected.
|
* by usb and no battery is connected.
|
||||||
*
|
*
|
||||||
* @param percent the limit the battery have to
|
* @param voltage the limit the battery have to
|
||||||
* @return true if the battery is low
|
* @return true if the battery is low
|
||||||
* @return false if the battery is high
|
* @return false if the battery is high
|
||||||
*/
|
*/
|
||||||
bool isBatteryLow(uint8_t percent);
|
bool isBatteryLow(double voltage);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double calculateInputVoltage();
|
double calculateInputVoltage();
|
||||||
|
|||||||
Reference in New Issue
Block a user