How to detect battery charging and discharging current