Introduction¶
CircuitPython driver for common low-cost FocalTech capacitive touch chips. Currently supports FT6206 & FT6236
Dependencies¶
This driver depends on:
Please ensure all dependencies are available on the CircuitPython filesystem. This is easily achieved by downloading the Adafruit library and driver bundle.
Installing from PyPI¶
On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally from PyPI. To install for current user:
pip3 install adafruit-circuitpython-focaltouch
To install system-wide (this may be required in some cases):
sudo pip3 install adafruit-circuitpython-focaltouch
To install in a virtual environment in your current project:
mkdir project-name && cd project-name
python3 -m venv .env
source .env/bin/activate
pip3 install adafruit-circuitpython-focaltouch
Usage Example¶
import time
import board
import busio
import adafruit_focaltouch
# Create library object (named "ft") using a Bus I2C port
i2c = busio.I2C(board.SCL, board.SDA)
ft = adafruit_focaltouch.Adafruit_FocalTouch(i2c, debug=False)
while True:
# if the screen is being touched print the touches
if ft.touched:
print(ft.touches)
else:
print('no touch')
time.sleep(.15)
Contributing¶
Contributions are welcome! Please read our Code of Conduct before contributing to help this project stay welcoming.
Documentation¶
For information on building library documentation, please check out this guide.
Table of Contents¶
Simple tests¶
Ensure your device works with these simple tests.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | """
Example for getting touch data from an FT6206 or FT6236 capacitive
touch driver, over I2C
"""
import time
import busio
import board
import adafruit_focaltouch
# Create library object (named "ft") using a Bus I2C port
i2c = busio.I2C(board.SCL, board.SDA)
ft = adafruit_focaltouch.Adafruit_FocalTouch(i2c, debug=False)
while True:
# if the screen is being touched print the touches
if ft.touched:
print(ft.touches)
else:
print("no touch")
time.sleep(0.15)
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | """
Simple painting demo that draws on an Adafruit capacitive touch shield with
ILI9341 display and FT6206 captouch driver
"""
import busio
import board
import digitalio
import adafruit_focaltouch
from adafruit_rgb_display import ili9341, color565
# Create library object using our Bus I2C & SPI port
i2c = busio.I2C(board.SCL, board.SDA)
spi = busio.SPI(clock=board.SCK, MOSI=board.MOSI, MISO=board.MISO)
# Adafruit Metro M0 + 2.8" Capacitive touch shield
cs_pin = digitalio.DigitalInOut(board.D10)
dc_pin = digitalio.DigitalInOut(board.D9)
# Initialize display
display = ili9341.ILI9341(spi, cs=cs_pin, dc=dc_pin)
# Fill with black!
display.fill(color565(0, 0, 0))
ft = adafruit_focaltouch.Adafruit_FocalTouch(i2c)
while True:
if ft.touched:
ts = ft.touches
point = ts[0] # the shield only supports one point!
# perform transformation to get into display coordinate system!
y = 320 - point["y"]
x = 240 - point["x"]
display.fill_rectangle(x - 2, y - 2, 4, 4, color565(255, 255, 255))
|
adafruit_focaltouch
¶
CircuitPython driver for common low-cost FocalTech capacitive touch chips. Currently supports FT6206 & FT6236.
- Author(s): ladyada
Implementation Notes¶
Hardware:
- Adafruit 2.8” TFT LCD with Cap Touch Breakout Board w/MicroSD Socket (Product ID: 2090)
- Adafruit 2.8” TFT Touch Shield for Arduino w/Capacitive Touch (Product ID: 1947)
Software and Dependencies:
- Adafruit CircuitPython firmware for the ESP8622 and M0-based boards: https://github.com/adafruit/circuitpython/releases
- Adafruit’s Bus Device library (when using I2C/SPI): https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
-
class
adafruit_focaltouch.
Adafruit_FocalTouch
(i2c, address=56, debug=False)[source]¶ A driver for the FocalTech capacitive touch sensor.
-
touched
¶ Returns the number of touches currently detected
-
touches
¶ Returns a list of touchpoint dicts, with ‘x’ and ‘y’ containing the touch coordinates, and ‘id’ as the touch # for multitouch tracking
-
\ Sort by:\ best rated\ newest\ oldest\
\\
Add a comment\ (markup):
\``code``
, \ code blocks:::
and an indented block after blank line