From 53381ab391d68a1939d6854ce16bf982a138d944 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sl=C3=A1vek=20Banko?= Date: Wed, 8 Jan 2020 01:49:53 +0100 Subject: tdehwlib: Adjusted parsing of battery information + Added initialization of all values Some batteries do not provide all values and, without initialization, values may contain dubious data. + Added reading of current battery capacity value in percent (capacity) Some batteries may provide the current capacity value in percent instead of the current energy value. + Added check whether the battery provides current energy value (charge_now or energy_now) The current energy is calculated if the value is not provided in the battery information. + Added reading of estimated time to empty battery (time_to_empty_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. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Slávek Banko (cherry picked from commit 86c1d896c748bf5117ccfe28b20e48a7e2a70c8d) --- tdecore/tdehw/tdebatterydevice.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'tdecore/tdehw/tdebatterydevice.cpp') diff --git a/tdecore/tdehw/tdebatterydevice.cpp b/tdecore/tdehw/tdebatterydevice.cpp index 781fb994b..e220fa5a6 100644 --- a/tdecore/tdehw/tdebatterydevice.cpp +++ b/tdecore/tdehw/tdebatterydevice.cpp @@ -21,7 +21,14 @@ #include "config.h" -TDEBatteryDevice::TDEBatteryDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn) : TDEGenericDevice(dt, dn) { +TDEBatteryDevice::TDEBatteryDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn) : + m_currentVoltage(0), m_minimumVoltage(0), m_maximumVoltage(0), m_maximumDesignVoltage(0), + m_alarmEnergy(0), m_currentEnergy(0), m_maximumEnergy(0), m_maximumDesignEnergy(0), + m_dischargeRate(0), m_timeRemaining(0), + m_technology(TQString::null), + m_status(TDEBatteryStatus::Unknown), + m_installed(0), + TDEGenericDevice(dt, dn) { } TDEBatteryDevice::~TDEBatteryDevice() { -- cgit v1.2.1