Add CST9217 touch panel with touch-to-wake display blanking

Touch driver via SensorLib TouchDrvCST92xx on I2C 0x1A with interrupt
on GPIO 12. Touch events unblank the display and reset the blanking
timer. Display blanks after 10 seconds of inactivity.

XL9555 TOUCH_RST now explicitly released at boot. Touch init runs
with explicit I2C_SDA/I2C_SCL pins (same fix as XPowersLib).
This commit is contained in:
GlassOnTin 2026-03-27 18:48:07 +00:00
commit deb061943a
2 changed files with 35 additions and 3 deletions

View file

@ -52,8 +52,9 @@
if (!co5300_init()) return false;
co5300_set_brightness(128);
// Disable blanking until button wake is implemented
display_blanking_enabled = false;
// Enable blanking — touch input now available to unblank
display_blanking_enabled = true;
display_blanking_timeout = 10000; // 10 seconds
// Allocate partial framebuffer for clock region (PSRAM preferred for large buffers)
clock_fb = (uint16_t *)heap_caps_malloc(CLOCK_FB_W * CLOCK_FB_H * 2, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT);

View file

@ -28,6 +28,14 @@
#include <BoschFirmware.h>
SensorBHI260AP *bhi260 = NULL;
bool bhi260_ready = false;
// CST9217 capacitive touch panel
#include <touch/TouchDrvCST92xx.h>
TouchDrvCST92xx touch;
bool touch_ready = false;
volatile bool touch_irq = false;
#define TP_INT 12
void IRAM_ATTR touch_isr() { touch_irq = true; }
#endif
#define CHANNEL_FIFO_SIZE (CONFIG_UART_BUFFER_SIZE / NUM_CHANNELS)
@ -284,10 +292,18 @@ void setup() {
xl9555_enable_lora_antenna();
xl9555_set(EXPANDS_DRV_EN, true); // Enable haptic motor driver
xl9555_set(EXPANDS_DISP_EN, true); // Enable display power gate
delay(10);
xl9555_set(EXPANDS_TOUCH_RST, true); // Release touch reset
delay(100);
drv2605_init();
if (drv2605_ready) drv2605_play(HAPTIC_SHARP_CLICK); // Boot feedback
// Init touch panel
touch.setPins(-1, TP_INT); // No reset pin (handled by XL9555), INT on GPIO 12
if (touch.begin(Wire, 0x1A, I2C_SDA, I2C_SCL)) {
touch_ready = true;
attachInterrupt(TP_INT, touch_isr, FALLING);
}
// BHI260AP init deferred — firmware upload takes ~10s at 1MHz I2C
// and blocks serial communication during boot. Will be initialized
// lazily from the main loop after radio is up.
@ -1997,6 +2013,21 @@ void loop() {
input_read();
#endif
// Touch panel event handling
#if BOARD_MODEL == BOARD_TWATCH_ULT
if (touch_ready && touch_irq) {
touch_irq = false;
int16_t tx, ty;
if (touch.getPoint(&tx, &ty, 1) > 0) {
// Touch detected — unblank display and update activity
#if HAS_DISPLAY
display_unblank();
#endif
last_unblank_event = millis();
}
}
#endif
// Deferred BHI260AP init — runs once after boot is complete
// Firmware upload takes ~10s and blocks, so we do it after radio is up
#if BOARD_MODEL == BOARD_TWATCH_ULT