sudo sed -i -r 's/dtoverlay\s*=\s*waveshare35a(\s*:\s*rotate\s*=\s*([0-9]{1,3})){0,1}/dtoverlay=waveshare35a/g' /boot/config.txt
sudo sed -i -r 's/Option\s+\"TransformationMatrix\"\s+\"(.+)\"/Option \"TransformationMatrix\" \"0 -1 1 1 0 0 0 0 1\"/g' /etc/X11/xorg.conf.d/99-calibration.conf
sudo reboot now
sudo sed -i -r 's/dtoverlay\s*=\s*waveshare35a(\s*:\s*rotate\s*=\s*([0-9]{1,3})){0,1}/dtoverlay=waveshare35a:rotate=270/g' /boot/config.txt
sudo sed -i -r 's/Option\s+\"TransformationMatrix\"\s+\"(.+)\"/Option \"TransformationMatrix\" \"0 1 0 -1 0 1 0 0 1\"/g' /etc/X11/xorg.conf.d/99-calibration.conf