Port-macppc archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: smartbat hacking
Slightly updated version attached (as patch against my previous version)
- some sensors now have correct units; "design cap" now implemented. I
suspect that the design cap should be specified as the max value of the
"charge" sensor, instead as an independent sensor; will investigate.
Magnus
--- smartbat.c 2008/06/27 15:56:15 1.4
+++ smartbat.c 2008/06/29 01:15:50
@@ -76,7 +76,6 @@
int sc_charge;
int sc_max_charge;
int sc_draw;
- int sc_current;
int sc_time;
uint32_t sc_timestamp;
};
@@ -145,9 +144,9 @@
INITDATA(BAT_PRESENT, ENVSYS_INDICATOR, "Battery present");
INITDATA(BAT_VOLTAGE, ENVSYS_SVOLTS_DC, "Battery voltage");
INITDATA(BAT_CURRENT, ENVSYS_SAMPS, "Battery current");
- INITDATA(BAT_MAX_CHARGE, ENVSYS_INTEGER, "Battery design cap");
- INITDATA(BAT_CHARGE, ENVSYS_INTEGER, "Battery charge");
- INITDATA(BAT_CHARGING, ENVSYS_INDICATOR, "Battery charging");
+ INITDATA(BAT_MAX_CHARGE, ENVSYS_SAMPHOUR, "Battery design cap");
+ INITDATA(BAT_CHARGE, ENVSYS_SAMPHOUR, "Battery charge");
+ INITDATA(BAT_CHARGING, ENVSYS_BATTERY_CHARGE, "Battery charging");
INITDATA(BAT_FULL, ENVSYS_INDICATOR, "Battery full");
#undef INITDATA
@@ -189,13 +188,13 @@
edata->value_cur = sc->sc_voltage * 1000;
break;
case BAT_CURRENT:
- edata->value_cur = sc->sc_current * 1000;
+ edata->value_cur = sc->sc_draw * 1000;
break;
case BAT_MAX_CHARGE:
- edata->value_cur = 100;
+ edata->value_cur = sc->sc_max_charge * 1000;
break;
case BAT_CHARGE:
- edata->value_cur = sc->sc_charge;
+ edata->value_cur = sc->sc_charge * 1000;
break;
case BAT_CHARGING:
if ((sc->sc_flags & PMU_PWR_BATT_CHARGING) &&
@@ -249,7 +248,7 @@
/* XXX: are these all valid for smart batteries? */
if (out) {
- printf(" flags: %x", buf[1]);
+ printf(" flags: %x", buf[2]);
if (buf[2] & PMU_PWR_AC_PRESENT)
printf(" AC");
if (buf[2] & PMU_PWR_BATT_CHARGING)
Home |
Main Index |
Thread Index |
Old Index