Simple test

Ensure your device works with this simple test.

examples/tsc2007_simpletest.py
 1# SPDX-FileCopyrightText: Copyright (c) 2022 ladyada for Adafruit Industries
 2#
 3# SPDX-License-Identifier: Unlicense
 4
 5
 6import board
 7import adafruit_tsc2007
 8
 9# Use for I2C
10i2c = board.I2C()  # uses board.SCL and board.SDA
11# i2c = board.STEMMA_I2C()  # For using the built-in STEMMA QT connector on a microcontroller
12
13irq_dio = None  # don't use an irq pin by default
14# uncomment for optional irq input pin so we don't continuously poll the I2C for touches
15# irq_dio = digitalio.DigitalInOut(board.A0)
16tsc = adafruit_tsc2007.TSC2007(i2c, irq=irq_dio)
17
18while True:
19    if tsc.touched:
20        point = tsc.touch
21        if point["pressure"] < 100:  # ignore touches with no 'pressure' as false
22            continue
23        print("Touchpoint: (%d, %d, %d)" % (point["x"], point["y"], point["pressure"]))