circuitpython-cst816

CircuitPython driver for the CST816 capacitive touch screen IC


Keywords
adafruit, blinka, circuitpython, micropython, cst816, CST816S, CST816T, touch, display, driver
License
MIT
Install
pip install circuitpython-cst816==0.1.0

Documentation

Introduction

Discord Build Status Code Style: Black

CircuitPython driver for the CST816 capacitive touch screen IC

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 or individual libraries can be installed using circup.

Usage Example

import time
import board
import busio
import cst816

# Initialize I2C
i2c = busio.I2C(board.GP7,board.GP6)
touch = cst816.CST816(i2c)

# Check if the touch controller is detected
if touch.who_am_i():
    print("CST816 detected.")
else:
    print("CST816 not detected.")

# Read touch data continuously
while True:
    point = touch.get_point()
    gesture = touch.get_gesture()
    press = touch.get_touch()
    distance = touch.get_distance()
    print("Position: {0},{1} - Gesture: {2} - Pressed? {3} - Distance: {4},{5}".format(point.x_point, point.y_point, gesture, press, distance.x_dist, distance.y_dist))
    time.sleep(0.05)

Contributing

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