File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change
1
+ # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
2
+ # SPDX-License-Identifier: MIT
3
+
4
+ """
5
+ Example for getting touch data from an FT6206 or FT6236 capacitive
6
+ touch driver, over I2C. This version uses an interrupt to prevent
7
+ read errors from the FocalTouch chip.
8
+ """
9
+
10
+ import time
11
+ import busio
12
+ import board
13
+ from digitalio import DigitalInOut , Direction
14
+ import adafruit_focaltouch
15
+
16
+
17
+ if hasattr (
18
+ board , "SCL"
19
+ ): # if SCL and SDA pins are defined by the board definition, use them.
20
+ SCL_pin = board .SCL
21
+ SDA_pin = board .SDA
22
+ else :
23
+ SCL_pin = board .IO42 # set to a pin that you want to use for SCL
24
+ SDA_pin = board .IO41 # set to a pin that you want to use for SDA
25
+
26
+ IRQ_pin = board .IO39 # select a pin to connect to the display's interrupt pin ("IRQ")
27
+
28
+ i2c = busio .I2C (SCL_pin , SDA_pin )
29
+
30
+ # Setup the interrupt (IRQ) pin for input
31
+ irq = DigitalInOut (board .IO39 )
32
+ irq .direction = Direction .INPUT
33
+
34
+ # Create library object (named "ft") using a Bus I2C port and using an interrupt pin (IRQ)
35
+ ft = adafruit_focaltouch .Adafruit_FocalTouch (i2c , debug = False , irq_pin = irq )
36
+
37
+
38
+ print ("\n \n Ready for touches..." )
39
+
40
+ while True :
41
+ # if the screen is being touched print the touches
42
+ if ft .touched :
43
+ print (ft .touches )
44
+ else :
45
+ print ("no touch" )
46
+
47
+ time .sleep (0.05 )
You can’t perform that action at this time.
0 commit comments