Skip to content

Commit fd0c808

Browse files
committed
Add example with new options
1 parent bc2f185 commit fd0c808

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

docs/examples.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,12 @@ Ensure your device works with this simple test.
66
.. literalinclude:: ../examples/tsc2007_simpletest.py
77
:caption: examples/tsc2007_simpletest.py
88
:linenos:
9+
10+
Display Specific test
11+
----------------------
12+
13+
Initialize a display and set options so that axes are correct to rotation.
14+
15+
.. literalinclude:: ../examples/tsc2007_3.5_feather_v2.py
16+
:caption: examples/tsc2007_3.5_feather_v2.py
17+
:linenos:

examples/tsc2007_3.5_feather_v2.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2024 Melissa LeBlanc-Williams for Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: Unlicense
4+
5+
6+
import board
7+
import displayio
8+
from adafruit_hx8357 import HX8357
9+
import adafruit_tsc2007
10+
11+
# Initialize the Display
12+
displayio.release_displays()
13+
14+
spi = board.SPI()
15+
tft_cs = board.D9
16+
tft_dc = board.D10
17+
18+
display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs)
19+
display = HX8357(display_bus, width=480, height=320)
20+
21+
# Use for I2C
22+
i2c = board.I2C() # uses board.SCL and board.SDA
23+
# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
24+
25+
tsc = adafruit_tsc2007.TSC2007(i2c, invert_x=True, swap_xy=True)
26+
27+
while True:
28+
if tsc.touched:
29+
point = tsc.touch
30+
if point["pressure"] < 100: # ignore touches with no 'pressure' as false
31+
continue
32+
print("Touchpoint: (%d, %d, %d)" % (point["x"], point["y"], point["pressure"]))

0 commit comments

Comments
 (0)