#
# PlatformIO Project Configuration File (global)
# Permet de builder tous les firmwares depuis la racine du projet
#
[platformio]
default_envs = esp32dev, esp32_release, ui_rp2040_ili9488, ui_rp2040_ili9486, esp8266_oled
src_dir = esp32_audio/src

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

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
board_build.partitions = no_ota.csv
board_build.filesystem = littlefs
build_src_filter =
  +<*>
  -<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 =
  -Iprotocol
  -DCORE_DEBUG_LEVEL=1
  -DUSON_STORY_V2_DEFAULT=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 =====================

[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 =
  -Iprotocol
  -Iui/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=19200
  -DUI_ROTATION=1
  -DILI9488_DRIVER
  -DTFT_RGB_ORDER=TFT_BGR

[env:ui_rp2040_ili9486]
extends = env:ui_rp2040_ili9488
build_flags = ${env:ui_rp2040_ili9488.build_flags} -DILI9486_DRIVER

; ===================== 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
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
#
