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
 8
 9import adafruit_cst8xx
10
11ctp = adafruit_cst8xx.Adafruit_CST8XX(board.I2C())
12
13events = adafruit_cst8xx.EVENTS
14while True:
15    if ctp.touched:
16        for touch_id, touch in enumerate(ctp.touches):
17            x = touch["x"]
18            y = touch["y"]
19            event = events[touch["event_id"]]
20            print(f"touch_id: {touch_id}, x: {x}, y: {y}, event: {event}")