;***************************************************;
;          ESP32-Touchdown custom PCB with 3.5" TFT ;
;               - ili9488 TFT SPI 4-WIRE            ;
;               - ft6336 touch controller           ;
;***************************************************;

[env:esp32-touchdown]
extends = arduino_esp32_v2, flash_4mb
board = esp32dev

build_flags =
    -D HASP_MODEL="ESP32 Touchdown"
    ${arduino_esp32_v2.build_flags}
    ${esp32.no_ps_ram}

;region -- TFT_eSPI build options ------------------------
    ${esp32.vspi}        ; Use VSPI hardware SPI bus
    -D USER_SETUP_LOADED=1
    -D ILI9488_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=4 ;// Reset pin (could connect to RST pin)
    -D TFT_BCKL=32  ;None, configurable via web UI (e.g. 2 for D4)
    -D SUPPORT_TRANSACTIONS
    -D TOUCH_DRIVER=0x6336 ; FT6336 Capacitive touch panel driver 
    -D TOUCH_SDA=21
    -D TOUCH_SCL=22
    -D TOUCH_IRQ=27
    -D TOUCH_RST=-1   ; not used
    -D I2C_TOUCH_FREQUENCY=400000
    -D I2C_TOUCH_ADDRESS=0x38
    -D SPI_FREQUENCY=40000000
    -D SPI_READ_FREQUENCY=20000000
;endregion

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

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