Skip to content

Commit

Permalink
Merge pull request #403 from urobot2011/#402
Browse files Browse the repository at this point in the history
Added t-display-s3-touch support
  • Loading branch information
sharandac authored Sep 14, 2023
2 parents 769d791 + 2b10ccf commit e0e5725
Show file tree
Hide file tree
Showing 27 changed files with 532 additions and 13 deletions.
45 changes: 45 additions & 0 deletions boards/lilygo-t-displays3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"build": {
"arduino": {
"ldscript": "esp32s3_out.ld",
"memory_type": "qio_opi",
"partitions": "default_16MB.csv"
},
"core": "esp32",
"extra_flags": [
"-DBOARD_HAS_PSRAM"
],
"f_cpu": "240000000L",
"f_flash": "80000000L",
"flash_mode": "qio",
"hwids": [
[
"0X303A",
"0x1001"
]
],
"mcu": "esp32s3",
"variant": "esp32s3"
},
"connectivity": [
"wifi",
"bluetooth"
],
"debug": {
"openocd_target": "esp32s3.cfg"
},
"frameworks": [
"arduino",
"espidf"
],
"name": "T-DisplayS3",
"upload": {
"flash_size": "16MB",
"maximum_ram_size": 327680,
"maximum_size": 16777216,
"require_upload_port": true,
"speed": 921600
},
"url": "https://www.lilygo.cc/products/t-display-s3",
"vendor": "LILYGO"
}
93 changes: 92 additions & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ build_src_filter =
+<*>
+<../hal/sdl2>

[env:emulator_tdisplay_s3_touch]
[env:emulator_t_display_s3_touch]
platform = native@^1.1.3
extra_scripts = support/sdl2_build_extra.py
build_type = release
Expand Down Expand Up @@ -563,6 +563,97 @@ lib_deps =
mikalhart/TinyGPSPlus
h2zero/NimBLE-Arduino @ ^1.3.8

[env:t_display_s3_touch]
; overrides the default arduino-esp32 framework with an custom built arduino-esp32 framework
; the custom arduino-esp32 framework provides better power managment, dynamic frquency scaling and 80Mhz Flash/SPIRAM support
; built from https://github.com/Jason2866/esp32-arduino-lib-builder
platform_packages = espressif32;framework-arduinoespressif32 @ https://github.com/sharandac/arduino-esp32-hedge-ng
platform = [email protected]
board = lilygo-t-displays3
framework = arduino
lib_archive = true
board_build.f_flash = 80000000L
board_build.flash_mode = qio
monitor_speed = 115200
monitor_filters =
default
esp32_exception_decoder
board_build.partitions = default_16MB.csv
board_build.embed_txtfiles =
src/gui/mainbar/setup_tile/time_settings/timezones.json
src/utils/osm_map/osmtileserver.json
build_type = release
build_flags =
-D BOARD_HAS_PSRAM
-mfix-esp32-psram-cache-issue
-DARDUNIO_NG
-D ESP32_S3
-DUSER_SETUP_LOADED=1
-DST7789_DRIVER=1
; -DINIT_SEQUENCE_3=1 ; Using this initialisation sequence improves the display image
-DCGRAM_OFFSET=1
-DTFT_RGB_ORDER=TFT_BGR ; Colour order Blue-Green-Red
-DTFT_INVERSION_ON=1
-DTFT_PARALLEL_8_BIT=1
-DTFT_WIDTH=170
-DTFT_HEIGHT=320
-DTFT_CS=6
-DTFT_DC=7
-DTFT_RST=5
-DTFT_WR=8
-DTFT_RD=9
-DTFT_D0=39
-DTFT_D1=40
-DTFT_D2=41
-DTFT_D3=42
-DTFT_D4=45
-DTFT_D5=46
-DTFT_D6=47
-DTFT_D7=48
-DTFT_LED=38
-DTFT_BACKLIGHT_ON=1
-DSPI_FREQUENCY=80000000
-DPIN_IIC_SCL=17
-DPIN_IIC_SDA=18
-DPIN_TOUCH_INT=16
-DPIN_TOUCH_RES=21
-D BAT_ADC=4
-D T_DISPLAY_S3_TOUCH
; -D LV_LVGL_H_INCLUDE_SIMPLE
-D ARDUINO_USB_CDC_ON_BOOT=1
-D DISABLE_ALL_LIBRARY_WARNINGS
-D ARDUINO_USB_MODE=1

; Choose different options according to different driver chips
; Early use of CST328
; -D TOUCH_MODULES_CST_MUTUAL
; Use CST816 by default
-D TOUCH_MODULES_CST_SELF

-D LV_LVGL_H_INCLUDE_SIMPLE=1

-D CORE_DEBUG_LEVEL=3
-D SERIAL_RX_BUFFER_SIZE=256
-ffunction-sections
-fdata-sections
-Wl,--gc-sections
-Os
build_src_filter =
+<*>
lib_deps =
https://github.com/lvgl/lvgl.git#v7.11.0
ESP Async WebServer@>=1.2.0
AsyncTCP@>=1.1.1
ArduinoJson@>=6.15.2
luc-github/ESP32SSDP
PubSubClient@>=2.8
nailbuster/ESP8266FtpServer
https://github.com/tobozo/ESP32-targz/archive/refs/heads/1.0.5-beta.zip
Bodmer/TFT_eSPI
https://github.com/mmMicky/TouchLib.git
mikalhart/TinyGPSPlus
h2zero/NimBLE-Arduino @ ^1.3.8

[env:t-watch2020-v1]
; overrides the default arduino-esp32 framework with an custom built arduino-esp32 framework
; the custom arduino-esp32 framework provides better power managment, dynamic frquency scaling and 80Mhz Flash/SPIRAM support
Expand Down
4 changes: 2 additions & 2 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
#define RES_X_MAX 320
#define RES_Y_MAX 170
#define USE_PSRAM_ALLOC_LVGL /** @brief enabled LVGL to use PSRAM */
#define ENABLE_WEBSERVER /** @brief To disable built-in webserver, comment this line */
#define ENABLE_FTPSERVER /** @brief To disable built-in ftpserver, comment this line */
//#define ENABLE_WEBSERVER /** @brief To disable built-in webserver, comment this line */
//#define ENABLE_FTPSERVER /** @brief To disable built-in ftpserver, comment this line */
#elif defined( LILYGO_WATCH_2021 )
#define HARDWARE_NAME "T-Watch2021"
#define RES_X_MAX 240
Expand Down
4 changes: 2 additions & 2 deletions src/gui/mainbar/app_tile/app_tile.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
#define APP_ICON_Y_OFFSET 0
#define MAX_APPS_TILES 4
#elif defined( T_DISPLAY_S3_TOUCH )
#define MAX_APPS_ICON_HORZ 2
#define MAX_APPS_ICON_VERT 2
#define MAX_APPS_ICON_HORZ 4
#define MAX_APPS_ICON_VERT 1
#define APP_ICON_X_CLEARENCE 8
#define APP_ICON_Y_CLEARENCE 54
#define APP_ICON_X_OFFSET 0
Expand Down
4 changes: 2 additions & 2 deletions src/gui/mainbar/setup_tile/setup_tile.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
#define SETUP_ICON_Y_OFFSET 0
#define MAX_SETUP_TILES 4
#elif defined( T_DISPLAY_S3_TOUCH )
#define MAX_SETUP_ICON_HORZ 2
#define MAX_SETUP_ICON_VERT 2
#define MAX_SETUP_ICON_HORZ 4
#define MAX_SETUP_ICON_VERT 1
#define SETUP_ICON_X_CLEARENCE 8
#define SETUP_ICON_Y_CLEARENCE 54
#define SETUP_ICON_X_OFFSET 0
Expand Down
1 change: 1 addition & 0 deletions src/gui/splashscreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#elif defined( LILYGO_WATCH_2020_V1 ) || defined( LILYGO_WATCH_2020_V2 ) || defined( LILYGO_WATCH_2020_V3 )
#elif defined( LILYGO_WATCH_2021 )
#elif defined( WT32_SC01 )
#elif defined( T_DISPLAY_S3_TOUCH )
#else
#error "not splashscreen pre hardware setup"
#endif
Expand Down
1 change: 1 addition & 0 deletions src/hardware/ble/blebatctl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#elif defined( M5CORE2 )
#elif defined( LILYGO_WATCH_2020_V1 ) || defined( LILYGO_WATCH_2020_V2 ) || defined( LILYGO_WATCH_2020_V3 )
#elif defined( WT32_SC01 )
#elif defined( T_DISPLAY_S3_TOUCH )
#else
#warning "no hardware driver for blebatctl"
#endif
Expand Down
1 change: 1 addition & 0 deletions src/hardware/ble/blestepctl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#elif defined( M5CORE2 )
#elif defined( LILYGO_WATCH_2020_V1 ) || defined( LILYGO_WATCH_2020_V2 ) || defined( LILYGO_WATCH_2020_V3 )
#elif defined( WT32_SC01 )
#elif defined( T_DISPLAY_S3_TOUCH )
#else
#warning "no hardware driver for blestepctl"
#endif
Expand Down
1 change: 1 addition & 0 deletions src/hardware/ble/bleupdater.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#if defined( M5PAPER )
#elif defined( LILYGO_WATCH_2020_V1 ) || defined( LILYGO_WATCH_2020_V2 ) || defined( LILYGO_WATCH_2020_V3 )
#elif defined( WT32_SC01 )
#elif defined( T_DISPLAY_S3_TOUCH )
#else
#endif
#endif
Expand Down
1 change: 1 addition & 0 deletions src/hardware/ble/gadgetbridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#elif defined( LILYGO_WATCH_2020_V1 ) || defined( LILYGO_WATCH_2020_V2 ) || defined( LILYGO_WATCH_2020_V3 )
#elif defined( LILYGO_WATCH_2021 )
#elif defined( WT32_SC01 )
#elif defined( T_DISPLAY_S3_TOUCH )
#else
#warning "no hardware driver for blegadgetbridge"
#endif
Expand Down
2 changes: 2 additions & 0 deletions src/hardware/blectl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#elif defined( LILYGO_WATCH_2020_V1 ) || defined( LILYGO_WATCH_2020_V2 ) || defined( LILYGO_WATCH_2020_V3 )
#elif defined( LILYGO_WATCH_2021 )
#elif defined( WT32_SC01 )
#elif defined( T_DISPLAY_S3_TOUCH )
#else
#warning "no hardware driver for blectl"
#endif
Expand Down Expand Up @@ -517,6 +518,7 @@ void blectl_off( void ) {
#ifdef M5PAPER
#elif defined( LILYGO_WATCH_2020_V1 ) || defined( LILYGO_WATCH_2020_V2 ) || defined( LILYGO_WATCH_2020_V3 )
#elif defined( WT32_SC01 )
#elif defined( T_DISPLAY_S3_TOUCH )
#endif
NimBLEServer *blectl_get_ble_server( void ) {
return pServer;
Expand Down
98 changes: 96 additions & 2 deletions src/hardware/button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ bool button_send_cb( EventBits_t event, void *arg );
#elif defined( LILYGO_WATCH_2021 )
#include <twatch2021_config.h>
#elif defined( WT32_SC01 )
#elif defined( T_DISPLAY_S3_TOUCH )
#define BTN_1 0
#define BTN_2 14
#else
#warning "no hardware driver for button"
#endif
Expand Down Expand Up @@ -109,7 +112,9 @@ void button_setup( void ) {
pinMode( BTN_2, INPUT );
pinMode( BTN_3, INPUT );
#elif defined( WT32_SC01 )

#elif defined( T_DISPLAY_S3_TOUCH )
pinMode( BTN_1, INPUT );
pinMode( BTN_2, INPUT );
#endif
#endif
/*
Expand Down Expand Up @@ -399,6 +404,71 @@ bool button_powermgm_loop_cb( EventBits_t event, void *arg ) {
if ( refresh_button ) button_send_cb( BUTTON_REFRESH, (void*)NULL );
}
#elif defined( WT32_SC01 )
#elif defined( T_DISPLAY_S3_TOUCH )
static bool exit_button = digitalRead( BTN_1 );
static bool setup_button = digitalRead( BTN_2 );
static uint64_t exit_button_time = 0;
static uint64_t setup_button_time = 0;
/**
* BTN_1 logic
*/
if ( digitalRead( BTN_1 ) != exit_button ) {
exit_button = digitalRead( BTN_1 );

uint64_t press_time = 0;
if ( !exit_button ) {
exit_button_time = millis();
}
else {
press_time = millis() - exit_button_time;
}

if ( press_time != 0 ) {
/**
* special case when we are in standby or silence wakeup
*/
if ( powermgm_get_event( POWERMGM_STANDBY ) || powermgm_get_event( POWERMGM_SILENCE_WAKEUP ) ){
button_send_cb( BUTTON_PWR, (void *)NULL );
powermgm_set_event( POWERMGM_WAKEUP_REQUEST );
}
else {
if( press_time < 250 )
button_send_cb( BUTTON_EXIT, (void *)NULL );
else if ( press_time < 1000 )
button_send_cb( BUTTON_PWR, (void *)NULL );
else
button_send_cb( BUTTON_QUICKBAR, (void *)NULL );
}
}
}
/**
* BTN_2 logic
*/
if ( digitalRead( BTN_2 ) != setup_button ) {
setup_button = digitalRead( BTN_2 );

uint64_t press_time = 0;
if ( setup_button )
setup_button_time = millis();
else
press_time = millis() - setup_button_time;

if ( press_time != 0 ) {
/**
* special case when we are in standby or silence wakeup
*/
if ( powermgm_get_event( POWERMGM_STANDBY ) || powermgm_get_event( POWERMGM_SILENCE_WAKEUP ) ){
button_send_cb( BUTTON_PWR, (void *)NULL );
powermgm_set_event( POWERMGM_WAKEUP_REQUEST );
}
else {
if ( press_time < 250 )
button_send_cb( BUTTON_DOWN, (void*)NULL );
else
button_send_cb( BUTTON_SETUP, (void *)NULL );
}
}
}
#endif
/**
* prevent "warning: variable 'temp_button_irq_flag' set but not used" in some platform conditions
Expand Down Expand Up @@ -481,6 +551,30 @@ bool button_powermgm_event_cb( EventBits_t event, void *arg ) {
}
#elif defined( WT32_SC01 )
retval = true;
#elif defined( T_DISPLAY_S3_TOUCH )
switch( event ) {
case POWERMGM_STANDBY: log_d("button standby");
/*
* enable GPIO in lightsleep for wakeup
*/
gpio_wakeup_enable( (gpio_num_t)BTN_1, GPIO_INTR_LOW_LEVEL );
gpio_wakeup_enable( (gpio_num_t)BTN_2, GPIO_INTR_LOW_LEVEL );
esp_sleep_enable_gpio_wakeup ();
retval = true;
break;
case POWERMGM_WAKEUP: log_d("button wakeup");
retval = true;
break;
case POWERMGM_SILENCE_WAKEUP: log_d("button silence wakeup");
retval = true;
break;
case POWERMGM_ENABLE_INTERRUPTS: log_d("button enable interrupts");
retval = true;
break;
case POWERMGM_DISABLE_INTERRUPTS: log_d("button disable interrupts");
retval = true;
break;
}
#endif
#endif

Expand Down Expand Up @@ -510,4 +604,4 @@ bool button_send_cb( EventBits_t event, void *arg ) {
* call all callbacks with her event mask
*/
return( callback_send( button_callback, event, arg ) );
}
}
Loading

0 comments on commit e0e5725

Please sign in to comment.