;***************************************************;
;          Lilygo®Ttgo Lily Pi ESP32 with TFT 3.5"  ;
;               - Custom PCB with ESP32-WROVER      ;
;               - IPS st7796 or ili9481 LCD         ;
;               - FT6236 or GT911 touch controller  ;
;***************************************************;

[lilygo-lily-pi]
extends = arduino_esp32_v2
board = esp32dev

build_flags =
    ${arduino_esp32_v2.build_flags}
    ${esp32.ps_ram}
    
;region -- TFT_eSPI build options ------------------------
    -D LGFX_USE_V1=1
    -D LILYGOPI=1
    -D HASP_USE_LGFX_TOUCH=1
    -D SPI_READ_FREQUENCY=20000000
    -D TFT_WIDTH=320
    -D TFT_HEIGHT=480
    -D TFT_MISO=23
    -D TFT_MOSI=19
    -D TFT_SCLK=18
    -D TFT_DC=27
    -D TFT_CS=5 
    -D TFT_RST=-1  ; RST
    -D TFT_BCKL=12 ; None, configurable via web UI (e.g. 21)
    -D I2C_TOUCH_FREQUENCY=400000
    -D I2C_TOUCH_PORT=1
    -D TOUCH_IRQ=34
    -D TOUCH_RST=-1
    -D TOUCH_SDA=21
    -D TOUCH_SCL=22
;endregion

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

lib_deps =
    ${arduino_esp32_v2.lib_deps}
    ${lovyangfx.lib_deps}

[env:lilygo-lily-pi_st7796]
extends = lilygo-lily-pi, flash_16mb
build_flags =
    ${lilygo-lily-pi.build_flags}
    -D ST7796_DRIVER=1
    -D SPI_FREQUENCY=40000000
    -D I2C_TOUCH_ADDRESS=0x38
    -D TOUCH_DRIVER=0x6336
    
[env:lilygo-lily-pi_ili9481]
extends = lilygo-lily-pi, flash_16mb
build_flags =
    ${lilygo-lily-pi.build_flags}
    -D ILI9481_DRIVER=1
    ;-D INVERT_COLORS=1
    ;-D TFT_INVERSION_ON   ; for inverted colors
    -D SPI_FREQUENCY=27000000
    -D I2C_TOUCH_ADDRESS=0x5D ; or 0x14
    -D TOUCH_DRIVER=0x0911 ; GT911 Capacitive I2C touch panel driver