The datasheet says the hardware's default State-Of-Charge threshold is three percent, i.e. the gauge pulls down the pin to logic low at 3% remaining battery life.
My Pinebook Pro's fuel gauge actually shows an alert level of zero percent however and the latest device tree (both from our dtb package and other sources) no longer provide the "cellwise,alert-level" property. The current code still looks for that property but falls back to the define; crank it such that apm(8) does not always report "high" battery state. While here, use all three available states in the same way acpibat(4) sys/dev/acpi/acpi.c does. Feedback? OK? Index: cwfg.c =================================================================== RCS file: /cvs/src/sys/dev/fdt/cwfg.c,v retrieving revision 1.4 diff -u -p -r1.4 cwfg.c --- cwfg.c 26 Mar 2021 22:54:41 -0000 1.4 +++ cwfg.c 29 Mar 2021 05:03:58 -0000 @@ -101,7 +101,7 @@ struct cwfg_softc { #define CWFG_MONITOR_INTERVAL_DEFAULT 5000 #define CWFG_DESIGN_CAPACITY_DEFAULT 2000 -#define CWFG_ALERT_LEVEL_DEFAULT 0 +#define CWFG_ALERT_LEVEL_DEFAULT 25 int cwfg_match(struct device *, void *, void *); void cwfg_attach(struct device *, struct device *, void *); @@ -387,9 +387,13 @@ cwfg_update_sensors(void *arg) sc->sc_sensor[CWFG_SENSOR_SOC].value = val * 1000; sc->sc_sensor[CWFG_SENSOR_SOC].flags &= ~SENSOR_FINVALID; #if NAPM > 0 - cwfg_power.battery_state = val > sc->sc_alert_level ? - APM_BATT_HIGH : APM_BATT_LOW; cwfg_power.battery_life = val; + if (val > 50) + cwfg_power.battery_state = APM_BATT_HIGH; + else if (val > sc->sc_alert_level) + cwfg_power.battery_state = APM_BATT_LOW; + else + cwfg_power.battery_state = APM_BATT_CRITICAL; #endif }