; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[platformio]
extra_configs =
  wifi_credentials.ini
default_envs = pcb_rev_1-3, pcb_rev_1-2

[env]
platform = espressif8266
board = d1_mini
framework = arduino

upload_speed = 921600 

upload_protocol = espota
upload_port = 10.0.1.14
upload_flags =
  --port=8266
  --auth=${wifi_cred.admin_password}


build_flags =
  !python git_rev_macro.py
  -DWIFI_SSID_CLIENT=${wifi_cred.wifi_ssid_client}
  -DWIFI_PASSWORD_CLIENT=${wifi_cred.wifi_password_client}
  -DADMIN_PASSWORD=${wifi_cred.admin_password}
  -DWIFI_AP_PASSWORD=${wifi_cred.wifi_ap_password}
  -DWIFI_AP_IP_GW=10,0,0,1
  -DATOMIC_FS_UPDATE

board_build.filesystem = littlefs
extra_scripts = 
  post:prepare_littlefs.py
  pre:build_dtcs.py
  pre:prepare_fwfiles.py

monitor_filters = esp8266_exception_decoder
monitor_speed = 115200

lib_ldf_mode = deep
lib_deps = 
    olikraus/U8g2 @ ^2.28.8
    adafruit/Adafruit NeoPixel @ ^1.11.0
    sstaub/Ticker @ ^4.2.0
    robtillaart/I2C_EEPROM @ ^1.5.2
    me-no-dev/ESP Async WebServer @ ^1.2.3
    bblanchon/ArduinoJson @ ^6.19.4

[env:pcb_rev_1-3]
;build_type = debug
custom_pcb_revision = 3
build_flags =
  ${env.build_flags}
  ;-DFEATURE_ENABLE_WIFI_CLIENT
  ;-DFEATURE_ENABLE_TIMER
  -DFEATURE_ENABLE_OLED
  -DCAN_DEBUG_MESSAGE
  -DPCB_REV=${this.custom_pcb_revision}

board_build.ldscript = eagle.flash.4m1m.ld

lib_deps = 
    ${env.lib_deps}
    coryjfowler/mcp_can @ ^1.5.0
    mikalhart/TinyGPSPlus @ ^1.0.3
    
[env:pcb_rev_1-2]
;build_type = debug
custom_pcb_revision = 2
build_flags =
  ${env.build_flags}
  ;-DFEATURE_ENABLE_WIFI_CLIENT
  ;-DFEATURE_ENABLE_TIMER
  -DFEATURE_ENABLE_OLED
  -DFEATURE_ENABLE_WEBSOCKETS
  -DPCB_REV=${this.custom_pcb_revision}

board_build.ldscript = eagle.flash.4m1m.ld

lib_deps = 
    ${env.lib_deps}