XPT2046_Bitbang
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.
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.
Sketch
-> Include Library
-> Add .ZIP Library
and select the downloaded zip file.#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.calibrate()
: Calibrates the touchscreen and displays prompts via Serial.getTouch()
: Gets the current touch point. Returns a Point
struct with x
and y
members.loadCalibration()
: Loads calibration data from SPIFFS.saveCalibration()
: Saves calibration data to SPIFFS.Refer to XPT2046_BitbangExample.ino
for a comprehensive usage example. This example demonstrates the initialization, calibration, 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.