#
# PlatformIO Project Configuration File (global)
# Permet de builder tous les firmwares depuis la racine du projet
#
[platformio]
default_envs = freenove_esp32s3_full_with_ui
src_dir = ui_freenove_allinone

; ===================== ESP32 =====================

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
board_build.partitions = no_ota.csv
board_build.filesystem = littlefs
build_src_filter =
  -<*>
  +<esp32_audio/src/>
  +<../libs/story/src/>
  +<../libs/story/story_engine.cpp>
  -<../libs/story/src/ui/mp3_ui_model_v2.cpp>
monitor_speed = 115200
monitor_filters = time, esp32_exception_decoder
monitor_echo = yes
monitor_eol = LF
monitor_rts = 0
monitor_dtr = 0
lib_deps =
  earlephilhower/ESP8266Audio@^1.9.7
  https://github.com/pschatzmann/arduino-audio-tools.git#v1.2.2
  sensorium/Mozzi@^2.0.2
  https://github.com/pschatzmann/arduino-audio-driver.git#84c7de2eb47efe43bcc769783bb1853ee8a32f21
  bblanchon/ArduinoJson@^6.21.5
  https://github.com/me-no-dev/AsyncTCP.git
  https://github.com/me-no-dev/ESPAsyncWebServer.git
build_flags =
  -I$PROJECT_DIR/protocol
  -Ihardware/firmware/esp32_audio/src
  -Ihardware/libs/story/src
  -Ihardware/libs/story
  -DCORE_DEBUG_LEVEL=1
  -DUSON_STORY_V2_DEFAULT=1
  -DUSON_TRACK_CATALOG_MAX_TRACKS=200

; ===================== freenove_esp32s3_full_with_ui =====================

[env:freenove_esp32s3_full_with_ui]
platform = espressif32@^6.5.0
# Physical board: ESP32-S3-WROOM-1-N16R8 (16MB flash / 16MB PSRAM)
board = esp32-s3-devkitc-1
framework = arduino
board_build.arduino.memory_type = qio_opi
board_build.psram_type = opi
upload_port = /dev/cu.usbmodem5AB907*
monitor_port = /dev/cu.usbmodem5AB907*
extra_scripts = pre:scripts/pio_prepare_webui_fonts.py
board_build.flash_size = 16MB
board_upload.flash_size = 16MB
board_upload.maximum_size = 6291456
board_upload.offset_address = 0x20000
board_build.partitions = partitions/freenove_esp32s3_app6mb_fs6mb.csv
board_build.filesystem = littlefs
build_src_filter =
  -<*>
  +<src/>
  -<src/app/runtime_web_service?2.cpp>
  -<src/ui/fonts/lv_font_ibmplexmono_bold_12?2.c>
  -<src/ui/fonts/lv_font_ibmplexmono_italic_24?2.c>
  -<src/ui/ui_manager_display?2.cpp>
  -<src/ui/ui_manager_intro?2.cpp>
  -<src/main.cpp>
  -<src/scenario_manager.cpp>
  -<src/ui_manager.cpp>
  -<src/audio_manager.cpp>
  -<src/storage_manager.cpp>
  -<src/camera_manager.cpp>
  -<src/button_manager.cpp>
  -<src/touch_manager.cpp>
  -<src/hardware_manager.cpp>
  -<src/network_manager.cpp>
  -<src/media_manager.cpp>
monitor_speed = 115200
monitor_filters = time, esp32_exception_decoder
monitor_echo = yes
monitor_eol = LF
monitor_rts = 0
monitor_dtr = 0
lib_deps =
  bodmer/TFT_eSPI@^2.5.43
  lovyan03/LovyanGFX@^1.2.7
  lvgl/lvgl@^8.4.0
  esphome/ESP32-audioI2S@^2.3.0
  bblanchon/ArduinoJson@^6.21.5
  adafruit/Adafruit NeoPixel@^1.12.3
  https://github.com/alvarowolfx/ESP32QRCodeReader.git#dd07abcf062c4c1b120e0584df57c0c92ca77daf
  https://github.com/codeplea/tinyexpr.git#4a7456e2eab88b4c76053c1c4157639ccb930e2b
build_flags =
  -I$PROJECT_DIR/protocol
  -I$PROJECT_DIR/ui_freenove_allinone/include
  -I$PROJECT_DIR/lib/zacus_story_portable/include
  -O2
  -ffast-math
  -DCORE_DEBUG_LEVEL=0
  -DARDUINO_LOOP_STACK_SIZE=16384
  -DZACUS_SPRINT_DIAG_MODE=1
  -DBOARD_HAS_PSRAM
  -DFREENOVE_USE_PSRAM=1
  -DFREENOVE_PSRAM_UI_DRAW_BUFFER=1
  -DFREENOVE_PSRAM_CAMERA_FRAMEBUFFER=1
  -DZACUS_FW_VERSION=\"freenove_esp32s3\"
  -DUSE_LVGL=1
  -DUSE_AUDIO=1
  -DUSE_CAM=1
  -DUSE_SD=1
  -DUI_COLOR_256=0
  -DUI_COLOR_565=1
  -DUI_FORCE_THEME_256=0
  -DUI_DRAW_BUF_LINES=16
  -DUI_DRAW_BUF_IN_PSRAM=1
  -DUI_AUDIO_RINGBUF_IN_PSRAM=1
  -DUI_CAMERA_FB_IN_PSRAM=1
  -DUI_DMA_TX_IN_DRAM=1
  -DUI_DMA_FLUSH_ASYNC=1
  -DUI_DMA_RGB332_ASYNC_EXPERIMENTAL=0
  -DUI_DMA_TRANS_BUF_LINES=1
  -DUI_ENABLE_SIMD_PATH=1
  -DUI_SIMD_EXPERIMENTAL=0
  -DUI_SIMD_USE_ESP_DSP=1
  -DUI_FULL_FRAME_BENCH=0
  -DUI_DEMO_AUTORUN_WIN_ETAPE=0
  -DUI_WIN_ETAPE_SIMPLIFIED=0
  -DUI_FX_BACKEND_LGFX=1
  -DUI_FX_DMA_BLIT=0
  -DUI_BOING_SHADOW_ASM=1
  -DUI_FX_SPRITE_W=160
  -DUI_FX_SPRITE_H=120
  -DUI_FX_TARGET_FPS=12
  -DFREENOVE_ENABLE_TASK_TOPOLOGY=0
  -DUI_LV_MEM_SIZE_KB=54
  -DUI_FONT_PIXEL_ENABLE=1
  -DUI_FONT_TITLE_XL_ENABLE=1
  -DUI_ENABLE_MEM_MONITOR=0
  -DUI_ENABLE_PERF_MONITOR=0
  -DLV_CONF_INCLUDE_SIMPLE=1
  -DFREENOVE_MEDIA_KIT
  -include ui_freenove_config.h
  -DTFT_RGB_ORDER=TFT_BGR
  -DFREENOVE_LCD_VARIANT_FNK0102A=0
  -DFREENOVE_LCD_VARIANT_FNK0102B=0
  -DFREENOVE_LCD_VARIANT_FNK0102H=1
  -DFREENOVE_LCD_USE_HSPI=1
  -DFREENOVE_HAS_TOUCH=0

[env:freenove_esp32s3]
extends = env:freenove_esp32s3_full_with_ui

[env:freenove_esp32s3_touch]
extends = env:freenove_esp32s3_full_with_ui
build_unflags =
  -DFREENOVE_HAS_TOUCH=0
build_flags =
  ${env:freenove_esp32s3_full_with_ui.build_flags}
  -DFREENOVE_HAS_TOUCH=1

[env:esp32_release]
extends = env:esp32dev
build_unflags = -DUSON_STORY_V2_DEFAULT=1
build_flags = ${env:esp32dev.build_flags} -DUSON_STORY_V2_DEFAULT=0

; =====================  ui_rp2040_ili9488 =====================

[env:ui_rp2040_ili9488]
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
board = rpipico
framework = arduino
build_src_filter =
  -<*>
  +<ui/rp2040_tft/src/>
monitor_speed = 115200
board_build.filesystem = littlefs
lib_deps =
  bodmer/TFT_eSPI@^2.5.43
  paulstoffregen/XPT2046_Touchscreen@0.0.0-alpha+sha.26b691b2c8
  bblanchon/ArduinoJson@^6.21.5
  lvgl/lvgl@^8.3.11
build_flags =
  -I$PROJECT_DIR/protocol
  -Ihardware/firmware/ui/rp2040_tft/include
  -DLV_CONF_INCLUDE_SIMPLE
  -DUSER_SETUP_LOADED=1
  -DTFT_MISO=4
  -DTFT_MOSI=3
  -DTFT_SCLK=2
  -DTFT_CS=5
  -DTFT_DC=6
  -DTFT_RST=7
  -DTOUCH_CS=9
  -DSPI_FREQUENCY=40000000
  -DSPI_READ_FREQUENCY=20000000
  -DSPI_TOUCH_FREQUENCY=2500000
  -DSUPPORT_TRANSACTIONS
  -DUI_LCD_SPI_HOST=0
  -DUI_TOUCH_IRQ_PIN=15
  -DUI_UART_RX_PIN=1
  -DUI_UART_TX_PIN=0
  -DUI_SERIAL_BAUD=57600
  -DUI_ROTATION=1
  -DILI9488_DRIVER
  -DTFT_RGB_ORDER=TFT_BGR



; ===================== (ui_rp2040_ili9486) =====================

[env:ui_rp2040_ili9486]
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
board = rpipico
framework = arduino
build_src_filter =
  -<*>
  +<ui/rp2040_tft/src/>
monitor_speed = 115200
board_build.filesystem = littlefs
lib_deps =
  bodmer/TFT_eSPI@^2.5.43
  paulstoffregen/XPT2046_Touchscreen@0.0.0-alpha+sha.26b691b2c8
  bblanchon/ArduinoJson@^6.21.5
  lvgl/lvgl@^8.3.11
build_flags =
  -I$PROJECT_DIR/protocol
  -Ihardware/firmware/ui/rp2040_tft/include
  -DLV_CONF_INCLUDE_SIMPLE
  -DUSER_SETUP_LOADED=1
  -DFREENOVE_MEDIA_KIT
  -include ui_freenove_config.h
  -DFREENOVE_LCD_WIDTH=480
  -DFREENOVE_LCD_HEIGHT=320
  -DFREENOVE_TFT_CS=5
  -DFREENOVE_TFT_DC=6
  -DFREENOVE_TFT_RST=7
  -DFREENOVE_TFT_MOSI=3
  -DFREENOVE_TFT_MISO=4
  -DFREENOVE_TFT_SCK=2
  -DFREENOVE_TOUCH_CS=9
  -DFREENOVE_TOUCH_IRQ=15
  -DFREENOVE_UART_TX=0
  -DFREENOVE_UART_RX=1
  -DFREENOVE_LCD_ROTATION=1
  -DSPI_FREQUENCY=40000000
  -DSPI_READ_FREQUENCY=20000000
  -DSPI_TOUCH_FREQUENCY=2500000
  -DSUPPORT_TRANSACTIONS
  -DUI_LCD_SPI_HOST=0
  -DUI_SERIAL_BAUD=57600
  -DUI_ROTATION=1
  -DILI9488_DRIVER
  -DTFT_RGB_ORDER=TFT_BGR

; ===================== ESP8266 OLED =====================

[env:esp8266_oled]
platform = espressif8266
board = nodemcuv2
framework = arduino
build_src_filter =
  -<*>
  +<ui/esp8266_oled/src/>
monitor_speed = 115200
monitor_filters = time, colorize, esp8266_exception_decoder
monitor_echo = yes
monitor_eol = LF
monitor_rts = 0
monitor_dtr = 0
lib_deps =
  adafruit/Adafruit SSD1306@^2.5.13
  adafruit/Adafruit GFX Library@^1.12.1
  plerup/EspSoftwareSerial@^8.2.0
  olikraus/U8g2@^2.36.2
  bblanchon/ArduinoJson@^6.21.5
build_flags =
  -Iprotocol

#
# Pour builder tous les firmwares :
#   pio run
# Pour builder un firmware spécifique :
#   pio run -e <nom_env>
# Pour flasher/monitorer :
#   pio run -e <env> -t upload --upload-port <PORT>
#   pio device monitor -e <env> --port <PORT>
#
# Voir docs/protocols/ pour la documentation centralisée
#
