summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2015-12-04 02:26:54 +0100
committerSlávek Banko <slavek.banko@axis.cz>2015-12-04 02:27:33 +0100
commit43b1218e15df31194d70161e058032582afbef83 (patch)
tree3c69456f87d81a7d3a8d95a286cb7945ea2d60ba
parent76adbedc16309784f85e558983848e4cce2962be (diff)
downloadtdelibs-43b1218e15df31194d70161e058032582afbef83.tar.gz
tdelibs-43b1218e15df31194d70161e058032582afbef83.zip
Fix calculation of remaining charging time in TDE hardware library
Signed-off-by: Slávek Banko <slavek.banko@axis.cz> (cherry picked from commit 075cf11458a98245a47505b944c5606c1b86afb2)
-rw-r--r--tdecore/tdehw/tdehardwaredevices.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/tdecore/tdehw/tdehardwaredevices.cpp b/tdecore/tdehw/tdehardwaredevices.cpp
index 62fd6a427..3fc8e42b0 100644
--- a/tdecore/tdehw/tdehardwaredevices.cpp
+++ b/tdecore/tdehw/tdehardwaredevices.cpp
@@ -3028,11 +3028,16 @@ void TDEHardwareDevices::updateExistingDeviceInformation(TDEGenericDevice* exist
}
// Calculate time remaining
- // Discharge rate is in watt-hours
+ // Discharge/charge rate is in watt-hours
// Energy is in watt-hours
// Therefore, energy/rate = time in hours
// Convert to seconds...
- bdevice->internalSetTimeRemaining((bdevice->energy()/bdevice->dischargeRate())*60*60);
+ if (bdevice->status() == TDEBatteryStatus::Charging) {
+ bdevice->internalSetTimeRemaining(((bdevice->maximumEnergy()-bdevice->energy())/bdevice->dischargeRate())*60*60);
+ }
+ else {
+ bdevice->internalSetTimeRemaining((bdevice->energy()/bdevice->dischargeRate())*60*60);
+ }
}
if (device->type() == TDEGenericDeviceType::PowerSupply) {