[Pkg-wmaker-commits] [wmbattery] 85/241: * My new battery has a design capacity of 7800 mAh and yet its last full capacity was 9488, and it's current charged to 8540. Deal with this wonderful miracle^W^Wcrap hardware by taking the max of the design or last full capacities.
Doug Torrance
dtorrance-guest at moszumanska.debian.org
Mon Aug 24 23:37:37 UTC 2015
This is an automated email from the git hooks/post-receive script.
dtorrance-guest pushed a commit to branch master
in repository wmbattery.
commit db52800efbff433fbcecca04a9dd302438b94701
Author: Joey Hess <joey at kodama.kitenet.net>
Date: Tue Oct 23 22:19:50 2007 -0400
* My new battery has a design capacity of 7800 mAh and yet its
last full capacity was 9488, and it's current charged to 8540.
Deal with this wonderful miracle^W^Wcrap hardware by taking the max
of the design or last full capacities.
---
acpi.c | 32 +++++++++++++++++++++++---------
acpi.h | 1 +
debian/changelog | 9 +++++++++
3 files changed, 33 insertions(+), 9 deletions(-)
diff --git a/acpi.c b/acpi.c
index ac5a701..6a398fe 100644
--- a/acpi.c
+++ b/acpi.c
@@ -68,6 +68,7 @@ char *acpi_labels_20020214[] = {
"thermal_zone",
#endif
"state:",
+ "last full capacity:",
NULL
};
@@ -128,18 +129,32 @@ char *get_acpi_value (const char *file, const char *key) {
return scan_acpi_value(buf, key);
}
-/* Returns the design capacity of a battery. */
+/* Returns the maximum capacity of a battery.
+ *
+ * Note that this returns the highest possible capacity for the battery,
+ * even if it can no longer charge that fully. So normally it uses the
+ * design capacity. While the last full capacity of the battery should
+ * never exceed the design capacity, some silly hardware might report
+ * that it does. So if the last full capacity is greater, it will be
+ * returned.
+ */
int get_acpi_batt_capacity(int battery) {
- int cap;
- char *caps=get_acpi_value(acpi_batt_info[battery], acpi_labels[label_design_capacity]);
- if (caps == NULL)
- cap=0; /* battery not present */
+ int dcap, lcap;
+ char *dcaps=get_acpi_value(acpi_batt_info[battery], acpi_labels[label_design_capacity]);
+ char *lcaps=get_acpi_value(acpi_batt_info[battery], acpi_labels[label_last_full_capacity]);
+ if (dcaps == NULL)
+ dcap=0; /* battery not present */
else
- cap=atoi(caps);
+ dcap=atoi(dcaps);
/* This is ACPI's broken way of saying that there is no battery. */
- if (cap == 655350)
+ if (dcap == 655350)
return 0;
- return cap;
+ if (lcaps != NULL) {
+ lcap=atoi(lcaps);
+ if (lcap > dcap)
+ return lcap;
+ }
+ return dcap;
}
/* Comparison function for qsort. */
@@ -198,7 +213,6 @@ int find_items (char *itemname, char infoarray[ACPI_MAXITEM][128],
int find_batteries(void) {
int i;
acpi_batt_count = find_items(acpi_labels[label_battery], acpi_batt_info, acpi_batt_status);
- /* Read in the last charged capacity of the batteries. */
for (i = 0; i < acpi_batt_count; i++)
acpi_batt_capacity[i] = get_acpi_batt_capacity(i);
return acpi_batt_count;
diff --git a/acpi.h b/acpi.h
index ea42e74..d6347e1 100644
--- a/acpi.h
+++ b/acpi.h
@@ -59,6 +59,7 @@ enum acpi_labels_items {
label_thermal,
#endif
label_ac_state,
+ label_last_full_capacity,
};
/* This is set to point to a list of strings used for the given acpi
diff --git a/debian/changelog b/debian/changelog
index 7496d5f..cda7265 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,12 @@
+wmbattery (2.30) UNRELEASED; urgency=low
+
+ * My new battery has a design capacity of 7800 mAh and yet its
+ last full capacity was 9488, and it's current charged to 8540.
+ Deal with this wonderful miracle^W^Wcrap hardware by taking the max
+ of the design or last full capacities.
+
+ -- Joey Hess <joeyh at debian.org> Tue, 23 Oct 2007 22:08:00 -0400
+
wmbattery (2.29) unstable; urgency=low
* Update to new menu policy.
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmbattery.git
More information about the Pkg-wmaker-commits
mailing list