Example: https://wokwi.com/arduino/projects/299392610996322826 (rotating the potentiometer by 142 degrees).
180 degrees seem to be the most confusing.
A good place to start looking is the slide-potentiometer implementation (#63), where a similar issue has been fixed using the inverse of the matrix returned by getScreenCTM().