Skip to content

Commit cd85c73

Browse files
authored
Orientation Example
Adding a basic example showing how to change the orientation of the touchscreen to mach reorientation of the display.
1 parent 1753b42 commit cd85c73

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

examples/touchscreen_orientation.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import board
2+
import adafruit_touchscreen
3+
4+
# Allign the touchscreen so that the top left corner reads as x=0, y=0
5+
# Uncoment the display setup code for the opropriate touchscreen orientation.
6+
7+
'''
8+
# -------Rotate 0:
9+
ts = adafruit_touchscreen.Touchscreen(board.TOUCH_XL, board.TOUCH_XR,
10+
board.TOUCH_YD, board.TOUCH_YU,
11+
calibration=((5200, 59000), (5800, 57000)),
12+
size=(320, 240))
13+
'''
14+
15+
'''
16+
# -------Rotate 90:
17+
ts = adafruit_touchscreen.Touchscreen(board.TOUCH_YU, board.TOUCH_YD,
18+
board.TOUCH_XL, board.TOUCH_XR,
19+
calibration=((5200, 59000), (5800, 57000)),
20+
size=(240, 320))
21+
'''
22+
23+
'''
24+
# ------Rotate 180:
25+
ts = adafruit_touchscreen.Touchscreen(board.TOUCH_XR, board.TOUCH_XL,
26+
board.TOUCH_YU, board.TOUCH_YD,
27+
calibration=((5200, 59000), (5800, 57000)),
28+
size=(320, 240))
29+
'''
30+
31+
# ------Rotate 270:
32+
ts = adafruit_touchscreen.Touchscreen(board.TOUCH_YD, board.TOUCH_YU,
33+
board.TOUCH_XR, board.TOUCH_XL,
34+
calibration=((5200, 59000), (5800, 57000)),
35+
size=(240, 320))
36+
37+
while True:
38+
p = ts.touch_point
39+
if p:
40+
print(p)

0 commit comments

Comments
 (0)