limited battery voltage to two decimal points
This commit is contained in:
@@ -28,6 +28,11 @@ void Battery::loop() {
|
||||
this->lastMillis = millis();
|
||||
}
|
||||
|
||||
double Battery::getBatteryVoltage() {
|
||||
double res = this->batteryVoltage;
|
||||
return (int)(res*100+0.5)/100.0;
|
||||
}
|
||||
|
||||
double Battery::readInputVoltage() {
|
||||
// Reference voltage is 3v3 so maximum reading is 3v3 = 4095 in range 0 to 4095
|
||||
double reading = analogRead(this->pin);
|
||||
|
||||
@@ -64,7 +64,7 @@ class Battery {
|
||||
*
|
||||
* @return double in Volt
|
||||
*/
|
||||
double getBatteryVoltage() {return this->batteryVoltage;}
|
||||
double getBatteryVoltage();
|
||||
|
||||
/**
|
||||
* @brief Get the charge level of the battery
|
||||
|
||||
Reference in New Issue
Block a user