lv_binding_micropython icon indicating copy to clipboard operation
lv_binding_micropython copied to clipboard

ESP32/CYD: Add support for XPT2046 access via SoftSpi and user supplied orientation tables for ILI9XXX classes

Open Angus71 opened this issue 1 year ago • 1 comments

As I own a set of these cheap 2432S028 boards (CYD - Cheap Yellow Display) I wanted to use this project to create a UI for these kind of boards, but the used XPT2046 is not connected to any of the hardware SPI interfaces and needs to be used with a SoftSPI.

While implementing the required changes, I tried to keep the existing API as stable as possible. So the usage of a hardware vs. a software SPI based XPT2046 should be seamless

from xpt2046 import xpt2046_softspi as xpt2046

To support an easier integration of user supplied orientation_tables in ILI9XXX based classes I extended the API to enable the user to provide an own orientation_table and thus still reuse the already defined rotation constants. The API, when the user provided a positive rotation value is still active.

Changes

  • ILI9341: Add software reset command in init command
  • ILI9XXX: Add option to provide external orientation table
  • XPT2046: Add SoftSPI support (E.g. CYD boards)
  • XPT2046: Returned coords are never outside the screen size

Possible optimizations

  • Due to the nature of the SoftSPI it uses more CPU resources, but for the XPT2046 this might be insignificant (3 bytes are exchanged). It might be possible to change to an interrupt based implementation, if an interrupt pin is available. (xpt2046_softspi.stat() currently returns around 2.9)

Angus71 avatar May 09 '24 08:05 Angus71

For anyone starting out, there is a nice example in https://forum.lvgl.io/t/modulo-esp32-2432s08-ili9341-xpt2046-problem-touch/14685 I posted a solution, using this patch, and it works with my CYD ESP32-2432S028...

However the button press is a little skewed towards the USB port, while in portrait mode. I (or someone) needs to find the correct calibration numbers.

robertojguerra avatar Jul 26 '24 07:07 robertojguerra