From 8c292393b713975c9d47754191c12ddb4b387e9c Mon Sep 17 00:00:00 2001 From: esp32-urobot Date: Thu, 14 Sep 2023 17:13:47 +0900 Subject: [PATCH 1/3] Added t-display-s3-touch support by sharandac/My-TTGO-Watch#402 --- boards/lilygo-t-displays3.json | 45 +++++++++++ platformio.ini | 95 +++++++++++++++++++++- src/config.h | 4 +- src/gui/mainbar/app_tile/app_tile.h | 4 +- src/gui/mainbar/setup_tile/setup_tile.h | 4 +- src/gui/splashscreen.cpp | 1 + src/hardware/ble/blebatctl.cpp | 1 + src/hardware/ble/blestepctl.cpp | 1 + src/hardware/ble/bleupdater.h | 1 + src/hardware/ble/gadgetbridge.cpp | 1 + src/hardware/blectl.cpp | 2 + src/hardware/button.cpp | 100 ++++++++++++++++++++++-- src/hardware/compass.cpp | 8 ++ src/hardware/config/touchconfig.h | 3 + src/hardware/display.cpp | 52 ++++++++++++ src/hardware/framebuffer.cpp | 24 ++++++ src/hardware/framebuffer.h | 3 + src/hardware/hardware.cpp | 22 ++++++ src/hardware/motion.cpp | 24 ++++++ src/hardware/motor.cpp | 5 ++ src/hardware/pmu.cpp | 36 +++++++++ src/hardware/powermgm.cpp | 8 +- src/hardware/rtcctl.cpp | 22 +++++- src/hardware/sdcard.cpp | 4 + src/hardware/sensor.cpp | 11 +++ src/hardware/sound.cpp | 1 + src/hardware/touch.cpp | 67 ++++++++++++++++ 27 files changed, 532 insertions(+), 17 deletions(-) create mode 100644 boards/lilygo-t-displays3.json diff --git a/boards/lilygo-t-displays3.json b/boards/lilygo-t-displays3.json new file mode 100644 index 00000000..9e79b9d0 --- /dev/null +++ b/boards/lilygo-t-displays3.json @@ -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" +} \ No newline at end of file diff --git a/platformio.ini b/platformio.ini index a71ea730..2a14b2bb 100644 --- a/platformio.ini +++ b/platformio.ini @@ -9,7 +9,7 @@ ; http://docs.platformio.org/page/projectconf.html [platformio] -default_envs = t-watch2020-v1 +default_envs = t-watch2021-v1 [env:emulator_m5paper] platform = native@^1.1.3 @@ -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 @@ -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 = espressif32@6.4.0 +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 diff --git a/src/config.h b/src/config.h index bfaf6b49..37c66068 100644 --- a/src/config.h +++ b/src/config.h @@ -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 diff --git a/src/gui/mainbar/app_tile/app_tile.h b/src/gui/mainbar/app_tile/app_tile.h index bb2defeb..ded70609 100644 --- a/src/gui/mainbar/app_tile/app_tile.h +++ b/src/gui/mainbar/app_tile/app_tile.h @@ -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 diff --git a/src/gui/mainbar/setup_tile/setup_tile.h b/src/gui/mainbar/setup_tile/setup_tile.h index 7e642ec9..f6161b8b 100644 --- a/src/gui/mainbar/setup_tile/setup_tile.h +++ b/src/gui/mainbar/setup_tile/setup_tile.h @@ -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 diff --git a/src/gui/splashscreen.cpp b/src/gui/splashscreen.cpp index 2d898db1..640d2349 100644 --- a/src/gui/splashscreen.cpp +++ b/src/gui/splashscreen.cpp @@ -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 diff --git a/src/hardware/ble/blebatctl.cpp b/src/hardware/ble/blebatctl.cpp index e64bf53a..50cfa4d8 100644 --- a/src/hardware/ble/blebatctl.cpp +++ b/src/hardware/ble/blebatctl.cpp @@ -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 diff --git a/src/hardware/ble/blestepctl.cpp b/src/hardware/ble/blestepctl.cpp index a94eabcc..115b15a6 100644 --- a/src/hardware/ble/blestepctl.cpp +++ b/src/hardware/ble/blestepctl.cpp @@ -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 diff --git a/src/hardware/ble/bleupdater.h b/src/hardware/ble/bleupdater.h index 9821fc07..01935338 100644 --- a/src/hardware/ble/bleupdater.h +++ b/src/hardware/ble/bleupdater.h @@ -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 diff --git a/src/hardware/ble/gadgetbridge.cpp b/src/hardware/ble/gadgetbridge.cpp index 52e051a0..aefa618e 100644 --- a/src/hardware/ble/gadgetbridge.cpp +++ b/src/hardware/ble/gadgetbridge.cpp @@ -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 diff --git a/src/hardware/blectl.cpp b/src/hardware/blectl.cpp index cb997e6a..68697c48 100644 --- a/src/hardware/blectl.cpp +++ b/src/hardware/blectl.cpp @@ -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 @@ -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; diff --git a/src/hardware/button.cpp b/src/hardware/button.cpp index d2461b8f..e99196df 100644 --- a/src/hardware/button.cpp +++ b/src/hardware/button.cpp @@ -64,6 +64,9 @@ bool button_send_cb( EventBits_t event, void *arg ); #elif defined( LILYGO_WATCH_2021 ) #include #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 @@ -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 /* @@ -399,11 +404,72 @@ 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 - */ - temp_button_irq_flag = ~temp_button_irq_flag; #endif return( true ); } @@ -481,6 +547,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 diff --git a/src/hardware/compass.cpp b/src/hardware/compass.cpp index 2bb56d6b..813a5733 100644 --- a/src/hardware/compass.cpp +++ b/src/hardware/compass.cpp @@ -39,6 +39,7 @@ #include QMC5883LCompass compass; #elif defined( WT32_SC01 ) + #elif defined( T_DISPLAY_S3_TOUCH ) #else #warning "no hardware driver for compass" #endif @@ -68,6 +69,7 @@ void compass_setup( void ) { compass.init(); compass_off(); #elif defined( WT32_SC01 ) + #elif defined( T_DISPLAY_S3_TOUCH ) #else #endif #endif @@ -98,6 +100,7 @@ static bool compass_powermgm_event_cb( EventBits_t event, void *arg ) { break; } #elif defined( WT32_SC01 ) + #elif defined( T_DISPLAY_S3_TOUCH ) #else #endif #endif @@ -122,6 +125,7 @@ static bool compass_powermgm_loop_event_cb( EventBits_t event, void *arg ) { #elif defined( LILYGO_WATCH_2021 ) compass.setCalibration( calibrationData[0][0], calibrationData[0][1], calibrationData[1][0], calibrationData[1][1], calibrationData[2][0], calibrationData[2][1] ); #elif defined( WT32_SC01 ) + #elif defined( T_DISPLAY_S3_TOUCH ) #endif #endif compass_calibrated = true; @@ -172,6 +176,7 @@ static bool compass_get_data( compass_data_t *compass_data ) { compass_data->direction[3] = '\0'; log_d("x=%d, y=%d, z=%d, azimuth=%d, bearing=%d, direction=%s", compass_data->x, compass_data->y, compass_data->z, compass_data->azimuth, compass_data->bearing, compass_data->direction ); #elif defined( WT32_SC01 ) + #elif defined( T_DISPLAY_S3_TOUCH ) #else #endif #endif @@ -246,6 +251,7 @@ void compass_on( void ) { if( compass_calibrated ) compass.setCalibration( calibrationData[0][0], calibrationData[0][1], calibrationData[1][0], calibrationData[1][1], calibrationData[2][0], calibrationData[2][1] ); #elif defined( WT32_SC01 ) + #elif defined( T_DISPLAY_S3_TOUCH ) #else #endif #endif @@ -264,6 +270,7 @@ void compass_off( void ) { compass.setReset(); compass.setMode( 0x00, 0x0C, 0x10, 0x00 ); #elif defined( WT32_SC01 ) + #elif defined( T_DISPLAY_S3_TOUCH ) #else #endif #endif @@ -306,6 +313,7 @@ bool compass_available( void ) { #elif defined( LILYGO_WATCH_2021 ) retval = true; #elif defined( WT32_SC01 ) + #elif defined( T_DISPLAY_S3_TOUCH ) #else #endif #endif diff --git a/src/hardware/config/touchconfig.h b/src/hardware/config/touchconfig.h index fdb06229..32069b58 100644 --- a/src/hardware/config/touchconfig.h +++ b/src/hardware/config/touchconfig.h @@ -45,6 +45,9 @@ #elif defined( WT32_SC01 ) #define TOUCH_X_SCALE 1.0 #define TOUCH_Y_SCALE 1.0 + #elif defined( T_DISPLAY_S3_TOUCH ) + #define TOUCH_X_SCALE 1.0 + #define TOUCH_Y_SCALE 1.0 #else #define TOUCH_X_SCALE 1.0 #define TOUCH_Y_SCALE 1.0 diff --git a/src/hardware/display.cpp b/src/hardware/display.cpp index 93700822..f796d11a 100644 --- a/src/hardware/display.cpp +++ b/src/hardware/display.cpp @@ -38,6 +38,7 @@ #elif defined( LILYGO_WATCH_2021 ) #include #elif defined( WT32_SC01 ) + #elif defined( T_DISPLAY_S3_TOUCH ) #else #error "no hardware driver for display, please setup minimal drivers ( display/framebuffer/touch )" #endif @@ -86,6 +87,19 @@ void display_setup( void ) { ledcSetup(0, 4000, 8); ledcAttachPin(TFT_LED, 0); ledcWrite(0, 0x0 ); + #elif defined( T_DISPLAY_S3_TOUCH ) + pinMode(TFT_LED, OUTPUT); + ledcSetup(0, 4000, 8); + ledcAttachPin(TFT_LED, 0); + ledcWrite(0, 0x0 ); + + // Lighten the screen with gradient + ledcSetup(0, 10000, 8); + ledcAttachPin(TFT_LED, 0); + for (uint8_t i = 0; i < 0xFF; i++) { + ledcWrite(0, i); + delay(2); + } #else #error "no display init function implemented, please setup minimal drivers ( display/framebuffer/touch )" #endif @@ -226,6 +240,33 @@ static bool display_powermgm_loop_cb( EventBits_t event, void *arg ) { } } + retval = true; + #elif defined( T_DISPLAY_S3_TOUCH ) + /** + * check if backlight adjust has change + */ + if ( dest_brightness != brightness ) { + if ( brightness < dest_brightness ) { + brightness++; + ledcWrite(0, brightness ); + } + else { + brightness--; + ledcWrite(0, brightness ); + } + } + /** + * check timeout + */ + if ( display_get_timeout() != DISPLAY_MAX_TIMEOUT ) { + if ( lv_disp_get_inactive_time(NULL) > ( ( display_get_timeout() * 1000 ) - display_get_brightness() * 8 ) ) { + dest_brightness = ( ( display_get_timeout() * 1000 ) - lv_disp_get_inactive_time( NULL ) ) / 8 ; + } + else { + dest_brightness = display_get_brightness(); + } + } + retval = true; #else #error "no display init function implemented, please setup minimal drivers ( display/framebuffer/touch )" @@ -274,6 +315,8 @@ static void display_standby( void ) { ledcWrite( 0, 0 ); #elif defined( WT32_SC01 ) ledcWrite( 0, 0 ); + #elif defined( T_DISPLAY_S3_TOUCH ) + ledcWrite( 0, 0 ); #else #error "no display statndby function implemented, please setup minimal drivers ( display/framebuffer/touch )" #endif @@ -316,6 +359,10 @@ static void display_wakeup( bool silence ) { ledcWrite( 0, 0 ); brightness = 0; dest_brightness = 0; + #elif defined( T_DISPLAY_S3_TOUCH ) + ledcWrite( 0, 0 ); + brightness = 0; + dest_brightness = 0; #else #error "no silence display wakeup function implemented, please setup minimal drivers ( display/framebuffer/touch )" #endif @@ -353,6 +400,10 @@ static void display_wakeup( bool silence ) { ledcWrite( 0, 0 ); brightness = 0; dest_brightness = display_get_brightness(); + #elif defined( T_DISPLAY_S3_TOUCH ) + ledcWrite( 0, 0 ); + brightness = 0; + dest_brightness = display_get_brightness(); #else #error "no display wakeup function implemented, please setup minimal drivers ( display/framebuffer/touch )" #endif @@ -433,6 +484,7 @@ void display_set_rotation( uint32_t rotation ) { display_config.rotation = rotation; ttgo->tft->setRotation( rotation / 90 ); #elif defined( WT32_SC01 ) + #elif defined( T_DISPLAY_S3_TOUCH ) #else #warning "no display set rotation function implemented, please setup minimal drivers ( display/framebuffer/touch )" #endif diff --git a/src/hardware/framebuffer.cpp b/src/hardware/framebuffer.cpp index 80dc4007..b866a30d 100644 --- a/src/hardware/framebuffer.cpp +++ b/src/hardware/framebuffer.cpp @@ -59,6 +59,10 @@ #elif defined( WT32_SC01 ) #include "TFT_eSPI.h" + TFT_eSPI tft = TFT_eSPI(); + #elif defined( T_DISPLAY_S3_TOUCH ) + #include "TFT_eSPI.h" + TFT_eSPI tft = TFT_eSPI(); #else #error "no hardware driver for framebuffer, please setup minimal drivers ( display/framebuffer/touch )" @@ -136,6 +140,14 @@ void framebuffer_setup( void ) { tft.initDMA(); tft.setRotation( 1 ); ledcWrite(0, 0xff ); + #elif defined( T_DISPLAY_S3_TOUCH ) + framebuffer_use_dma = false; + tft.init(); + tft.setSwapBytes( true ); + tft.fillScreen( TFT_BLACK ); + //tft.initDMA(); + tft.setRotation( 1 ); + ledcWrite(0, 0xff ); #else #error "no framebuffer init function implemented, please setup minimal drivers ( display/framebuffer/touch )" #endif @@ -249,6 +261,7 @@ bool framebuffer_powermgm_loop_cb( EventBits_t event, void *arg ) { #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 "no framebuffer powermgm loop event function implemented, please setup minimal drivers ( display/framebuffer/touch )" #endif @@ -275,6 +288,7 @@ void framebuffer_refresh( void ) { #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 "no framebuffer refresh function implemented, please setup minimal drivers ( display/framebuffer/touch )" #endif @@ -422,6 +436,16 @@ static void framebuffer_flush_cb(lv_disp_drv_t *disp_drv, const lv_area_t *area, tft.flush(); tft.endWrite(); } + #elif defined( T_DISPLAY_S3_TOUCH ) + /** + * get buffer size + */ + uint32_t size = (area->x2 - area->x1 + 1) * (area->y2 - area->y1 + 1) ; + + tft.startWrite(); + tft.pushImage( area->x1, area->y1, (area->x2 - area->x1 + 1), (area->y2 - area->y1 + 1), ( uint16_t *)color_p ); + tft.flush(); + tft.endWrite(); #else #error "no LVGL display driver function implemented, please setup minimal drivers ( display/framebuffer/touch )" #endif diff --git a/src/hardware/framebuffer.h b/src/hardware/framebuffer.h index 022fb112..ec424eef 100644 --- a/src/hardware/framebuffer.h +++ b/src/hardware/framebuffer.h @@ -45,6 +45,9 @@ #elif defined( WT32_SC01 ) #define FRAMEBUFFER_BUFFER_W RES_X_MAX #define FRAMEBUFFER_BUFFER_H 40 + #elif defined( T_DISPLAY_S3_TOUCH ) + #define FRAMEBUFFER_BUFFER_W RES_X_MAX + #define FRAMEBUFFER_BUFFER_H 10 #endif #endif diff --git a/src/hardware/hardware.cpp b/src/hardware/hardware.cpp index ac652f83..39212a70 100644 --- a/src/hardware/hardware.cpp +++ b/src/hardware/hardware.cpp @@ -68,6 +68,8 @@ #include #elif defined( WT32_SC01 ) #include + #elif defined( T_DISPLAY_S3_TOUCH ) + #include #else #error "no hardware init" #endif @@ -82,6 +84,7 @@ void hardware_attach_lvgl_ticker( void ) { #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 ) #endif tickTicker->attach_ms( 5, []() { lv_tick_inc(5); @@ -96,6 +99,7 @@ void hardware_attach_lvgl_ticker_slow( void ) { #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 ) #endif tickTicker->attach_ms(250, []() { lv_tick_inc(250); @@ -110,6 +114,7 @@ void hardware_detach_lvgl_ticker( void ) { #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 ) #endif tickTicker->detach(); #endif @@ -214,6 +219,23 @@ void hardware_setup( void ) { if ( Wire.endTransmission() == 0 ) log_i("I2C device at: 0x%02x", address ); } + #elif defined( T_DISPLAY_S3_TOUCH ) + /** + * lvgl init + */ + lv_init(); + /** + * setup wire interface + */ + Wire.begin( PIN_IIC_SDA, PIN_IIC_SCL ); + /** + * scan i2c devices + */ + for( uint8_t address = 1; address < 127; address++ ) { + Wire.beginTransmission(address); + if ( Wire.endTransmission() == 0 ) + log_i("I2C device at: 0x%02x", address ); + } #endif /** * init lvgl ticker diff --git a/src/hardware/motion.cpp b/src/hardware/motion.cpp index 7f4f439b..fefe1ee4 100644 --- a/src/hardware/motion.cpp +++ b/src/hardware/motion.cpp @@ -68,6 +68,7 @@ return (0 != Wire.endTransmission()); } #elif defined( WT32_SC01 ) + #elif defined( T_DISPLAY_S3_TOUCH ) #else #warning "no hardware driver for bma/axis sensor" @@ -145,6 +146,10 @@ void bma_setup( void ) { stepcounter = 0; stepcounter_before_reset = 0; stepcounter_valid = 0xa5a5a5a5; + #elif defined( T_DISPLAY_S3_TOUCH ) + stepcounter = 0; + stepcounter_before_reset = 0; + stepcounter_valid = 0xa5a5a5a5; #endif #endif /* @@ -217,6 +222,7 @@ void bma_setup( void ) { bma.enableTiltInterrupt(); bma.enableWakeupInterrupt(); #elif defined( WT32_SC01 ) + #elif defined( T_DISPLAY_S3_TOUCH ) #endif #endif @@ -258,6 +264,8 @@ bool bma_powermgm_event_cb( EventBits_t event, void *arg ) { break; #elif defined( WT32_SC01 ) + #elif defined( T_DISPLAY_S3_TOUCH ) + #endif #endif } @@ -329,6 +337,8 @@ bool bma_powermgm_loop_cb( EventBits_t event , void *arg ) { } #elif defined( WT32_SC01 ) + #elif defined( T_DISPLAY_S3_TOUCH ) + #endif #endif } @@ -382,6 +392,8 @@ void bma_notify_stepcounter( void ) { stepcounter_before_reset = bma.getCounter(); #elif defined( WT32_SC01 ) + #elif defined( T_DISPLAY_S3_TOUCH ) + #endif #endif val = stepcounter + stepcounter_before_reset; @@ -405,6 +417,8 @@ void bma_standby( void ) { bma.enableStepCountInterrupt( false ); #elif defined( WT32_SC01 ) + #elif defined( T_DISPLAY_S3_TOUCH ) + #endif #endif } @@ -422,6 +436,8 @@ void bma_standby( void ) { esp_sleep_enable_gpio_wakeup (); #elif defined( WT32_SC01 ) + #elif defined( T_DISPLAY_S3_TOUCH ) + #endif #endif } @@ -443,6 +459,8 @@ void bma_wakeup( void ) { bma.enableStepCountInterrupt( true ); #elif defined( WT32_SC01 ) + #elif defined( T_DISPLAY_S3_TOUCH ) + #endif #endif } @@ -480,6 +498,7 @@ void bma_wakeup( void ) { #elif defined( LILYGO_WATCH_2021 ) bma.resetStepCounter(); #elif defined( WT32_SC01 ) + #elif defined( T_DISPLAY_S3_TOUCH ) #endif #endif stepcounter_before_reset = 0; @@ -511,6 +530,7 @@ void bma_reload_settings( void ) { bma.enableWakeupInterrupt( bma_config.enable[ BMA_DOUBLECLICK ] ); bma.enableTiltInterrupt( bma_config.enable[ BMA_TILT ] ); #elif defined( WT32_SC01 ) + #elif defined( T_DISPLAY_S3_TOUCH ) #endif #endif } @@ -635,6 +655,8 @@ void bma_set_rotate_tilt( uint32_t rotation ) { } #elif defined( WT32_SC01 ) + #elif defined( T_DISPLAY_S3_TOUCH ) + #endif #endif } @@ -655,6 +677,8 @@ void bma_reset_stepcounter( void ) { bma.resetStepCounter(); #elif defined( WT32_SC01 ) + #elif defined( T_DISPLAY_S3_TOUCH ) + #endif #endif /** diff --git a/src/hardware/motor.cpp b/src/hardware/motor.cpp index 48647505..3de518e1 100644 --- a/src/hardware/motor.cpp +++ b/src/hardware/motor.cpp @@ -103,6 +103,8 @@ } #elif defined( WT32_SC01 ) + #elif defined( T_DISPLAY_S3_TOUCH ) + #else #warning "no hardware driver for motor/vibe" #endif @@ -160,6 +162,8 @@ void motor_setup( void ) { timerAlarmEnable(timer); #elif defined( WT32_SC01 ) + #elif defined( T_DISPLAY_S3_TOUCH ) + #endif #endif /* @@ -202,6 +206,7 @@ bool motor_powermgm_event_cb( EventBits_t event, void *arg ) { break; } #elif defined( WT32_SC01 ) + #elif defined( T_DISPLAY_S3_TOUCH ) #endif #endif return( true ); diff --git a/src/hardware/pmu.cpp b/src/hardware/pmu.cpp index 65bb47e2..3eabb87f 100644 --- a/src/hardware/pmu.cpp +++ b/src/hardware/pmu.cpp @@ -50,6 +50,8 @@ #include #elif defined( WT32_SC01 ) + #elif defined( T_DISPLAY_S3_TOUCH ) + #else #warning "no hardware driver for pmu" #endif @@ -170,6 +172,8 @@ void pmu_setup( void ) { attachInterrupt( CHARGE, &pmu_irq, CHANGE ); #elif defined( WT32_SC01 ) + #elif defined( T_DISPLAY_S3_TOUCH ) + pinMode( BAT_ADC, INPUT ); #endif #endif /* @@ -440,6 +444,10 @@ void pmu_loop( void ) { static bool plug = false; static bool charging = false; static bool battery = percent > 0 ? true : false; + #elif defined( T_DISPLAY_S3_TOUCH ) + static bool plug = false; + static bool charging = false; + static bool battery = percent > 0 ? true : false; #endif #endif /* @@ -822,6 +830,8 @@ int32_t pmu_get_battery_percent( void ) { percent = tmp_percent; #elif defined( WT32_SC01 ) percent = 100; + #elif defined( T_DISPLAY_S3_TOUCH ) + percent = 100; #endif #endif return( percent ); @@ -898,6 +908,23 @@ float pmu_get_battery_voltage( void ) { voltage = ( ( battery * 3300 * 2 ) / 4096 ) + 200; #elif defined( WT32_SC01 ) voltage = 3700.0; + #elif defined( T_DISPLAY_S3_TOUCH ) + uint16_t battery = 0; + uint16_t count = 10; + /** + * dummy read + */ + analogRead( BAT_ADC ); + /** + * collect count measurements + */ + for( int i = 0 ; i < count ; i++ ) + battery += analogRead( BAT_ADC ); + battery /= count; + /** + * calc voltage + */ + voltage = ( ( battery * 3300 * 2 ) / 4096 ) + 200; #endif #endif return( voltage ); @@ -1002,6 +1029,7 @@ float pmu_get_battery_charge_current( void ) { current = ttgo->power->getBattChargeCurrent(); #elif defined( LILYGO_WATCH_2021 ) #elif defined( WT32_SC01 ) + #elif defined( T_DISPLAY_S3_TOUCH ) #endif #endif @@ -1024,6 +1052,7 @@ float pmu_get_battery_discharge_current( void ) { current = ttgo->power->getBattDischargeCurrent(); #elif defined( LILYGO_WATCH_2021 ) #elif defined( WT32_SC01 ) + #elif defined( T_DISPLAY_S3_TOUCH ) #endif #endif @@ -1048,6 +1077,8 @@ float pmu_get_vbus_voltage( void ) { #elif defined( LILYGO_WATCH_2021 ) #elif defined( WT32_SC01 ) voltage = 5.0f; + #elif defined( T_DISPLAY_S3_TOUCH ) + voltage = 5.0f; #endif #endif @@ -1068,6 +1099,7 @@ float pmu_get_coulumb_data( void ) { coulumb_data = ttgo->power->getCoulombData(); #elif defined( LILYGO_WATCH_2021 ) #elif defined( WT32_SC01 ) + #elif defined( T_DISPLAY_S3_TOUCH ) #endif #endif @@ -1090,6 +1122,8 @@ bool pmu_is_charging( void ) { charging = digitalRead( CHARGE ) ? false : true; #elif defined( WT32_SC01 ) charging = true; + #elif defined( T_DISPLAY_S3_TOUCH ) + charging = true; #endif #endif @@ -1115,6 +1149,8 @@ bool pmu_is_vbus_plug( void ) { plug = false; #elif defined( WT32_SC01 ) plug = true; + #elif defined( T_DISPLAY_S3_TOUCH ) + plug = true; #endif #endif diff --git a/src/hardware/powermgm.cpp b/src/hardware/powermgm.cpp index f5f950d4..25fbfd7f 100644 --- a/src/hardware/powermgm.cpp +++ b/src/hardware/powermgm.cpp @@ -43,7 +43,11 @@ EventGroupHandle_t powermgm_status = NULL; TaskHandle_t _powermgmTask; portMUX_TYPE DRAM_ATTR powermgmMux = portMUX_INITIALIZER_UNLOCKED; - esp_pm_config_esp32_t pm_config; + #ifdef ESP32_S3 + esp_pm_config_esp32s3_t pm_config; + #else + esp_pm_config_esp32_t pm_config; + #endif #endif callback_t *powermgm_callback = NULL; @@ -63,7 +67,7 @@ void powermgm_setup( void ) { powermgm_status = xEventGroupCreate(); powermgm_tickTicker = new Ticker(); - #if defined( LILYGO_WATCH_2021 ) || defined( WT32_SC01 ) + #if defined( LILYGO_WATCH_2021 ) || defined( WT32_SC01 ) || defined( T_DISPLAY_S3_TOUCH ) powermgm_tickTicker->attach_ms( 100, []() { powermgm_resume_from_ISR(); }); diff --git a/src/hardware/rtcctl.cpp b/src/hardware/rtcctl.cpp index e400c89a..e3c9a55d 100644 --- a/src/hardware/rtcctl.cpp +++ b/src/hardware/rtcctl.cpp @@ -51,6 +51,8 @@ PCF8563_Class rtc; #elif defined( WT32_SC01 ) + #elif defined( T_DISPLAY_S3_TOUCH ) + #else #warning "no hardware driver for rtcctl" #endif @@ -116,7 +118,7 @@ void rtcctl_setup( void ) { // attachInterrupt( RTC_Int, &rtcctl_irq, GPIO_INTR_POSEDGE ); #endif #elif defined( WT32_SC01 ) - + #elif defined( T_DISPLAY_S3_TOUCH ) #endif #endif @@ -183,7 +185,7 @@ void set_next_alarm( void ) { #elif defined( LILYGO_WATCH_2021 ) rtc.setAlarm( PCF8563_NO_ALARM, PCF8563_NO_ALARM, PCF8563_NO_ALARM, PCF8563_NO_ALARM ); #elif defined( WT32_SC01 ) - + #elif defined( T_DISPLAY_S3_TOUCH ) #else #warning "no alarm rtcctl function" #endif @@ -235,6 +237,8 @@ void set_next_alarm( void ) { rtc.setAlarm( alarm_tm.tm_hour, alarm_tm.tm_min, alarm_tm.tm_mday, PCF8563_NO_ALARM ); #elif defined( WT32_SC01 ) + #elif defined( T_DISPLAY_S3_TOUCH ) + #else #warning "no alarm rtcctl function" #endif @@ -259,6 +263,8 @@ void rtcctl_set_next_alarm( void ) { rtc.disableAlarm(); #elif defined( WT32_SC01 ) + #elif defined( T_DISPLAY_S3_TOUCH ) + #else #warning "no alarm rtcctl function" #endif @@ -282,6 +288,8 @@ void rtcctl_set_next_alarm( void ) { rtc.enableAlarm(); #elif defined( WT32_SC01 ) + #elif defined( T_DISPLAY_S3_TOUCH ) + #else #warning "no alarm rtcctl function" #endif @@ -304,6 +312,7 @@ bool rtcctl_powermgm_event_cb( EventBits_t event, void *arg ) { // gpio_wakeup_enable( (gpio_num_t)RTC_Int, GPIO_INTR_POSEDGE ); // esp_sleep_enable_gpio_wakeup (); #elif defined( WT32_SC01 ) + #elif defined( T_DISPLAY_S3_TOUCH ) #else #warning "no rtcctl powermgm standby event" #endif @@ -323,6 +332,7 @@ bool rtcctl_powermgm_event_cb( EventBits_t event, void *arg ) { attachInterrupt( RTC_INT_PIN, &rtcctl_irq, FALLING ); #elif defined( LILYGO_WATCH_2021 ) #elif defined( WT32_SC01 ) + #elif defined( T_DISPLAY_S3_TOUCH ) #else #warning "no rtcctl powermgm enable interrupts event" #endif @@ -338,6 +348,7 @@ bool rtcctl_powermgm_event_cb( EventBits_t event, void *arg ) { detachInterrupt( RTC_INT_PIN ); #elif defined( LILYGO_WATCH_2021 ) #elif defined( WT32_SC01 ) + #elif defined( T_DISPLAY_S3_TOUCH ) #else #warning "no rtcctl powermgm disable interrupts event" #endif @@ -413,6 +424,7 @@ void rtcctl_set_alarm( rtcctl_alarm_t *data ) { #elif defined( LILYGO_WATCH_2021 ) rtc.disableAlarm(); #elif defined( WT32_SC01 ) + #elif defined( T_DISPLAY_S3_TOUCH ) #else #warning "no rtcctl alarm function" #endif @@ -447,6 +459,8 @@ void rtcctl_set_alarm( rtcctl_alarm_t *data ) { rtc.enableAlarm(); #elif defined( WT32_SC01 ) + #elif defined( T_DISPLAY_S3_TOUCH ) + #else #warning "no rtcctl alarm function" #endif @@ -467,6 +481,8 @@ void rtcctl_set_alarm( rtcctl_alarm_t *data ) { rtc.enableAlarm(); #elif defined( WT32_SC01 ) + #elif defined( T_DISPLAY_S3_TOUCH ) + #else #warning "no rtcctl alarm function" #endif @@ -541,6 +557,7 @@ void rtcctl_syncToSystem( void ) { #elif defined( LILYGO_WATCH_2021 ) rtc.syncToSystem(); #elif defined( WT32_SC01 ) + #elif defined( T_DISPLAY_S3_TOUCH ) #endif #endif } @@ -601,6 +618,7 @@ void rtcctl_syncToRtc( void ) { #elif defined( LILYGO_WATCH_2021 ) rtc.syncToRtc(); #elif defined( WT32_SC01 ) + #elif defined( T_DISPLAY_S3_TOUCH ) #endif #endif } \ No newline at end of file diff --git a/src/hardware/sdcard.cpp b/src/hardware/sdcard.cpp index dbc57926..fbcff8ed 100644 --- a/src/hardware/sdcard.cpp +++ b/src/hardware/sdcard.cpp @@ -44,6 +44,7 @@ #endif #elif defined( LILYGO_WATCH_2021 ) #elif defined( WT32_SC01 ) + #elif defined( T_DISPLAY_S3_TOUCH ) #else #warning "no hardware driver for sd_card" #endif @@ -101,6 +102,7 @@ void sdcard_setup( void ) { #endif #elif defined( LILYGO_WATCH_2021 ) #elif defined( WT32_SC01 ) + #elif defined( T_DISPLAY_S3_TOUCH ) #endif #endif powermgm_register_cb( POWERMGM_SILENCE_WAKEUP | POWERMGM_STANDBY | POWERMGM_WAKEUP, sdcard_powermgm_event_cb, "sdcard powermgm" ); @@ -198,6 +200,8 @@ bool sdcard_powermgm_event_cb( EventBits_t event, void *arg ) { retval = true; #elif defined( WT32_SC01 ) retval = true; + #elif defined( T_DISPLAY_S3_TOUCH ) + retval = true; #else switch( event ) { case POWERMGM_SILENCE_WAKEUP: diff --git a/src/hardware/sensor.cpp b/src/hardware/sensor.cpp index b1be36ff..46ec833e 100644 --- a/src/hardware/sensor.cpp +++ b/src/hardware/sensor.cpp @@ -33,6 +33,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 sensor" #endif @@ -54,6 +55,7 @@ void sensor_setup( void ) { M5.SHT30.Begin(); #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 #endif /** @@ -101,6 +103,8 @@ bool sensor_powermgm_loop_cb( EventBits_t event, void *arg ) { retval = true; #elif defined( WT32_SC01 ) retval = true; + #elif defined( T_DISPLAY_S3_TOUCH ) + retval = true; #else #warning "not sensor powermgm loop" retval = true; @@ -140,6 +144,8 @@ bool sensor_powermgm_event_cb( EventBits_t event, void *arg ) { retval = true; #elif defined( WT32_SC01 ) retval = true; + #elif defined( T_DISPLAY_S3_TOUCH ) + retval = true; #else #warning "not sensor powermgm" retval = true; @@ -158,6 +164,7 @@ bool sensor_get_available( void ) { retval = true; #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 #endif @@ -181,6 +188,7 @@ float sensor_get_temperature( void ) { temperature = M5.SHT30.GetTemperature(); #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 #endif @@ -204,6 +212,7 @@ float sensor_get_humidity( void ) { humidity = M5.SHT30.GetAbsHumidity(); #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 #endif @@ -227,6 +236,7 @@ float sensor_get_relativ_humidity( void ) { relativ_humidity = M5.SHT30.GetRelHumidity(); #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 #endif @@ -249,6 +259,7 @@ float sensor_get_pressure( 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 #endif diff --git a/src/hardware/sound.cpp b/src/hardware/sound.cpp index 16902f4b..33970d18 100644 --- a/src/hardware/sound.cpp +++ b/src/hardware/sound.cpp @@ -58,6 +58,7 @@ #elif defined( LILYGO_WATCH_2020_V2 ) #elif defined( LILYGO_WATCH_2021 ) #elif defined( WT32_SC01 ) + #elif defined( T_DISPLAY_S3_TOUCH ) #else #warning "no hardware driver for sound" #endif diff --git a/src/hardware/touch.cpp b/src/hardware/touch.cpp index 4e6d0c35..c589ac54 100644 --- a/src/hardware/touch.cpp +++ b/src/hardware/touch.cpp @@ -54,6 +54,17 @@ touch_config_t touch_config; #include Adafruit_FT6206 ctp = Adafruit_FT6206(); + #elif defined( T_DISPLAY_S3_TOUCH ) + #include + #include "TouchLib.h" + + #if defined(TOUCH_MODULES_CST_MUTUAL) + TouchLib touch(Wire, PIN_IIC_SDA, PIN_IIC_SCL, CTS328_SLAVE_ADDRESS, PIN_TOUCH_RES); + #elif defined(TOUCH_MODULES_CST_SELF) + TouchLib touch(Wire, PIN_IIC_SDA, PIN_IIC_SCL, CTS820_SLAVE_ADDRESS, PIN_TOUCH_RES); + #else + #error "Please choose the correct touch driver model!" + #endif #else #error "no hardware driver for touch, please setup minimal drivers ( display/framebuffer/touch )" #endif @@ -149,6 +160,11 @@ void touch_setup( void ) { #elif defined( WT32_SC01 ) pinMode( GPIO_NUM_39, INPUT ); ASSERT( ctp.begin(40), "Couldn't start FT6206 touchscreen controller"); + #elif defined( T_DISPLAY_S3_TOUCH ) + Wire.begin(PIN_IIC_SDA, PIN_IIC_SCL, 800000); + bool inited_touch = touch.init(); + ASSERT(inited_touch , "Couldn't start FT6206 touchscreen controller"); + if(inited_touch) touch.setRotation(1); #else #error "no touch init implemented, please setup minimal drivers ( display/framebuffer/touch )" #endif @@ -245,6 +261,22 @@ bool touch_powermgm_loop_event_cb( EventBits_t event, void *arg ) { retval = true; break; } + #elif defined( T_DISPLAY_S3_TOUCH ) + switch( event ) { + case POWERMGM_STANDBY: + if( touch.read() ) + powermgm_set_event( POWERMGM_WAKEUP_REQUEST ); + retval = true; + break; + case POWERMGM_WAKEUP: + retval = true; + break; + case POWERMGM_SILENCE_WAKEUP: + if ( touch.read() ) + powermgm_set_event( POWERMGM_WAKEUP_REQUEST ); + retval = true; + break; + } #else #error "no touch powermgm loop event implemented, please setup minimal drivers ( display/framebuffer/touch )" #endif @@ -346,6 +378,29 @@ bool touch_powermgm_event_cb( EventBits_t event, void *arg ) { retval = true; break; } + #elif defined( T_DISPLAY_S3_TOUCH ) + switch( event ) { + case POWERMGM_STANDBY: log_d("go standby"); + /** + * enable GPIO in lightsleep for wakeup + */ + gpio_wakeup_enable( (gpio_num_t)GPIO_NUM_16, GPIO_INTR_LOW_LEVEL ); + esp_sleep_enable_gpio_wakeup (); + retval = true; + break; + case POWERMGM_WAKEUP: log_d("go wakeup"); + retval = true; + break; + case POWERMGM_SILENCE_WAKEUP: log_d("go silence wakeup"); + retval = true; + break; + case POWERMGM_ENABLE_INTERRUPTS: + retval = true; + break; + case POWERMGM_DISABLE_INTERRUPTS: + retval = true; + break; + } #else #error "no touch powermgm event implemented, please setup minimal drivers ( display/framebuffer/touch )" #endif @@ -461,6 +516,16 @@ bool touch_getXY( int16_t &x, int16_t &y ) { else { return( false ); } + #elif defined( T_DISPLAY_S3_TOUCH ) + if ( touch.read() ) { + TP_Point p = touch.getPoint(0); + x = p.x; + y = map( p.y, 0, TFT_WIDTH, TFT_WIDTH, 0 ); + return( true ); + } + else { + return( false ); + } #else #error "no touch getXY function implemented, please setup minimal drivers ( display/framebuffer/touch )" #endif @@ -569,6 +634,8 @@ static bool touch_read(lv_indev_drv_t * drv, lv_indev_data_t*data) { data->state = touch_getXY( data->point.x, data->point.y ) ? LV_INDEV_STATE_PR : LV_INDEV_STATE_REL; #elif defined( WT32_SC01 ) data->state = touch_getXY( data->point.x, data->point.y ) ? LV_INDEV_STATE_PR : LV_INDEV_STATE_REL; + #elif defined( T_DISPLAY_S3_TOUCH ) + data->state = touch_getXY( data->point.x, data->point.y ) ? LV_INDEV_STATE_PR : LV_INDEV_STATE_REL; #else #error "no LVGL Input driver function implemented, please setup minimal drivers ( display/framebuffer/touch )" #endif From 04fdc537d80d1482c8c41ac7632d9e91d49577b3 Mon Sep 17 00:00:00 2001 From: esp32-urobot Date: Thu, 14 Sep 2023 17:48:09 +0900 Subject: [PATCH 2/3] Fix default_envs --- platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index 2a14b2bb..af9c1a50 100644 --- a/platformio.ini +++ b/platformio.ini @@ -9,7 +9,7 @@ ; http://docs.platformio.org/page/projectconf.html [platformio] -default_envs = t-watch2021-v1 +default_envs = t-watch2020-v1 [env:emulator_m5paper] platform = native@^1.1.3 From 2b10ccf47674a70ccc24eaa0f9bcf942efb937b8 Mon Sep 17 00:00:00 2001 From: esp32-urobot Date: Thu, 14 Sep 2023 20:01:54 +0900 Subject: [PATCH 3/3] Fix temp_button_irq_flag --- src/hardware/button.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/hardware/button.cpp b/src/hardware/button.cpp index e99196df..459c99ed 100644 --- a/src/hardware/button.cpp +++ b/src/hardware/button.cpp @@ -470,6 +470,10 @@ bool button_powermgm_loop_cb( EventBits_t event, void *arg ) { } } #endif + /** + * prevent "warning: variable 'temp_button_irq_flag' set but not used" in some platform conditions + */ + temp_button_irq_flag = ~temp_button_irq_flag; #endif return( true ); } @@ -600,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 ) ); -} \ No newline at end of file +}