Add standalone XPT2046 touch driver for RGB/ArduinoGFX boards (Sunton 4827S043R)#1028
Open
lucvan wants to merge 1 commit into
Open
Add standalone XPT2046 touch driver for RGB/ArduinoGFX boards (Sunton 4827S043R)#1028lucvan wants to merge 1 commit into
lucvan wants to merge 1 commit into
Conversation
openHASP's XPT2046 support was only wired into the TFT_eSPI and LovyanGFX display drivers, which own the SPI touch read. RGB-parallel boards must use ArduinoGFX for the display, so TOUCH_DRIVER=0x2046 there matched no dispatch branch and fell through to the no-op "Generic Touch" stub -- resistive touch was silently dead (discussion HASwitchPlate#648). Add a self-contained driver that runs XPT2046 on its own SPI bus, independent of the display driver: - src/drv/touch/touch_driver_xpt2046.{h,cpp}: TouchXpt2046 : BaseTouch on a dedicated SPIClass, IRQ press-detect, median-filtered 12-bit reads, and build-flag calibration (raw min/max window, SWAP_XY, MIRROR_X/Y). Guarded to compile only when TOUCH_DRIVER==0x2046 and neither TFT_eSPI nor LovyanGFX is active, so it is a no-op on every other board. - src/drv/touch/touch_driver.h: dispatch to the standalone driver after the existing TFT_eSPI/LovyanGFX 0x2046 branches (those still win when active). - Enable it on the Sunton ESP32-4827S043R: make its env buildable, set TOUCH_DRIVER=0x2046 with the touch pins, and add a measured calibration. Exclude the dead, uncalled src/drv/old/hasp_drv_touch.cpp for this env, whose 0x2046 branch assumes a TFT_eSPI display object. - Register sunton-4827s043r_16MB in the CI build matrix and the platformio_override template, alongside the existing 4827s043c variant, so nightly builds publish the resistive firmware. Verified on hardware: display and calibrated resistive touch working. Signed-off-by: Luc Van <lucvan@gmail.com>
34ee6d6 to
f81419b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
openHASP's XPT2046 support is only wired into the TFT_eSPI and LovyanGFX display drivers, which own the SPI touch read. RGB-parallel boards must use ArduinoGFX for the display, so on those boards
TOUCH_DRIVER=0x2046matches no branch intouch_driver.hand falls through to the no-op Generic Touch stub — resistive touch is silently dead. This is the blocker behind the unresolved reports of no touch on the Sunton ESP32-4827S043R (e.g. discussion #648).Change
A self-contained XPT2046 touch driver that runs on its own SPI bus, independent of the display driver:
src/drv/touch/touch_driver_xpt2046.{h,cpp}—TouchXpt2046 : BaseTouchusing a dedicatedSPIClass, PENIRQ press-detection, median-filtered 12-bit reads, and build-flag calibration (TOUCH_XPT2046_XMIN/XMAX/YMIN/YMAX,SWAP_XY,MIRROR_X/Y). Guarded to compile only whenTOUCH_DRIVER==0x2046and neither TFT_eSPI (USER_SETUP_LOADED) nor LovyanGFX (LGFX_USE_V1) is active — so it is a no-op on every existing board.src/drv/touch/touch_driver.h— dispatch to the new driver in a branch placed after the existing TFT_eSPI/LovyanGFX0x2046branches, so those still win when their display driver is active.user_setups/esp32s3/sunton-esp32-s3-tft.ini— turn the existing[sunton-4827s043r_16MB]template into a buildable[env:...], enableTOUCH_DRIVER=0x2046with the board's touch pins, and add a measured calibration. The dead, uncalledsrc/drv/old/hasp_drv_touch.cppis excluded for this env viabuild_src_filter(its0x2046branch assumes a TFT_eSPI display object and won't compile on ArduinoGFX).Testing
Built and flashed to a Sunton ESP32-4827S043R. Display renders and resistive touch works, calibrated across the full 480×272 panel (corner taps map correctly). No other board's build is affected — both the new driver and the legacy-file exclusion are scoped (compile guards / per-env
build_src_filter).Notes