Optimize battery charging power