;***************************************************;
;       Sunton ESP32-WROOM custom dev board with    ;
;               - ST7796 TFT SPI 4-WIRE             ;
;               - XPT2046 or GT911 touch controller ;
;***************************************************;

[esp32-3248s035]
extends = arduino_esp32_v2
board = esp32dev

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

;region -- TFT_eSPI build options ------------------------
    ${esp32.hspi}        ; Use HSPI hardware SPI bus
    -D ST7796_DRIVER=1
    -D TFT_ROTATION=0 ; 0=0, 1=90, 2=180 or 3=270 degree
    -D TFT_WIDTH=320
    -D TFT_HEIGHT=480
    -D TFT_CS=15      ;// Chip select control pin
    -D TFT_DC=2       ;// Data Command control pin
    -D TFT_RST=-1     ;// Reset pin (could connect to RST pin)
    -D TFT_BCKL=27    ;None, configurable via web UI (e.g. 2 for D4)
    -D SUPPORT_TRANSACTIONS
    -D SPI_FREQUENCY=65000000
    -D SPI_READ_FREQUENCY=20000000
;endregion

; -- Debugging options -----------------------------
;   -D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG


[env:esp32-3248s035r_4MB]
extends = esp32-3248s035, flash_4mb
build_flags =
    ${esp32-3248s035.build_flags}
    -D USER_SETUP_LOADED=1
    -D TOUCH_CS=33
    -D TOUCH_DRIVER=0x2046 ; XPT2606 Resistive touch panel driver
    -D HASP_USE_LGFX_TOUCH=1
    -D TOUCH_SDA=-1
    -D TOUCH_SCL=-1
    -D TOUCH_IRQ=-1
    -D I2C_TOUCH_PORT=0
    -D I2C_TOUCH_ADDRESS=0
    -D I2C_TOUCH_FREQUENCY=0
    -D SPI_TOUCH_FREQUENCY=2500000

lib_deps =
    ${esp32-3248s035.lib_deps}
    ${tft_espi.lib_deps}
    ;${lovyangfx.lib_deps}
    

[env:esp32-3248s035c_4MB]
extends = esp32-3248s035, flash_4mb
board = esp32dev

build_flags =
    ${esp32-3248s035.build_flags}
    ${esp32.no_ps_ram}

;region -- TFT_eSPI build options ------------------------
    ${esp32.hspi}        ; Use HSPI hardware SPI bus
    ;-D USER_SETUP_LOADED=1
    -D LGFX_USE_V1=1
    -D ST7796_DRIVER=1
    -D TOUCH_DRIVER=0x0911 ; GT911 Capacitive I2C touch panel driver
    -D HASP_USE_LGFX_TOUCH=1
    -D TFT_ROTATION=0 ; 0=0, 1=90, 2=180 or 3=270 degree
    -D TFT_WIDTH=320
    -D TFT_HEIGHT=480
    -D TFT_CS=15      ;// Chip select control pin
    -D TFT_DC=2       ;// Data Command control pin
    -D TFT_RST=-1     ;// Reset pin (could connect to RST pin)
    -D TFT_BCKL=27    ;None, configurable via web UI (e.g. 2 for D4)
    -D SUPPORT_TRANSACTIONS    
    -D TOUCH_SDA=33
    -D TOUCH_SCL=32
    ;-D TOUCH_IRQ=21
    -D TOUCH_IRQ=-1
    -D TOUCH_RST=25
    -D I2C_TOUCH_FREQUENCY=400000
    -D I2C_TOUCH_PORT=1
    -D I2C_TOUCH_ADDRESS=0x5D ; or 0x14
    -D SPI_FREQUENCY=65000000
    -D SPI_TOUCH_FREQUENCY=2500000
    -D SPI_READ_FREQUENCY=20000000
;endregion

; -- Debugging options -----------------------------
;   -D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG

lib_deps =
    ${esp32-3248s035.lib_deps}
    ;${tft_espi.lib_deps}
    ${lovyangfx.lib_deps}
    ;${goodix.lib_deps}
