From 466ee39accbdaacdf76f55c6ed5a65f36f182ed2 Mon Sep 17 00:00:00 2001 From: Alexander Klein Date: Thu, 25 May 2023 19:57:00 +0200 Subject: [PATCH] changed isBatteryLow function to check voltage instead of percent --- lib/Battery/battery.cpp | 4 ++-- lib/Battery/battery.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Battery/battery.cpp b/lib/Battery/battery.cpp index 2b701db..82043a5 100644 --- a/lib/Battery/battery.cpp +++ b/lib/Battery/battery.cpp @@ -45,8 +45,8 @@ double Battery::getBatteryVoltage() { return (int)(res*100+0.5)/100.0; } -bool Battery::isBatteryLow(uint8_t percent) { - if (this->getBatteryPercent() <= percent && this->batteryVoltage > this->absurdLowVoltage) +bool Battery::isBatteryLow(double voltage) { + if (this->getBatteryVoltage() <= voltage && this->batteryVoltage > this->absurdLowVoltage) return true; return false; } diff --git a/lib/Battery/battery.h b/lib/Battery/battery.h index c4db57c..181ff10 100644 --- a/lib/Battery/battery.h +++ b/lib/Battery/battery.h @@ -83,11 +83,11 @@ class Battery { * 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 + * @param voltage 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); + bool isBatteryLow(double voltage); private: double calculateInputVoltage();