From 259a26e79ec2d91e75f167df71b9a10804792b07 Mon Sep 17 00:00:00 2001 From: David Gwilliam Date: Mon, 16 Feb 2026 12:38:13 -0800 Subject: [PATCH] feat: add touch driver abstraction layer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit XPT2046 path: no change — uses TFT_eSPI built-in getTouch(). GT911 path: TouchDriver namespace with begin()/read() stub. TouchDriverGT911.cpp compiles to nothing on TFT_eSPI targets. Uncomment TAMC_GT911 lines to enable real capacitive touch. --- .../doorbell-touch-esp32-32e/TouchDriver.h | 21 ++++++++++ .../TouchDriverGT911.cpp | 42 +++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 sketches/doorbell-touch-esp32-32e/TouchDriver.h create mode 100644 sketches/doorbell-touch-esp32-32e/TouchDriverGT911.cpp diff --git a/sketches/doorbell-touch-esp32-32e/TouchDriver.h b/sketches/doorbell-touch-esp32-32e/TouchDriver.h new file mode 100644 index 0000000..0633cdb --- /dev/null +++ b/sketches/doorbell-touch-esp32-32e/TouchDriver.h @@ -0,0 +1,21 @@ +#pragma once +#include "BoardConfig.h" + +// ═══════════════════════════════════════════════════════════════════ +// Touch driver abstraction +// +// XPT2046: integrated in TFT_eSPI — DisplayManager calls +// _tft.getTouch() / _tft.setTouch() directly inside +// #if USE_TOUCH_XPT2046 blocks. +// +// GT911: separate I2C controller — namespace below. +// ═══════════════════════════════════════════════════════════════════ + +#if USE_TOUCH_GT911 + +namespace TouchDriver { + void begin(); + bool read(uint16_t &x, uint16_t &y); +} + +#endif diff --git a/sketches/doorbell-touch-esp32-32e/TouchDriverGT911.cpp b/sketches/doorbell-touch-esp32-32e/TouchDriverGT911.cpp new file mode 100644 index 0000000..0b6db1b --- /dev/null +++ b/sketches/doorbell-touch-esp32-32e/TouchDriverGT911.cpp @@ -0,0 +1,42 @@ +#include "BoardConfig.h" + +#if USE_TOUCH_GT911 + +#include "TouchDriver.h" +#include + +// ═══════════════════════════════════════════════════════════════════ +// GT911 capacitive touch — Waveshare ESP32-S3 Touch LCD 4.3" +// +// This is a compilable stub. To enable actual touch: +// 1. arduino-cli lib install "TAMC_GT911" +// 2. Uncomment the TAMC_GT911 lines below. +// ═══════════════════════════════════════════════════════════════════ + +// #include +// static TAMC_GT911 ts(TOUCH_SDA, TOUCH_SCL, TOUCH_INT, TOUCH_RST, +// SCREEN_WIDTH, SCREEN_HEIGHT); + +namespace TouchDriver { + +void begin() { + Wire.begin(TOUCH_SDA, TOUCH_SCL); + // ts.begin(); + // ts.setRotation(TOUCH_MAP_ROTATION); + Serial.println("[TOUCH] GT911 stub initialized"); +} + +bool read(uint16_t &x, uint16_t &y) { + // ts.read(); + // if (ts.isTouched) { + // x = ts.points[0].x; + // y = ts.points[0].y; + // return true; + // } + (void)x; (void)y; + return false; +} + +} // namespace TouchDriver + +#endif // USE_TOUCH_GT911