pnd_log ( pndn_debug, "---[ SIGALRM ]---\n" );
- static time_t last_charge_check;
+ static time_t last_charge_check, last_charge_worka;
int batlevel = pnd_device_get_battery_gauge_perc();
int uamps = 0;
time_t now;
pnd_log ( pndn_debug, "Charge start conditions reached, enabling charging\n" );
pnd_device_set_charger_enable ( bc_charge_device, 1 );
}
+
+ // for some unknown reason it just stops charging randomly (happens once per week or so),
+ // and does not restart, resulting in a flat battery if machine is unattended.
+ // What seems to help here is writing to chip registers, we can do it here indirectly
+ // by writing to enable. Doing it occasionally should do no harm even with missing charger.
+ if ( batlevel <= bc_startcap && (unsigned int)(now - last_charge_worka) > 20*60 ) {
+ pnd_log ( pndn_debug, "Charge workaround trigger\n" );
+ pnd_device_set_charger_enable ( bc_charge_device, 1 );
+ last_charge_worka = now;
+ }
}
last_charge_check = now;
}