Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for 2424S012 (round display with ESP32-C3) #714

Merged
merged 3 commits into from
Apr 25, 2024
Merged
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
2 changes: 1 addition & 1 deletion src/drv/tft/M5Stack.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Original Source:
/----------------------------------------------------------------------------*/
#pragma once

#if defined(ARDUINO) && defined(LGFX_USE_V1)
#if defined(ARDUINO) && defined(LGFX_USE_V1) && !defined(CONFIG_IDF_TARGET_ESP32C3)

#include "Arduino.h"
#include "LovyanGFX.hpp"
Expand Down
1 change: 1 addition & 0 deletions src/drv/tft/tft_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ enum lv_hasp_obj_type_t {
TFT_PANEL_RM68140,
TFT_PANEL_RGB,
TFT_PANEL_EPD,
TFT_PANEL_GC9A01,
TFT_PANEL_LAST,
};

Expand Down
40 changes: 39 additions & 1 deletion src/drv/tft/tft_driver_lovyangfx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,12 @@ static lgfx::Bus_Parallel8* init_parallel_8_bus(Preferences* prefs, int8_t data_
cfg.pin_rd = prefs->getInt("rd", TFT_RD);
cfg.pin_wr = prefs->getInt("wr", TFT_WR);
cfg.pin_rs = prefs->getInt("rs", TFT_DC);
#ifndef CONFIG_IDF_TARGET_ESP32C3
cfg.freq_write = prefs->getUInt("write_freq", SPI_FREQUENCY);
#if !defined(CONFIG_IDF_TARGET_ESP32S3)
#endif


#if !defined(CONFIG_IDF_TARGET_ESP32S3) && !defined(CONFIG_IDF_TARGET_ESP32C3)
uint8_t port = prefs->getUInt("i2s_port", 0);
switch(port) {
#if SOC_I2S_NUM > 1
Expand Down Expand Up @@ -328,6 +332,11 @@ lgfx::Panel_Device* LovyanGfx::_init_panel(lgfx::IBus* bus)
LOG_VERBOSE(TAG_TFT, F("Panel_RGB"));
break;
}
case TFT_PANEL_GC9A01: {
panel = new lgfx::Panel_GC9A01();
LOG_VERBOSE(TAG_TFT, F("Panel_GC9A01"));
break;
}
default: { // Needs to be in curly braces
LOG_FATAL(TAG_TFT, F(D_SERVICE_START_FAILED ": %s line %d"), __FILE__, __LINE__);
}
Expand Down Expand Up @@ -455,6 +464,31 @@ lgfx::ITouch* _init_touch(Preferences* preferences)
}
#endif

#if TOUCH_DRIVER == 0x816
{
auto touch = new lgfx::Touch_CST816S();
auto cfg = touch->config();

cfg.x_min = 0;
cfg.x_max = TFT_WIDTH - 1;
cfg.y_min = 0;
cfg.y_max = TFT_HEIGHT - 1;
cfg.pin_int = TOUCH_IRQ;
cfg.bus_shared = true;
cfg.offset_rotation = TOUCH_OFFSET_ROTATION;

// I2C接続の場合
cfg.i2c_port = I2C_TOUCH_PORT;
cfg.i2c_addr = I2C_TOUCH_ADDRESS;
cfg.pin_sda = TOUCH_SDA;
cfg.pin_scl = TOUCH_SCL;
cfg.freq = I2C_TOUCH_FREQUENCY;

touch->config(cfg);
return touch;
}
#endif

#endif // HASP_USE_LGFX_TOUCH

return nullptr;
Expand Down Expand Up @@ -1261,6 +1295,8 @@ const char* LovyanGfx::get_tft_model()
return "R61529";
#elif defined(RM68140_DRIVER)
return "RM68140";
#elif defined(GC9A01_DRIVER)
return "GC9A01";
#else
return "Other";
#endif
Expand Down Expand Up @@ -1302,6 +1338,8 @@ uint32_t LovyanGfx::get_tft_driver()
return TFT_PANEL_EPD;
#elif defined(RGB_DRIVER)
return TFT_PANEL_RGB;
#elif defined(GC9A01_DRIVER)
return TFT_PANEL_GC9A01;
#else
return TFT_PANEL_UNKNOWN;
#endif
Expand Down
54 changes: 54 additions & 0 deletions user_setups/esp32/ttgo-t-watch.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
[ttgo-t-watch]

extends = arduino_esp32_v2
board = esp32dev

build_flags =
${arduino_esp32_v2.build_flags}
${esp32.ps_ram}

;region -- TFT_eSPI build options ------------------------
-D LGFX_USE_V1=1
-D HASP_USE_LGFX_TOUCH=1
-D ST7789_DRIVER=1
-D TFT_HEIGHT=240
-D TFT_WIDTH=240
-D TFT_DC=27
-D TFT_CS=5
-D TFT_MOSI=19
-D TFT_RST=-1
-D TFT_SCLK=18
-D TFT_BCKL=12
-D SPI_FREQUENCY=40000000
-D I2C_TOUCH_ADDRESS=0x38
-D I2C_TOUCH_FREQUENCY=400000
-D TOUCH_DRIVER=0x6336
-D I2C_TOUCH_PORT=1
-D TOUCH_IRQ=38
-D TOUCH_RST=-1
-D TOUCH_SDA=23
-D TOUCH_SCL=32
;endregion

lib_deps =
${arduino_esp32_v2.lib_deps}
${lovyangfx.lib_deps}
${ft6336.lib_deps}

[env:ttgo-t-watch-2019]
extends = ttgo-t-watch, flash_16mb

build_flags =
${ttgo-t-watch.build_flags}
-D HASP_MODEL="TTgo T-Watch 2019"
-D INVERT_COLORS=1

[env:ttgo-t-watch-2020]
extends = ttgo-t-watch, flash_16mb

build_flags =
${ttgo-t-watch.build_flags}
-D HASP_MODEL="TTgo T-Watch 2020"
-D TFT_ROTATION=0
;-D TFT_ROTATION=2
-D TOUCH_OFFSET_ROTATION=4 ; 1=swap xy, 2=invert x, 4=inverty
35 changes: 35 additions & 0 deletions user_setups/esp32c3/2424S012.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[env:2424S012]
extends = arduino_esp32c3_v2, flash_4mb
; Close enough, sets it up to use USB-CDC rather than uart
board = seeed_xiao_esp32c3

build_flags =
-D HASP_MODEL="ESP32-2424S012"
${arduino_esp32c3_v2.build_flags}
${esp32c3.no_ps_ram}

; Display configuration
-D LGFX_USE_V1=1
-D HASP_USE_LGFX_TOUCH=1
;CST816S driver
-D TOUCH_DRIVER=0x816
-D GC9A01_DRIVER=1
-D TFT_WIDTH=240
-D TFT_HEIGHT=240
-D TOUCH_SDA=4
-D TOUCH_SCL=5
-D TOUCH_IRQ=0
-D TOUCH_RST=1
-D I2C_TOUCH_FREQUENCY=400000
-D I2C_TOUCH_PORT=0
-D I2C_TOUCH_ADDRESS=0x15
-D TFT_SCLK=6
-D TFT_MOSI=7
-D TFT_DC=2
-D TFT_CS=10
-D TFT_BCKL=3
-D SERIAL_SPEED=-1 ;otherwise requires serial term to boot first time

lib_deps =
${arduino_esp32s3_v2.lib_deps}
${lovyangfx.lib_deps}