;***************************************************;
;          Lanbon L8 Switch with ST7789V TFT 2.4"   ;
;               - Custom ESP32 pcb                  ;
;               - ST7789V TFT                       ;
;               - FT5206 touch controller           ;
;***************************************************;

[env:lanbon_l8]
extends = esp32_8mb_v2
board = esp32dev

build_flags =
    ${env.build_flags}
    ${esp32.build_flags}
    ${esp32.ps_ram}
    -D HASP_MODEL="Lanbon L8"

;region -- TFT_eSPI build options ------------------------
    -D LANBONL8
    ; -D USER_SETUP_LOADED=1
    -D LGFX_USE_V1=1
    -D ST7789_DRIVER=1
    ;-D CGRAM_OFFSET=1         ; Library will add offsets required
    -D TFT_SDA_READ            ; Read from display, it only provides an SDA pin
    -D TFT_WIDTH=240
    -D TFT_HEIGHT=320
    -D TFT_ROTATION=2          ; see TFT_ROTATION values
    ; -D TFT_INVERSION_OFF     ; for normal colors
    ; -D TFT_RGB_ORDER=1       ; Colour order Red-Green-Blue
    -D TFT_RGB_ORDER=0         ; Colour order Blue-Green-Red
    -D SPI_FREQUENCY=60000000
    -D SPI_READ_FREQUENCY=6000000 
    -D SUPPORT_TRANSACTIONS
    -D TFT_RST=18        ; FCP pin2 RESET
    -D TFT_SCLK=19       ; FCP pin3 SCL
    -D TFT_DC=21         ; FCP pin4 D/C
    -D TFT_CS=22         ; FCP pin5 CS
    -D TFT_MOSI=23       ; FCP pin6 SDA
    -D TFT_MISO=25       ; FCP pin7 SDO
    -D TFT_BCKL=5
    -D TOUCH_DRIVER=0x6336 ; FT5206 is too slow, 6336U works 6x faster
    -D TOUCH_SDA=4
    -D TOUCH_SCL=0
    -D TOUCH_IRQ=-1   ; not connected
    -D TOUCH_RST=-1   ; not used, connected to 3.3V on FCP pin10
    -D I2C_TOUCH_FREQUENCY=400000
    -D I2C_TOUCH_ADDRESS=0x38
    -D LED_RED=26
    -D LED_GREEN=32
    -D LED_BLUE=33
    -D RELAY_1=12
    -D RELAY_2=24
    -D RELAY_3=37
;endregion

;region -- Library options -------------------------------
lib_deps =
    ${env.lib_deps}
    ${esp32.lib_deps}
    ${arduino_esp32_v2.lib_deps}
    ${lovyangfx.lib_deps}
    ;${tft_espi.lib_deps}
    ; FT6336U is 6x faster then FocalTech Library
    ;git+https://github.com/lewisxhe/FocalTech_Library.git
    ${ft6336.lib_deps}

lib_ignore =
    ${env.lib_ignore}
    ${esp32.lib_ignore}
    ${arduino_esp32_v2.lib_ignore}
;endregion
