Simple test

Ensure your device works with this simple test.

examples/cst8xx_simpletest.py
 1# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
 2# SPDX-FileCopyrightText: Copyright (c) 2023 Melissa LeBlanc-Williams for Adafruit Industries
 3#
 4# SPDX-License-Identifier: Unlicense
 5
 6
 7import board
 8import adafruit_cst8xx
 9
10ctp = adafruit_cst8xx.Adafruit_CST8XX(board.I2C())
11
12events = adafruit_cst8xx.EVENTS
13while True:
14    if ctp.touched:
15        for touch_id, touch in enumerate(ctp.touches):
16            x = touch["x"]
17            y = touch["y"]
18            event = events[touch["event_id"]]
19            print(f"touch_id: {touch_id}, x: {x}, y: {y}, event: {event}")