diff options
author | Slávek Banko <slavek.banko@axis.cz> | 2015-12-04 02:26:54 +0100 |
---|---|---|
committer | Slávek Banko <slavek.banko@axis.cz> | 2015-12-04 02:26:54 +0100 |
commit | 075cf11458a98245a47505b944c5606c1b86afb2 (patch) | |
tree | cb30e36f0845ec94672b7c177a8d16d1a72d42df | |
parent | dd1a8d0d1a40f43040555128913e55202f241270 (diff) | |
download | tdelibs-075cf11458a98245a47505b944c5606c1b86afb2.tar.gz tdelibs-075cf11458a98245a47505b944c5606c1b86afb2.zip |
Fix calculation of remaining charging time in TDE hardware library
Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
-rw-r--r-- | tdecore/tdehw/tdehardwaredevices.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/tdecore/tdehw/tdehardwaredevices.cpp b/tdecore/tdehw/tdehardwaredevices.cpp index bb1318a39..017b1188f 100644 --- a/tdecore/tdehw/tdehardwaredevices.cpp +++ b/tdecore/tdehw/tdehardwaredevices.cpp @@ -3082,11 +3082,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) { |