battery: OpenBSD use proper constants.

Not a workaround, we can be AMP or WATT hour.
This commit is contained in:
Alastair Poole 2020-07-09 01:11:31 +01:00
parent 12ddeaa2d1
commit 1fa239b404
1 changed files with 16 additions and 17 deletions

View File

@ -188,7 +188,7 @@ _battery_sysctl_battery_update()
charge = 0; charge = 0;
/* last full capacity */ /* last full capacity */
bat->mib[3] = 7; bat->mib[3] = SENSOR_WATTHOUR;
bat->mib[4] = 0; bat->mib[4] = 0;
if (sysctl(bat->mib, 5, &s, &slen, NULL, 0) != -1) if (sysctl(bat->mib, 5, &s, &slen, NULL, 0) != -1)
{ {
@ -196,31 +196,30 @@ _battery_sysctl_battery_update()
} }
/* remaining capacity */ /* remaining capacity */
bat->mib[3] = 7; bat->mib[3] = SENSOR_WATTHOUR;
bat->mib[4] = 3; bat->mib[4] = 3;
if (sysctl(bat->mib, 5, &s, &slen, NULL, 0) != -1) if (sysctl(bat->mib, 5, &s, &slen, NULL, 0) != -1)
{ {
charge = (double)s.value; charge = (double)s.value;
} }
/* This is a workaround because there's an ACPI bug */
if ((EINA_FLT_EQ(charge, 0.0)) || (EINA_FLT_EQ(bat->last_full_charge, 0.0))) if ((EINA_FLT_EQ(charge, 0.0)) || (EINA_FLT_EQ(bat->last_full_charge, 0.0)))
{ {
/* last full capacity */ /* last full capacity */
bat->mib[3] = 8; bat->mib[3] = SENSOR_AMPHOUR;
bat->mib[4] = 0; bat->mib[4] = 0;
if (sysctl(bat->mib, 5, &s, &slen, NULL, 0) != -1) if (sysctl(bat->mib, 5, &s, &slen, NULL, 0) != -1)
{ {
bat->last_full_charge = (double)s.value; bat->last_full_charge = (double)s.value;
} }
/* remaining capacity */ /* remaining capacity */
bat->mib[3] = 8; bat->mib[3] = SENSOR_AMPHOUR;
bat->mib[4] = 3; bat->mib[4] = 3;
if (sysctl(bat->mib, 5, &s, &slen, NULL, 0) != -1) if (sysctl(bat->mib, 5, &s, &slen, NULL, 0) != -1)
{ {
charge = (double)s.value; charge = (double)s.value;
} }
} }
bat->got_prop = 1; bat->got_prop = 1;