6#if !defined(ESP32) || !(CONFIG_IDF_TARGET_ESP32S3)
9#include "roo_logging.h"
18constexpr uint8_t kCh422gAddrWrSet = 0x24;
19constexpr uint8_t kCh422gAddrWrIo = 0x38;
20constexpr uint8_t kCh422gConfigWriteEnable = 0b00000001;
23constexpr uint8_t kExioTpRst = 1;
24constexpr uint8_t kExioLcdBl = 2;
25constexpr uint8_t kExioLcdRst = 3;
28constexpr int kI2cSda = 8;
29constexpr int kI2cScl = 9;
30constexpr uint32_t kI2cFreq = 400000;
33constexpr int kGt911AsyncInitDelayMs = 300;
35constexpr esp32s3_dma::Config kWaveshareConfig = {
42 .hsync_pulse_width = 4,
43 .hsync_back_porch = 8,
44 .hsync_front_porch = 8,
46 .vsync_pulse_width = 4,
47 .vsync_back_porch = 16,
48 .vsync_front_porch = 16,
51 .prefer_speed = 16000000,
72WaveshareEsp32s3TouchLcd43::WaveshareEsp32s3TouchLcd43(
73 Orientation orientation, I2cMasterBusHandle i2c)
75 ch422g_wr_set_(i2c_, kCh422gAddrWrSet),
76 ch422g_wr_io_(i2c_, kCh422gAddrWrIo),
77 display_(kWaveshareConfig),
84 [this](uint8_t state) {
85 writeEXIO(kExioTpRst, state > 0);
87 [
this]() { writeEXIO(kExioTpRst,
false); }),
88 kGt911AsyncInitDelayMs),
89 exio_shadow_(0b00001110) {
90 display_.setOrientation(orientation);
93bool WaveshareEsp32s3TouchLcd43::initTransport() {
95 LOG(ERROR) <<
"PSRAM not found - required for frame buffer";
99 i2c_.init(kI2cSda, kI2cScl, kI2cFreq);
100 ch422g_wr_set_.init();
101 ch422g_wr_io_.init();
105 exio_shadow_ = (1 << kExioLcdRst) | (1 << kExioLcdBl) | (1 << kExioTpRst);
106 writeEXIO(kExioTpRst,
true);
111DisplayDevice& WaveshareEsp32s3TouchLcd43::display() {
115TouchDevice* WaveshareEsp32s3TouchLcd43::touch() {
119TouchCalibration WaveshareEsp32s3TouchLcd43::touch_calibration() {
120 return TouchCalibration(0, 0, 800, 480);
123void WaveshareEsp32s3TouchLcd43::setBacklight(
bool on) {
124 writeEXIO(kExioLcdBl, on);
127void WaveshareEsp32s3TouchLcd43::writeEXIO(uint8_t pin,
bool state) {
129 exio_shadow_ |= (1 << pin);
131 exio_shadow_ &= ~(1 << pin);
135 roo::byte enable_cmd[] = {roo::byte{kCh422gConfigWriteEnable}};
136 if (!ch422g_wr_set_.transmit(enable_cmd, 1)) {
137 LOG(ERROR) <<
"CH422G write enable failed";
141 roo::byte output_data[] = {roo::byte{exio_shadow_}};
142 if (!ch422g_wr_io_.transmit(output_data, 1)) {
143 LOG(ERROR) <<
"CH422G output write failed";