Simple tests

Ensure your device works with these simple tests.

examples/focaltouch_print_touches.py
 1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
 2# SPDX-License-Identifier: MIT
 3
 4"""
 5Example for getting touch data from an FT6206 or FT6236 capacitive
 6touch driver, over I2C
 7"""
 8
 9import time
10import busio
11import board
12import adafruit_focaltouch
13
14# Create library object (named "ft") using a Bus I2C port
15i2c = busio.I2C(board.SCL, board.SDA)
16
17ft = adafruit_focaltouch.Adafruit_FocalTouch(i2c, debug=False)
18
19while True:
20    # if the screen is being touched print the touches
21    if ft.touched:
22        print(ft.touches)
23    else:
24        print("no touch")
25
26    time.sleep(0.15)
examples/focaltouch_paint_simpletest.py
 1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
 2# SPDX-License-Identifier: MIT
 3
 4"""
 5Simple painting demo that draws on an Adafruit capacitive touch shield with
 6ILI9341 display and FT6206 captouch driver
 7"""
 8
 9import busio
10import board
11import digitalio
12from adafruit_rgb_display import ili9341, color565
13import adafruit_focaltouch
14
15# Create library object using our Bus I2C & SPI port
16i2c = busio.I2C(board.SCL, board.SDA)
17spi = busio.SPI(clock=board.SCK, MOSI=board.MOSI, MISO=board.MISO)
18
19# Adafruit Metro M0 + 2.8" Capacitive touch shield
20cs_pin = digitalio.DigitalInOut(board.D10)
21dc_pin = digitalio.DigitalInOut(board.D9)
22
23# Initialize display
24display = ili9341.ILI9341(spi, cs=cs_pin, dc=dc_pin)
25# Fill with black!
26display.fill(color565(0, 0, 0))
27
28ft = adafruit_focaltouch.Adafruit_FocalTouch(i2c)
29
30while True:
31    if ft.touched:
32        ts = ft.touches
33        point = ts[0]  # the shield only supports one point!
34        # perform transformation to get into display coordinate system!
35        y = 320 - point["y"]
36        x = 240 - point["x"]
37        display.fill_rectangle(x - 2, y - 2, 4, 4, color565(255, 255, 255))