XPT2046_Bitbang_Slim
is an Arduino library that provides a bit-banged SPI interface to communicate with XPT2046 touchscreen controllers. This library is ideal for users who require greater flexibility in pin choice for the MOSI, MISO, CLK, and CS lines.
This is a fork of the original XPT2046_Bitbang_Slim library, rewritten to work without SPIFFS dependency.
Really I made this for those esp32-2432S028R and esp32-2432S024R ESP32 Cheap Yellow Displays, though it should be compatible with a lot more. It's just that those boards had unusual hard-wired software SPI.
- Manual bit-banging SPI communication
- Calibration of the touchscreen
- Getting touchscreen coordinates
- Download the repository as a zip file.
- In the Arduino IDE, go to
Sketch
->Include Library
->Add .ZIP Library
and select the downloaded zip file. - The library should now be available in your Arduino IDE.
#define MOSI_PIN 32
#define MISO_PIN 39
#define CLK_PIN 25
#define CS_PIN 33
#include <XPT2046_Bitbang.h>
XPT2046_Bitbang touchscreen(MOSI_PIN, MISO_PIN, CLK_PIN, CS_PIN);
begin()
: Initializes the touchscreen.setCalibration()
: Set calibration values.getTouch()
: Gets the current touch point. Returns aTouchPoint
struct withx
,y
,xRaw
,yRaw
andzRaw
members.
Refer to basic_touch.ino
for a usage example. This example demonstrates the initialization and reading of touch points.
Pull requests are welcome! For major changes, please open an issue first to discuss what you'd like to change.