https://tongfamily.com/2014/03/23/battery-charger-redux/
Battery Charger redux