ddxfish / XPT2046_Bitbang_Arduino_Library

A software implementation of SPI to access the XPT2046 on the 2432S028 board and similar
GNU General Public License v3.0
6 stars 2 forks source link

XPT2046_Bitbang Library for Arduino

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. image

Features

Installation

  1. Download the repository as a zip file.
  2. In the Arduino IDE, go to Sketch -> Include Library -> Add .ZIP Library and select the downloaded zip file.
  3. The library should now be available in your Arduino IDE.

Usage

Initialization

#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);

Basic methods

Example

Refer to XPT2046_BitbangExample.ino for a comprehensive usage example. This example demonstrates the initialization, calibration, and reading of touch points.

Contributing

Pull requests are welcome! For major changes, please open an issue first to discuss what you'd like to change.