summaryrefslogtreecommitdiffstats
path: root/tdecore/tdehw
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2020-01-23 03:37:34 +0100
committerSlávek Banko <slavek.banko@axis.cz>2020-01-23 03:38:22 +0100
commit352be1b977a470e6d666275df3cd0f0e2ffd1185 (patch)
tree6bf8dba3d160079a719b2e49ff7c20db51b630ec /tdecore/tdehw
parentee113c26fbd5723c863282e8bbadfaf5d86a46b4 (diff)
downloadtdelibs-352be1b977a470e6d666275df3cd0f0e2ffd1185.tar.gz
tdelibs-352be1b977a470e6d666275df3cd0f0e2ffd1185.zip
tdehwlib: Adjusted parsing of battery information
+ Added reading of estimated time to fully charged battery (time_to_full_now) The remaining time is calculated if the value is not provided in the battery information. If the battery does not provide charging current information, the estimated time to charge the battery cannot be calculated. Signed-off-by: Slávek Banko <slavek.banko@axis.cz> (cherry picked from commit ecd1e4bd401a00be11f4d8bbaff01718f29f9118)
Diffstat (limited to 'tdecore/tdehw')
-rw-r--r--tdecore/tdehw/tdehardwaredevices.cpp32
1 files changed, 24 insertions, 8 deletions
diff --git a/tdecore/tdehw/tdehardwaredevices.cpp b/tdecore/tdehw/tdehardwaredevices.cpp
index d116325b1..e90fee144 100644
--- a/tdecore/tdehw/tdehardwaredevices.cpp
+++ b/tdecore/tdehw/tdehardwaredevices.cpp
@@ -3024,8 +3024,11 @@ void TDEHardwareDevices::updateExistingDeviceInformation(TDEGenericDevice* exist
valuesdir.setFilter(TQDir::All);
TQString nodename;
double bdevice_capacity = 0;
+ int bdevice_time_to_empty = 0;
+ int bdevice_time_to_full = 0;
bool bdevice_has_energy = false;
bool bdevice_has_time_to_empty = false;
+ bool bdevice_has_time_to_full = false;
const TQFileInfoList *dirlist = valuesdir.entryInfoList();
if (dirlist) {
TQFileInfoListIterator valuesdirit(*dirlist);
@@ -3076,9 +3079,14 @@ void TDEHardwareDevices::updateExistingDeviceInformation(TDEGenericDevice* exist
}
else if (nodename == "time_to_empty_now") {
// Convert from minutes to seconds
- bdevice->internalSetTimeRemaining(line.toDouble()*60);
+ bdevice_time_to_empty = line.toDouble()*60;
bdevice_has_time_to_empty = true;
}
+ else if (nodename == "time_to_full_now") {
+ // Convert from minutes to seconds
+ bdevice_time_to_full = line.toDouble()*60;
+ bdevice_has_time_to_full = true;
+ }
else if (nodename == "voltage_min_design") {
bdevice->internalSetMinimumVoltage(line.toDouble()/1000000.0);
}
@@ -3097,17 +3105,25 @@ void TDEHardwareDevices::updateExistingDeviceInformation(TDEGenericDevice* exist
}
// Calculate time remaining
- if (bdevice->dischargeRate() > 0) {
- // Discharge/charge rate is in watt-hours
- // Energy is in watt-hours
- // Therefore, energy/rate = time in hours
- // Convert to seconds...
- if (bdevice->status() == TDEBatteryStatus::Charging) {
+ // Discharge/charge rate is in amper
+ // Energy is in amper-hours
+ // Therefore, energy/rate = time in hours
+ // Convert to seconds...
+ if (bdevice->status() == TDEBatteryStatus::Charging) {
+ if (!bdevice_has_time_to_full && bdevice->dischargeRate() > 0) {
bdevice->internalSetTimeRemaining(((bdevice->maximumEnergy()-bdevice->energy())/bdevice->dischargeRate())*60*60);
}
- else if (!bdevice_has_time_to_empty) {
+ else {
+ bdevice->internalSetTimeRemaining(bdevice_time_to_full);
+ }
+ }
+ else {
+ if (!bdevice_has_time_to_empty && bdevice->dischargeRate() > 0) {
bdevice->internalSetTimeRemaining((bdevice->energy()/bdevice->dischargeRate())*60*60);
}
+ else {
+ bdevice->internalSetTimeRemaining(bdevice_time_to_empty);
+ }
}
}