fix(c6): drive AMOLED-2.16 C6 panel as CO5300, side-USB orientation

platformio.ini and the board files labelled the Waveshare
ESP32-C6-Touch-AMOLED-2.16 as an SH8601 panel, when it actually uses a
CO5300 (per the official spec) -- the same controller as the S3
AMOLED-2.16. It still rendered because display.cpp grafted CO5300-style
manufacturer registers (a 0xFE page-switch writing the 0x19/0x1C
driving-voltage registers) onto the Arduino_SH8601 class, and both
controllers speak standard MIPI DCS for pixel writes.

Rebase onto Arduino_CO5300 (matching the S3 AMOLED-2.16 sibling) and keep
only the page-0x20 panel-driving registers (0x19/0x1C) the class init
omits; everything else (0xC4/0x36/0x53/0x51/0x63/0x29) is now covered by
Arduino_CO5300::begin().

Adopt the CO5300 rotation-0 default (MADCTL 0x00) instead of the old forced
0x30 transpose, orienting the board with the USB port on the side (the
preferred desk orientation). Touch axis mapping is re-derived and tap-tested
on hardware to match: swap=false, mirror=(false,false).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jerome Tay
2026-06-08 21:37:34 +08:00
co-authored by Claude Opus 4.8
parent 9392d23092
commit 9375bd6d66
4 changed files with 46 additions and 39 deletions
@@ -22,11 +22,16 @@ void touch_hal_init(void) {
return;
}
touch.setMaxCoordinates(LCD_WIDTH, LCD_HEIGHT);
// C6 2.16 panel mapping (verified empirically): the CST9217's raw
// axes are swapped relative to the SH8601 raster AND X is mirrored.
// Matches the Waveshare BSP, which reads y = raw_byte1, x = W - raw_byte2.
touch.setSwapXY(true);
touch.setMirrorXY(true, false);
// C6 2.16 panel mapping. The original values (swap=true, mirrorX=true)
// were calibrated to the old display orientation that force-wrote MADCTL
// 0x30 (MV transpose + ML). The display now runs at the CO5300 class
// default (MADCTL 0x00 — USB-port-on-the-side orientation), so the touch
// mapping is re-derived to match. SensorLib applies swap then mirror
// (TouchDrvInterface::updateXY); tap-tested on C6 hardware, the raw
// CST9217 coordinates map straight through in this orientation — no swap,
// no mirror.
touch.setSwapXY(false);
touch.setMirrorXY(false, false);
pinMode(TP_INT, INPUT_PULLUP);
attachInterrupt(TP_INT, touch_isr, FALLING);
Serial.println("Touch init OK");