Switchable photovoltaic window for on-demand shading and electricity generation