;***************************************************;
;          STM32F4xx build with                     ;
;               - STM32F407VET6 black board         ;
;               - FSMC 16 bit ili9341 TFT           ;
;               - xpt2046 touch controller          ;
;***************************************************;

; !Warning! Make sure to purchase a compatible screen, preferably from the same vendor
; There are multiple FSMC interfaces: e.g. One is marked "TFT" and the other one is marked "New-TFT"
; The pinout is different and you can NOT interchange screens from these 2 interfaces!

; Versions:
; - STM32F407VET6 Black (v2.1) has 512 KB flash
; Purchase Link: https://www.aliexpress.com/item/32618222721.html
;                https://www.aliexpress.com/item/33013274704.html
;                https://www.aliexpress.com/item/32868515918.html
;                https://www.aliexpress.com/item/1000006481553.html (! V2.0 !)
; Documentation: https://github.com/mcauser/BLACK_F407VE

; - STM32F407ZGT6 Black (V3.0) has 1 MB flash (with empty PSRAM slot on the back)
; Purchase Link: 
; Documentation: https://github.com/mcauser/BLACK_F407ZG

[env:STM32F407VET6_black_fsmc]
extends = stm32f4
board = black_f407ve
; upload_protocol = dfu
upload_protocol = dfu
debug_tool = stlink
;monitor_port = COM19     ; To change the port, use platform_override.ini
build_flags =
    ${env.build_flags}
    ${stm32f4.build_flags}
    -I include/GxTFT/src
    -I include/GxTFT/src/GxCTRL/GxCTRL_ILI9341

;region -- TFT_eSPI build options ------------------------
    -D ILI9341_DRIVER=1
    -D TFT_WIDTH=240
    -D TFT_HEIGHT=320
    -D USE_FSMC=                    ; Use the onboard FSMC TFT header
    ;-D USER_SETUP_LOADED=1         ; TFT_eSPI is not used here
    ;-D TOUCH_CS=PA6 ;NC
    ;-D TFT_RST=-1  ;D4
    ;-D STM32
    ;-D TFT_SPI3
    ;-D USE_DMA_TO_TFT
;endregion

    -D STM32_SERIAL1                ; Set this option to use Serial1 as default sersial port, leave out if using Serial2

;region -- Hasp build options ----------------------------
    -D HASP_USE_TASMOTA_CLIENT=0
    -D HASP_OUTPUT_PIN=PA1          ; User LED D2 on DevEBox board 
    -D HASP_INPUT_PIN=PA0           ; User Button K1 on DevEBox board
    -D HASP_USE_WIFI=0
    -D HASP_USE_MQTT=0
    -D HASP_USE_HTTP=0
    -D HASP_USE_MDNS=0
    -D HASP_USE_SYSLOG=0
    -D HASP_USE_TELNET=0
    -D HASP_USE_SPIFFS=0
    -D HASP_USE_EEPROM=1
    -D HASP_USE_GPIO=0
    -D HASP_USE_OTA=0
    -D HASP_USE_ETHERNET=0
;endregion

;region -- Network build options -------------------------
    -D USE_BUILTIN_ETHERNET=0
    -D HAL_ETH_MODULE_ENABLED=0
    ; -D LAN8742A_PHY_ADDRESS=0x01U ; moved to include\stm32f4\hal_conf_custom.h
    ; -D DP83848_PHY_ADDRESS=0x01U
;endregion

;region -- Library options -------------------------------
lib_deps =
    ${env.lib_deps}
    ${stm32f4.lib_deps}
    stm32duino/STM32Ethernet @ ^1.2.0
    ;https://github.com/stm32duino/STM32Ethernet.git
    khoih-prog/EthernetWebServer_STM32 @ ^1.1.0
    adafruit/Adafruit GFX Library @ ^1.10.3
    adafruit/Adafruit BusIO @ ^1.6.0
    ;https://github.com/ZinggJM/GxTFT.git
    XPT2046_Touchscreen

lib_ignore =
    lv_lib_zifont

src_filter = +<*> -<.git/> -<.svn/> -<example/> -<examples/> -<test/> -<tests/> -<lv_lib_zifont/> +<stm32f4/>
;endregion