-
Notifications
You must be signed in to change notification settings - Fork 9
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
I am not sure how it could be added to this library, but I created the following code to recalculate the touch coordinates based on the orientation of the screen set by board.DISPLAY.rotation. This fixes an issue with how the hotspots are setup from the Button() function used in Displayio.
### Function for recalculating .touch_point based on Display rotation
def touch_rotate():
touchData = ts.touch_point
if touchData:
if display.rotation == 0:
return touchData
elif display.rotation == 90:
touchX = adafruit_touchscreen.map_range(touchData[0], 0, ts._size[0], ts._size[0], 0)
return (touchData[1],int(touchX) )
elif display.rotation == 180:
touchX = adafruit_touchscreen.map_range(touchData[0], 0, ts._size[0], ts._size[0], 0)
touchY = adafruit_touchscreen.map_range(touchData[1], 0, ts._size[1], ts._size[1], 0)
return (int(touchX), int(touchY))
elif display.rotation == 270:
touchY = adafruit_touchscreen.map_range(touchData[1], 0, ts._size[1], ts._size[1], 0)
return (int(touchY),touchData[0] )Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request