Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 119 additions & 0 deletions include/graphics/LGFX/LGFX_ESP32_S3_TOUCH.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
#pragma once

#define LGFX_USE_V1
#include <LovyanGFX.hpp>

#ifndef SPI_FREQUENCY
#define SPI_FREQUENCY 80000000
#endif

class LGFX_ESP32_S3_TOUCH : public lgfx::LGFX_Device
{
lgfx::Panel_ST7789 _panel_instance;
lgfx::Bus_SPI _bus_instance;
lgfx::Light_PWM _light_instance;
lgfx::Touch_CST816S _touch_instance;

public:
const uint32_t screenWidth = 320;
const uint32_t screenHeight = 240;

bool hasButton(void) { return true; }

LGFX_ESP32_S3_TOUCH(void)
{
{
auto cfg = _bus_instance.config();

// SPI
cfg.spi_host = SPI3_HOST;
cfg.spi_mode = 0;
cfg.freq_write = SPI_FREQUENCY; // SPI clock for transmission (up to 80MHz, rounded to
// the value obtained by dividing 80MHz by an integer)
cfg.freq_read = 16000000; // SPI clock when receiving
cfg.spi_3wire = false;
cfg.use_lock = false; // Set to true to use transaction locking
cfg.dma_channel = SPI_DMA_CH_AUTO; // SPI_DMA_CH_AUTO; // Set DMA channel
// to use (0=not use DMA / 1=1ch / 2=ch
// / SPI_DMA_CH_AUTO=auto setting)
cfg.pin_sclk = 39; // Set SPI SCLK pin number
cfg.pin_mosi = 38; // Set SPI MOSI pin number
cfg.pin_miso = 40; // Set SPI MISO pin number (-1 = disable)
cfg.pin_dc = 42; // Set SPI DC pin number (-1 = disable)

_bus_instance.config(cfg); // applies the set value to the bus.
_panel_instance.setBus(&_bus_instance); // set the bus on the panel.
}

{ // Set the display panel control.
auto cfg = _panel_instance.config(); // Gets a structure for display panel settings.

cfg.pin_cs = 45; // Pin number where CS is connected (-1 = disable)
cfg.pin_rst = -1; // Pin number where RST is connected (-1 = disable)
cfg.pin_busy = -1; // Pin number where BUSY is connected (-1 = disable)

// The following setting values ​​are general initial values ​​for
// each panel, so please comment out any unknown items and try them.

cfg.panel_width = screenHeight; // actual displayable width
cfg.panel_height = screenWidth; // actual displayable height
cfg.offset_x = 0; // Panel offset amount in X direction
cfg.offset_y = 0; // Panel offset amount in Y direction
cfg.offset_rotation = 1; // Rotation direction value offset 0~7 (4~7 is upside down)
cfg.dummy_read_pixel = 16; // Number of bits for dummy read before pixel readout
cfg.dummy_read_bits = 1; // Number of bits for dummy read before non-pixel data read
cfg.readable = true; // Set to true if data can be read
cfg.invert = true; // Set to true if the light/darkness of the panel is reversed
cfg.rgb_order = false; // Set to true if the panel's red and blue are swapped
cfg.dlen_16bit = false; // Set to true for panels that transmit data length in 16-bit
// units with 16-bit parallel or SPI
cfg.bus_shared = true; // If the bus is shared with the SD card, set to
// true (bus control with drawJpgFile etc.)

// Set the following only when the display is shifted with a driver with a
// variable number of pixels, such as the ST7735 or ILI9163.
// cfg.memory_width = TFT_WIDTH; // Maximum width supported by the driver IC
// cfg.memory_height = TFT_HEIGHT; // Maximum height supported by the driver IC
_panel_instance.config(cfg);
}

// Set the backlight control.
{
auto cfg = _light_instance.config(); // Gets a structure for backlight settings.

cfg.pin_bl = 1; // Pin number to which the backlight is connected
cfg.invert = false; // true to invert the brightness of the backlight
cfg.freq = 44100;
cfg.pwm_channel = 7;

_light_instance.config(cfg);
_panel_instance.setLight(&_light_instance); // Set the backlight on the panel.
}

// Configure settings for touch screen control.
{
auto cfg = _touch_instance.config();

cfg.pin_cs = -1;
cfg.x_min = 0;
cfg.x_max = screenWidth - 1;
cfg.y_min = 0;
cfg.y_max = screenHeight - 1;
cfg.pin_int = 46;
cfg.bus_shared = true;
cfg.offset_rotation = 0;

// I2C
cfg.i2c_port = 1;
cfg.i2c_addr = 0x15;
cfg.pin_sda = 48;
cfg.pin_scl = 47;
cfg.freq = 400000;

_touch_instance.config(cfg);
_panel_instance.setTouch(&_touch_instance);
}

setPanel(&_panel_instance); // Sets the panel to use.
}
};
1 change: 1 addition & 0 deletions include/graphics/driver/DisplayDriverConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class DisplayDriverConfig
ELECROW_ADV,
HELTEC_TRACKER,
WT32_SC01_PLUS,
ESP32_S3_CAP_TOUCH,
ESP2432S028RV1,
ESP2432S028RV2,
ESP4848S040,
Expand Down
7 changes: 7 additions & 0 deletions source/graphics/driver/DisplayDriverFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@
#ifdef WT32_SC01
#include "graphics/LGFX/LGFX_WT_SC01PLUS.h"
#endif
#ifdef ESP32_S3_TOUCH
#include "graphics/LGFX/LGFX_ESP32_S3_TOUCH.h"
#endif
#ifdef HELTEC_TRACKER
#include "graphics/LGFX/LGFX_HELTEC_TRACKER.h"
#endif
Expand Down Expand Up @@ -169,6 +172,10 @@ DisplayDriver *DisplayDriverFactory::create(const DisplayDriverConfig &cfg)
case DisplayDriverConfig::device_t::WT32_SC01_PLUS:
return new LGFXDriver<LGFX_WT_SC01_PLUS>(cfg.width(), cfg.height());
break;
#elif defined(ESP32_S3_TOUCH)
case DisplayDriverConfig::device_t::ESP32_S3_CAP_TOUCH:
return new LGFXDriver<LGFX_ESP32_S3_TOUCH>(cfg.width(), cfg.height());
break;
#elif defined(ESP2432S028RV1)
case DisplayDriverConfig::device_t::ESP2432S028RV1:
return new LGFXDriver<LGFX_ESP2432S028RV1>(cfg.width(), cfg.height());
Expand Down