Skip to content

Orientation Example #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 15, 2020
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)