Based on https://github.com/battery-lcf