summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2008-09-04 14:30:57 +0100
committerRichard Hughes <richard@hughsie.com>2008-09-04 14:30:57 +0100
commit23ed73c4d08b8cfc3c07932b2ae33306bc47dfad (patch)
tree024e2ae2882f23da0921369e31720b4c17643250
parent73d5bcb4c062ca74bdf6d329c121c3c99348cf22 (diff)
bugfix: don't unconditionally set the energy_full to energy_full_design if larger, a few batteries like overcharging
-rw-r--r--src/dkp-supply.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/dkp-supply.c b/src/dkp-supply.c
index 0f6153b..f59215d 100644
--- a/src/dkp-supply.c
+++ b/src/dkp-supply.c
@@ -236,16 +236,26 @@ dkp_supply_refresh_battery (DkpSupply *supply)
obj->energy_full_design =
sysfs_get_double (obj->native_path, "energy_full_design") / 1000000.0;
- /* the last full cannot be bigger than the design */
+ /* the last full should not be bigger than the design */
if (obj->energy_full > obj->energy_full_design)
+ egg_warning ("energy_full (%f) is greater than energy_full_design (%f)",
+ obj->energy_full, obj->energy_full_design);
+
+ /* some systems don't have this */
+ if (obj->energy_full < 0.01) {
+ egg_warning ("correcting energy_full (%f) using energy_full_design (%f)",
+ obj->energy_full, obj->energy_full_design);
obj->energy_full = obj->energy_full_design;
+ }
/* calculate how broken our battery is */
- obj->capacity = obj->energy_full_design / obj->energy_full * 100.0f;
- if (obj->capacity < 0)
- obj->capacity = 0;
- if (obj->capacity > 100.0)
- obj->capacity = 100.0;
+ if (obj->energy_full > 0) {
+ obj->capacity = obj->energy_full_design / obj->energy_full * 100.0f;
+ if (obj->capacity < 0)
+ obj->capacity = 0;
+ if (obj->capacity > 100.0)
+ obj->capacity = 100.0;
+ }
/* we only coldplug once, as these values will never change */
supply->priv->has_coldplug_values = TRUE;