Skip to content

Commit 226dca4

Browse files
authored
Merge pull request #8 from RichardA1/master
Orientation Example
2 parents 585d5ac + 6d4c006 commit 226dca4

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+
# Change rotation variable to display setup code for the opropriate touchscreen orientation.
6+
7+
rotation = 270
8+
9+
if rotation == 0:
10+
# -------Rotate 0:
11+
ts = adafruit_touchscreen.Touchscreen(board.TOUCH_XL, board.TOUCH_XR,
12+
board.TOUCH_YD, board.TOUCH_YU,
13+
calibration=((5200, 59000), (5800, 57000)),
14+
size=(320, 240))
15+
16+
if rotation == 90:
17+
# -------Rotate 90:
18+
ts = adafruit_touchscreen.Touchscreen(board.TOUCH_YU, board.TOUCH_YD,
19+
board.TOUCH_XL, board.TOUCH_XR,
20+
calibration=((5200, 59000), (5800, 57000)),
21+
size=(240, 320))
22+
23+
if rotation == 180:
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+
if rotation == 270:
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)