diff --git a/src/drv/tft/tft_driver_lovyangfx.cpp b/src/drv/tft/tft_driver_lovyangfx.cpp index 62e57625..3730a740 100644 --- a/src/drv/tft/tft_driver_lovyangfx.cpp +++ b/src/drv/tft/tft_driver_lovyangfx.cpp @@ -386,7 +386,6 @@ lgfx::ITouch* _init_touch(Preferences* preferences) #endif #if TOUCH_DRIVER == 0x2046 - { auto touch = new lgfx::Touch_XPT2046(); auto cfg = touch->config(); @@ -526,6 +525,68 @@ void LovyanGfx::init(int w, int h) _panel_instance->config(cfg); } +#elif defined(ESP32_2432S028R) + auto _panel_instance = new lgfx::Panel_ILI9341(); + auto _bus_instance = new lgfx::Bus_SPI(); + auto _touch_instance = new lgfx::Touch_XPT2046(); + + { + auto cfg = _bus_instance->config(); + cfg.spi_host = SPI2_HOST; + cfg.spi_mode = 0; + cfg.freq_write = 40000000; + cfg.freq_read = 16000000; + cfg.spi_3wire = false; + cfg.use_lock = true; + cfg.dma_channel = 1; + cfg.pin_sclk = 14; + cfg.pin_mosi = 13; + cfg.pin_miso = 12; + cfg.pin_dc = 2; + _bus_instance->config(cfg); + _panel_instance->setBus(_bus_instance); + } + + { + auto cfg = _panel_instance->config(); + cfg.pin_cs = 15; + cfg.pin_rst = -1; + cfg.pin_busy = -1; + cfg.memory_width = 240; + cfg.memory_height = 320; + cfg.panel_width = 240; + cfg.panel_height = 320; + cfg.offset_x = 0; + cfg.offset_y = 0; + cfg.offset_rotation = 0; + cfg.dummy_read_pixel = 8; + cfg.dummy_read_bits = 1; + cfg.readable = true; + cfg.invert = false; + cfg.rgb_order = false; + cfg.dlen_16bit = false; + cfg.bus_shared = false; + _panel_instance->config(cfg); + } + + { + auto cfg = _touch_instance->config(); + cfg.x_min = 300; + cfg.x_max = 3900; + cfg.y_min = 200; + cfg.y_max = 3700; + cfg.pin_int = -1; + cfg.bus_shared = false; + cfg.offset_rotation = 6; + cfg.spi_host = VSPI_HOST; + cfg.freq = 1000000; + cfg.pin_sclk = 25; + cfg.pin_mosi = 32; + cfg.pin_miso = 39; + cfg.pin_cs = 33; + _touch_instance->config(cfg); + _panel_instance->setTouch(_touch_instance); + } #else Preferences preferences; diff --git a/src/drv/touch/touch_driver_lovyangfx.h b/src/drv/touch/touch_driver_lovyangfx.h index 31daf48a..b98dce1e 100644 --- a/src/drv/touch/touch_driver_lovyangfx.h +++ b/src/drv/touch/touch_driver_lovyangfx.h @@ -47,12 +47,16 @@ class TouchLovyanGfx : public BaseTouch { void init(int w, int h) { +#if defined(TOUCH_SDA) && defined(TOUCH_SCL) && defined(I2C_TOUCH_FREQUENCY) Wire.begin(TOUCH_SDA, TOUCH_SCL, (uint32_t)I2C_TOUCH_FREQUENCY); touch_scan(Wire); +#endif } void calibrate(uint16_t* calData) { + /* + haspTft.tft.fillScreen(TFT_BLACK); // haspTft.tft.setCursor(20, 0); // haspTft.tft.setTextFont(1); @@ -65,6 +69,8 @@ class TouchLovyanGfx : public BaseTouch { delay(500); haspTft.tft.calibrateTouch(calData, TFT_MAGENTA, TFT_BLACK, 15); // haspTft.tft.setTouch(calData); + + */ } };