Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions examples/touchscreen_orientation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import board
import adafruit_touchscreen

# Allign the touchscreen so that the top left corner reads as x=0, y=0
# Change rotation variable to display setup code for the opropriate touchscreen orientation.

rotation = 270

if rotation == 0:
# -------Rotate 0:
ts = adafruit_touchscreen.Touchscreen(board.TOUCH_XL, board.TOUCH_XR,
board.TOUCH_YD, board.TOUCH_YU,
calibration=((5200, 59000), (5800, 57000)),
size=(320, 240))

if rotation == 90:
# -------Rotate 90:
ts = adafruit_touchscreen.Touchscreen(board.TOUCH_YU, board.TOUCH_YD,
board.TOUCH_XL, board.TOUCH_XR,
calibration=((5200, 59000), (5800, 57000)),
size=(240, 320))

if rotation == 180:
# ------Rotate 180:
ts = adafruit_touchscreen.Touchscreen(board.TOUCH_XR, board.TOUCH_XL,
board.TOUCH_YU, board.TOUCH_YD,
calibration=((5200, 59000), (5800, 57000)),
size=(320, 240))

if rotation == 270:
# ------Rotate 270:
ts = adafruit_touchscreen.Touchscreen(board.TOUCH_YD, board.TOUCH_YU,
board.TOUCH_XR, board.TOUCH_XL,
calibration=((5200, 59000), (5800, 57000)),
size=(240, 320))

while True:
p = ts.touch_point
if p:
print(p)