Skip to main content

A library to use XPT2046 touch module

Project description

XPT2046_asukiaaa_python

Python library for XPT2046 Touchscreen. This library references Luca8991/XPT2046-Python and Adafruit_CircuitPython_RGB_Display.

Usage

Enable SPI for Raspberry Pi

sudo raspi-config nonint do_spi 0

No need to reboot.

Wiring

Raspberri Pi <--> XPT2046
MOSI (GPIO10) <--> DIN
MISO (GPIO9) <--> DO
SCLK (GPIO11) <--> CLK
GPIO7 or any <--> CS
3V3 <--> VCC
GND <--> GND

This library does not use IRQ pin.

Code, same as in tests/print_touch.py file:

from XPT2046_asukiaaa_python import XPT2046
import board
import busio
from digitalio import DigitalInOut
from time import sleep

cs = DigitalInOut(board.D7)
spi = busio.SPI(board.SCLK, board.MOSI, board.MISO)
touch = XPT2046(spi, cs=cs)

print("start monitoring touch")

while True:
    touch.update()
    if touch.coordinate is not None:
        print(touch.coordinate)
    sleep(.01)

License

MIT

References

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

XPT2046-asukiaaa-python-1.0.0.tar.gz (4.0 kB view hashes)

Uploaded Source

Built Distribution

XPT2046_asukiaaa_python-1.0.0-py3-none-any.whl (4.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page