Is it possible to code a DPDT switch?

And you can boost the PV with a Joule Thief if your charger can take pulsing input.