summaryrefslogtreecommitdiffstats
path: root/src/hardware_battery.cpp
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2020-02-16 14:34:08 +0100
committerSlávek Banko <slavek.banko@axis.cz>2020-02-16 14:34:08 +0100
commitfa0e4e246ccb8f436598db4deee1777decfbc702 (patch)
tree3e9950b80df1bf908589c94b596d14c351423c62 /src/hardware_battery.cpp
parent80c12d8a765e1afb7b9d0d67df0117a95578595c (diff)
downloadtdepowersave-fa0e4e246ccb8f436598db4deee1777decfbc702.tar.gz
tdepowersave-fa0e4e246ccb8f436598db4deee1777decfbc702.zip
Fix units of current consumption value.
Previously it was not clear whether the units in tdehwlib are in Wh and W or Ah and A. Now the units are always Ah and A. Because power consumption is usually given in W, the value is converted from A to W. If it is less than 100 W, it is displayed as a decimal number. This is related to issue TDE/tdelibs#68. Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
Diffstat (limited to 'src/hardware_battery.cpp')
-rw-r--r--src/hardware_battery.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/hardware_battery.cpp b/src/hardware_battery.cpp
index ac18b52..2e60fb7 100644
--- a/src/hardware_battery.cpp
+++ b/src/hardware_battery.cpp
@@ -94,7 +94,7 @@ void Battery::initDefault() {
state = BAT_NORM;
capacity_state = "ok";
charging_state = UNKNOWN_STATE;
- charge_level_unit = "mWh";
+ charge_level_unit = "Ah";
charge_level_current = 0;
charge_level_lastfull = 0;
charge_level_percentage = 0;
@@ -461,16 +461,18 @@ bool Battery::checkChargeLevelRate () {
return false;
}
- int _rate = present_rate;
+ double _rate = present_rate;
- // FIXME VERIFY CORRECTNESS
- // what does tdepowersave expect to see in present_rate (battery.charge_level.rate)?
- present_rate = bdevice->dischargeRate();
+ // Note that the units used for charge_level_unit and present_rate_unit
+ // are different. This is intentionally because the battery charge
+ // values are in Ah while the power consumption is displayed in W.
+ present_rate = bdevice->dischargeRate()*bdevice->voltage();
if (present_rate < 0 )
present_rate = 0;
- if (present_rate != _rate)
+ if (present_rate != _rate) {
emit changedBattery();
+ }
kdDebugFuncOut(trace);
return true;
@@ -839,7 +841,7 @@ int Battery::getRemainingMinutes() const {
}
//! current charging/discharging rate
-int Battery::getPresentRate() const {
+double Battery::getPresentRate() const {
return present_rate;
}