The previous combined function was hard to read and understand. Now using a dedicated function for both power flow directions.
The format tries to maintain the previously used Libre Solar firmware coding style as much as possible. Applying the format fixed some issues and re-ordered some parts of the code.