[gnome-battery-bench] Don't add together voltage_now values for multiple batteries
- From: Owen Taylor <otaylor src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-battery-bench] Don't add together voltage_now values for multiple batteries
- Date: Tue, 30 Jun 2015 21:18:13 +0000 (UTC)
commit b769f9209fdac2d95e2115e8515a8a09cd97e02b
Author: Owen W. Taylor <otaylor fishsoup net>
Date: Tue Jun 30 16:18:35 2015 -0400
Don't add together voltage_now values for multiple batteries
If there are multiple batteries, it's not possible to compute an
overall "voltage_now" for the system, so just ignore it.
https://bugzilla.gnome.org/show_bug.cgi?id=747370
src/power-monitor.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/src/power-monitor.c b/src/power-monitor.c
index 3036815..8946b16 100644
--- a/src/power-monitor.c
+++ b/src/power-monitor.c
@@ -148,6 +148,7 @@ battery_poll(Battery *battery)
battery->charge_full = -1.0;
battery->charge_full_design = -1.0;
battery->capacity_now = -1.0;
+ battery->voltage_now = -1.0;
get_file_contents_double (battery->directory, "energy_now", &battery->energy_now, NULL, NULL);
if (battery->energy_now >= 0) {
@@ -363,7 +364,6 @@ read_state(GbbPowerMonitor *monitor,
} else if (battery->charge_now >= 0) {
add_to (&state->charge_now, battery->charge_now);
add_to (&state->charge_full, battery->charge_full);
- add_to (&state->voltage_now, battery->voltage_now);
if (battery->charge_full_design >= 0) {
if (n_batteries == 0 || state->charge_full_design >= 0)
@@ -375,6 +375,12 @@ read_state(GbbPowerMonitor *monitor,
add_to (&state->capacity_now, battery->capacity_now);
}
+ /* state->voltage_now only makes sense if there is a single battery */
+ if (n_batteries == 0)
+ state->voltage_now = battery->voltage_now;
+ else
+ state->voltage_now = -1.0;
+
n_batteries += 1;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]