skip to docs
xpt2046-circuitpython
A CircuitPython (or Adafruit-Blinka) library which reads values from an XPT2046 chip, commonly found on cheap microcontroller TFT displays.
installation
This project is available on PyPi:
pip3 install xpt2046-circuitpython
Or, to install it manually:
git clone https://github.com/humeman/xpt2046-circuitpython
cd xpt2046-circuitpython
pip3 install .
If you're using this on regular Linux rather than CircuitPython, make sure you also install Adafruit Blinka.
usage
Be sure to enable SPI in sudo raspi-config before proceeding.
sample wiring
| TFT | Board | GPIO | Pin # |
|---|---|---|---|
| T_CLK | SPI0 SCLK | GPIO11 | 23 |
| T_CS | GPIO6 | 31 | |
| T_DIN | SPI0 MOSI | GPIO10 | 19 |
| T_DO | SPI0 MISO | GPIO9 | 21 |
| T_IRQ | GPIO22 | 15 |
examples
The most basic read example is:
import xpt2046_circuitpython
import time
import busio
import digitalio
from board import SCK, MOSI, MISO, D6, D22
# Pin config
T_CS_PIN = D6
T_IRQ_PIN = D22
# Set up SPI bus using hardware SPI
spi = busio.SPI(clock=SCK, MOSI=MOSI, MISO=MISO)
# Create touch controller
touch = xpt2046.Touch(
spi,
cs = digitalio.DigitalInOut(T_CS_PIN),
interrupt = digitalio.DigitalInOut(T_IRQ_PIN)
)
# Check if we have an interrupt signal
if touch.is_pressed():
# Get the coordinates for this touch
print(touch.get_coordinates())
Some more examples:
- read.py: A simple program which continuously prints coordinates when the screen is pressed
- adafruit-ili.py: A simple drawing program for an ILI9341 display controlled by the Adafruit display library
Metadata
Release files for xpt2046-circuitpython 1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| xpt2046_circuitpython-1.0.3.tar.gz | 17.4 kB | Without provenance | Details for xpt2046_circuitpython-1.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| xpt2046_circuitpython-1.0.3-py3-none-any.whl | Python 3 | none | any | Details for xpt2046_circuitpython-1.0.3-py3-none-any.whl |
Total release size: 35.2 kB
Release files / xpt2046_circuitpython-1.0.3.tar.gz
| Download URL | xpt2046_circuitpython-1.0.3.tar.gz |
|---|---|
| Size | 17.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5074fe5f2bb4612643facbf13343ffc16471bafa3a9f3bd83aea1268bfcb7f16
|
|
BLAKE2b-256 checksum How to use checksums |
4b72b4865353ee8ab238d717053aa82d6d701d25d18b556f9d7669077e95d67d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.10
|
Release files / xpt2046_circuitpython-1.0.3-py3-none-any.whl
| Download URL | xpt2046_circuitpython-1.0.3-py3-none-any.whl |
|---|---|
| Size | 17.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0ba99b71809781503e437768679bdd1c41f99c8596ac42f22bea7495bea22da2
|
|
BLAKE2b-256 checksum How to use checksums |
ee0db8b3f7c1b7210fb134cb5b41517dc064e7ddaba73a24ac1080726af18969
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.10
|
Security for xpt2046-circuitpython 1.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.