;***************************************************;
;      Waveshare ESP32 One with TFT 3.5" or 4"      ;
;               - Waveshare ESP32 One board         ;
;               - IPS ST7796S Rpi LCD MHS4001 (B)   ;
;               - XPT2046 touch controller          ;
;***************************************************;

[esp32one]
extends = arduino_esp32_v2
board = esp32dev

build_flags =
    ${arduino_esp32_v2.build_flags}
    ${esp32.ps_ram}
    ;-DBOARD_HAS_PSRAM               ; uses 78kB
    ;-mfix-esp32-psram-cache-issue  ; uses 
    
;region -- TFT_eSPI build options ------------------------
    ${esp32.hspi}        ; Use HSPI hardware SPI bus
    -D RPI_DISPLAY_TYPE=1
    -D TFT_WIDTH=320
    -D TFT_HEIGHT=480
    ;-D TFT_ROTATION=0 ; Use default, see TFT_ROTATION values
    -D SPI_FREQUENCY=80000000
    -D SPI_TOUCH_FREQUENCY=2500000
    -D USER_SETUP_LOADED=1
    -D TOUCH_DRIVER=0x2046 ; XPT2046 Resistive SPI touch panel driver
    -D SUPPORT_TRANSACTIONS
    -D TFT_CS=5
    -D TFT_DC=4
    -D TFT_RST=32
    -D TFT_BCKL=26       ; Default, configurable via web UI
    -D TOUCH_CS=22
    -D SD_CS=15          ; Currently not supported
    ;-D LED_BUILTIN=21   ; Onboard LED
    ;-D VBAT=2           ; Default voltage divider NC
;endregion

;region -- Hasp build options ----------------------------
    -D HASP_USE_WIFI=1
;endregion

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


[env:esp32-one_ili9486]
extends = esp32one, flash_4mb
build_flags =
    ${esp32one.build_flags}
    -D ILI9486_DRIVER=1

[env:esp32-one_st7796]
extends = esp32one, flash_4mb
build_flags =
    ${esp32one.build_flags}
    -D ST7796_DRIVER=1
