;***************************************************;
;     Generic ESP32 build with                      ;
;      - Wemos "TTGo" D1-R32 board aka ESPDUINO-32  ;
;      - Arduino UNO ILI9341 2.4" TFT shield        ;
;***************************************************;

[env:d1-r32-unoshield_ili9341_adc]
extends = arduino_esp32_v2, flash_4mb
board = esp32dev

build_flags =
    ${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 LGFX_USE_V1=1
    -D ILI9341_DRIVER=1
    -D TFT_WIDTH=240
    -D TFT_HEIGHT=320
    -D ESP32_PARALLEL=1
    -D TFT_BACKLIGHT_ON=0 ; At what level is the backlight on
    -D TFT_ROTATION=0 ; Use default, see TFT_ROTATION values
    -D TFT_BCKL=-1  ;None, configurable via web UI (e.g. 2 for D4)
    -D TFT_CS=33  ; Chip select control pin
    -D TFT_DC=15  ; Data Command control pin - must use a pin in the range 0-31
    -D TFT_RST=32 ; Reset pin
    -D TFT_WR=4   ; Write strobe control pin - must use a pin in the range 0-31
    -D TFT_RD=2
    -D TFT_D0=12  ; Must use pins in the range 0-31 for the data bus
    -D TFT_D1=13  ; so a single register write sets/clears all bits
    -D TFT_D2=26
    -D TFT_D3=25
    -D TFT_D4=17
    -D TFT_D5=16
    -D TFT_D6=27
    -D TFT_D7=14
    -D SD_CS=5
    -D SPI_FREQUENCY=40000000
    -D SPI_READ_FREQUENCY=20000000
    -D TOUCH_DRIVER=0x0ADC ; No touch driver found? No problem
    -D TOUCH_anDC=35 ; Analog pin to be connected to TFT_DC
    -D TOUCH_anWR=34 ; Analog pin to be connected to TFT_WR
;endregion

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

;region -- Library options -------------------------------
lib_deps =
    ${arduino_esp32_v2.lib_deps}
    ; ${tft_espi.lib_deps}
    ${lovyangfx.lib_deps}
;endregion