Introduction

Documentation Status Discord Build Status

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.

Usage Example

import time
import busio
import board
import adafruit_focaltouch

# Create library object using our Bus I2C port
i2c = busio.I2C(board.SCL, board.SDA)

ft = adafruit_focaltouch.Adafruit_FocalTouch(i2c, debug=True)

while True:
    n = ft.touched
    if n:
        print(ft.touches)

Contributing

Contributions are welcome! Please read our Code of Conduct before contributing to help this project stay welcoming.

Building locally

To build this library locally you’ll need to install the circuitpython-build-tools package.

python3 -m venv .env
source .env/bin/activate
pip install circuitpython-build-tools

Once installed, make sure you are in the virtual environment:

source .env/bin/activate

Then run the build:

circuitpython-build-bundles --filename_prefix adafruit-circuitpython-focaltouch --library_location .

Sphinx documentation

Sphinx is used to build the documentation based on rST files and comments in the code. First, install dependencies (feel free to reuse the virtual environment from above):

python3 -m venv .env
source .env/bin/activate
pip install Sphinx sphinx-rtd-theme

Now, once you have the virtual environment activated:

cd docs
sphinx-build -E -W -b html . _build/html

This will output the documentation to docs/_build/html. Open the index.html in your browser to view them. It will also (due to -W) error out on any warning like Travis will. This is a good way to locally verify it will pass.

Table of Contents

Simple tests

Ensure your device works with these simple tests.

examples/print_touches.py
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
"""
Example for getting touch data from an FT6206 or FT6236 capacitive
touch driver, over I2C
"""

import busio
import board
import adafruit_focaltouch

# Create library object using our Bus I2C port
i2c = busio.I2C(board.SCL, board.SDA)

ft = adafruit_focaltouch.Adafruit_FocalTouch(i2c, debug=True)

while True:
    n = ft.touched
    if n:
        print(ft.touches)
examples/simple_paint.py
 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:

Software and Dependencies:

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

Indices and tables