; -- Platform specific build flags
[esp32s2]
board_build.mcu = esp32s2
board_build.f_cpu = 240000000L
board_upload.flash_size=4MB
board_upload.maximum_size = 4194304
board_build.partitions = user_setups/esp32s2/no_ota.csv
board_build.filesystem = littlefs

; ----- crash reporter
monitor_filters = esp32_exception_decoder

; ----- debugger
; check_tool = cppcheck
; check_flags = --enable=all
; debug_tool = esp-prog
; debug_init_break = tbreak setup

build_flags =
    ${env.build_flags}
    -D ESP32S2
    -D HTTP_UPLOAD_BUFLEN=1024      ; lower http upload buffer
    -D MQTT_MAX_PACKET_SIZE=2048    ; longer PubSubClient messages
    -D HASP_CONSOLE_BUFFER=256      ; maximum length of a console/telnet command
    -D NO_GLOBAL_HTTPUPDATE         ; dont instantiate httpUpdate
    ;-D CONFIG_NEWLIB_NANO_FORMAT
; -- lvgl build options -----------------------------
    -D LV_ATTRIBUTE_FAST_MEM=       ; smaller RAM doesn't allow for IRAM_ATTR
    -D LV_ATTRIBUTE_TASK_HANDLER=IRAM_ATTR
    ;-D LV_FS_PC_PATH="//littlefs"   ; this needs to match the vfs mount pount
; -- ArduinoJson build options ----------------------------
    -D ARDUINOJSON_ENABLE_PROGMEM=1 ; for PROGMEM arguments
; -- tft_espi build options ------------------------
    ;-D USE_DMA_TO_TFT
; -- openHASP build options ------------------------
    -D HASP_ATTRIBUTE_FAST_MEM=IRAM_ATTR
    -D HASP_USE_TELNET=1
    ;-D HASP_USE_SPIFFS=1
    -D HASP_USE_LITTLEFS=1
    ;-D HASP_USE_EEPROM=1
    -D HASP_USE_CONFIG=1            ; Native application, not library
    -D LV_LOG_TRACE_TIMER=1
    -D HASP_USE_PNGDECODE=1
    -D HASP_USE_BMPDECODE=1
    -D HASP_USE_JPGDECODE=0
    -D HASP_USE_GIFDECODE=0
; -- LittleFS build options ------------------------
	;-D CONFIG_LITTLEFS_FOR_IDF_3_2  ; obsolete in IDF 3.3
; -- FreeType build options ------------------------
    -D HASP_USE_FREETYPE=1
    -D LV_USE_FT_CACHE_MANAGER=1            ; crashes without cache
    -D LVGL_FREETYPE_MAX_FACES=8            ; max number of FreeType faces in cache
    -D LVGL_FREETYPE_MAX_SIZES=8            ; max number of sizes in cache
    -D LVGL_FREETYPE_MAX_BYTES=16384        ; max bytes in cache
    -D LVGL_FREETYPE_MAX_BYTES_PSRAM=131072 ; max bytes in cache when using PSRAM

lib_ignore =
    GxTFT
    XPT2046_Touchscreen
    Adafruit BusIO
    Adafruit GFX Library
    sstaub/Ticker
    lv_drv_fsmc_ili9341
    lv_drivers
    AXP192

lib_deps =
    ${tft_espi.lib_deps}
    ;ESP Async WebServer
    git+https://github.com/fvanroie/ConsoleInput.git#dev

ps_ram =
    -DBOARD_HAS_PSRAM
    ;-mfix-esp32-psram-cache-issue  ; uses 24kB

extra_scripts =
    tools/littlefsbuilder.py
    tools/esp_merge_bin.py
    tools/analyze_elf.py
;    ${env.extra_scripts}
;    tools/copy_partitions.py

; -- The ESP32S2 has 2 SPI Hardware Busses available to use:
hspi =
    -D TFT_MISO=37
    -D TFT_MOSI=35
    -D TFT_SCLK=36
fspi =
    -D TFT_MISO=12
    -D TFT_MOSI=13
    -D TFT_SCLK=14

; -- The Arduino ESP32S2 v2.0.2 with 3 available flash sizes:
[arduino_esp32s2_v2]
framework = arduino
platform = https://github.com/tasmota/platform-espressif32
board_build.embed_files =
    data/edit.htm.gz
    data/style.css.gz
    data/script.js.gz
    data/cert/x509_crt_bundle.bin
board_build.filesystem = littlefs
; ----- crash reporter
monitor_filters = esp32_exception_decoder
extra_scripts =
    ${esp32s2.extra_scripts}

[esp32s2_4mb_v2]
extends = esp32s2, arduino_esp32s2_v2
board_upload.flash_size=4MB
board_upload.maximum_size = 4194304
board_build.partitions = user_setups/esp32/partitions_4MB.csv

[esp32s2_8mb_v2]
extends = esp32s2, arduino_esp32s2_v2
board_upload.flash_size=8MB
board_upload.maximum_size = 8388608
board_build.partitions = user_setups/esp32/partitions_8MB.csv

[esp32s2_16mb_v2]
extends = esp32s2, arduino_esp32s2_v2
board_upload.flash_size = 16MB
board_upload.maximum_size = 16777216
board_build.partitions = user_setups/esp32/partitions_16MB.csv

; =========================== SOLO ==============================================

; -- The Arduino ESP32S2-solo v2.0.2 with 3 available flash sizes:
[arduino_esp32s2-solo_v2]
framework = arduino
platform = https://github.com/tasmota/platform-espressif32/releases/download/v2.0.3rc1/platform-espressif32-2.0.3solo1.zip
board_build.embed_files =
    data/edit.htm.gz
    data/style.css.gz
    data/script.js.gz
    data/cert/x509_crt_bundle.bin
board_build.filesystem = littlefs
; ----- crash reporter
monitor_filters = esp32_exception_decoder
extra_scripts =
    ${esp32s2.extra_scripts}

[esp32s2-solo_4mb_v2]
extends = esp32s2, arduino_esp32s2-solo_v2
board_upload.flash_size=4MB
board_upload.maximum_size = 4194304
board_build.partitions = user_setups/esp32/partitions_4MB.csv

[esp32s2-solo_8mb_v2]
extends = esp32s2, arduino_esp32s2-solo_v2
board_upload.flash_size=8MB
board_upload.maximum_size = 8388608
board_build.partitions = user_setups/esp32/partitions_8MB.csv

[esp32s2-solo_16mb_v2]
extends = esp32s2, arduino_esp32s2-solo_v2
board_upload.flash_size = 16MB
board_upload.maximum_size = 16777216
board_build.partitions = user_setups/esp32/partitions_16MB.csv
