Limiting charging to 80% means getting rid of constant voltage charging mode altogether. Generally speaking and in illustrative numbers, Li-ion batteries are charged in following manners:
- Below 10%, battery is charged in pre-charge mode through a 10-foot pole.
- Above 10%, battery is charged in constant current mode, as in:
`charger.current_max(battery.CAPACITY * battery.CHARGE_C_RATE)`
`charger.voltage(battery.voltage + 0.0001)`
- Above 80%, battery is charged in constant voltage mode, as in:
`charger.current_max(battery.TERMINATION_CURRENT)`
`charger.voltage(battery.VOLTAGE_MAX)`
- `charger.charge_complete` shall return `True` if `battery.voltage == battery.VOLTAGE_MAX and charger.current == battery.TERMINATION_CURRENT`.
- * `battery.CHARGE_C_RATE` is generally set within 0.2 to 4; 1.0 matches mAh rating of the battery, a mostly-safe default. 0.2 is 5 hours to full charge, and 4 is "fast charge to 80% in 15 minutes".
- * all above is usually implemented in charge controller chip firmware, often in actual ROM; the bare minimum often done in real products is to hardwire indicate `charger.current_max` to the chip in circuits. That suffices unless intricate charging really is one of your differentiation.
- * `battery.state_of_charge` is more or less `find_acidity_or_pH(battery.voltage, battery.formulae)`, by the way. Capacity-Voltage curve is titration chart turned sideways.
It is often vaguely told that this constant voltage variable current mode used in 80 - 100% range is harmful to batteries, so not doing it should improve longevity. As to why then implement CV modes at all, and why not offer an option to easily disable it, I don't know. Everyone does it this way.
I wish I knew if altering `battery.VOLTAGE_MAX` would work or if `charger.allow_cv_charging` can be set to `False`, but those are often hardcoded `4.2` and `True` in ROM.