; 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

[env]
platform = espressif32
framework = arduino
lib_deps = 
	https://github.com/me-no-dev/ESPAsyncWebServer
	https://github.com/tzapu/WiFiManager.git#feature_asyncwebserver
	bblanchon/ArduinoJson
	bodmer/TFT_eSPI
	https://github.com/Bodmer/TJpg_Decoder.git
	https://github.com/garretlab/shoddyxml2
	https://github.com/Bodmer/U8g2_for_TFT_eSPI
	https://github.com/ricmoo/qrcode
	fastled/FastLED

platform_packages = 
board_build.filesystem = littlefs
monitor_filters = esp32_exception_decoder
monitor_speed = 115200
board_build.f_cpu = 240000000L
;upload_port = COM30
;monitor_port = COM30

[env:OpenEPaperLink_Mini_AP]
platform = https://github.com/platformio/platform-espressif32.git
board=lolin_s2_mini
board_build.partitions = default.csv
build_unflags =
  -D CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC=y
build_flags = 
	-D BUILD_ENV_NAME=$PIOENV
	-D BUILD_TIME=$UNIX_TIME
	-D OPENEPAPERLINK_MINI_AP_PCB
	-D ARDUINO_USB_MODE=0
	-D CONFIG_SPIRAM_USE_MALLOC=1
	-D CONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC=y

	-D HAS_RGB_LED
	-D BOARD_HAS_PSRAM
	
	-D POWER_NO_SOFT_POWER

	-D FLASHER_AP_SS=11
	-D FLASHER_AP_CLK=9
	-D FLASHER_AP_MOSI=10
	-D FLASHER_AP_MISO=8
	-D FLASHER_AP_RESET=13
  	-D FLASHER_AP_POWER={-1} ;this board has no soft power control
  	-D FLASHER_AP_TXD=7
  	-D FLASHER_AP_RXD=6
  	-D FLASHER_AP_TEST=12
  	-D FLASHER_LED=15
  	-D FLASHER_RGB_LED=33

	-D USER_SETUP_LOADED
	-D DISABLE_ALL_LIBRARY_WARNINGS
	-D ILI9341_DRIVER
	-D SMOOTH_FONT
	-D LOAD_FONT2

build_src_filter = 
   +<*>-<usbflasher.cpp>-<serialconsole.cpp>

board_build.psram_type=qspi_opi
board_upload.maximum_size = 4194304
;board_upload.maximum_ram_size = 2097152
board_upload.maximum_ram_size = 327680
board_upload.flash_size = 4MB


[env:OpenEPaperLink_Nano_AP]
platform = https://github.com/platformio/platform-espressif32.git
board=lolin_s2_mini
board_build.partitions = default.csv
build_unflags =
  -D CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC=y
build_flags = 
	-D BUILD_ENV_NAME=$PIOENV
	-D BUILD_TIME=$UNIX_TIME
	-D OPENEPAPERLINK_NANO_AP_PCB
	-D ARDUINO_USB_MODE=0
	-D CONFIG_SPIRAM_USE_MALLOC=1
	-D CONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC=y

	-D BOARD_HAS_PSRAM

	-D FLASHER_AP_SS=38
	-D FLASHER_AP_CLK=40
	-D FLASHER_AP_MOSI=39
	-D FLASHER_AP_MISO=33
	-D FLASHER_AP_RESET=37
  	-D FLASHER_AP_POWER={16,17,18,21}
  	-D FLASHER_AP_TXD=35
  	-D FLASHER_AP_RXD=36
  	-D FLASHER_AP_TEST=34
  	-D FLASHER_LED=15
  	-D FLASHER_RGB_LED=-1

	-D USER_SETUP_LOADED
	-D DISABLE_ALL_LIBRARY_WARNINGS
	-D ILI9341_DRIVER
	-D SMOOTH_FONT
	-D LOAD_FONT2

build_src_filter = 
   +<*>-<usbflasher.cpp>-<serialconsole.cpp>

board_build.psram_type=qspi_opi
board_upload.maximum_size = 4194304
;board_upload.maximum_ram_size = 2097152
board_upload.maximum_ram_size = 327680
board_upload.flash_size = 4MB


; ----------------------------------------------------------------------------------------
; !!! this configuration expects the 16MB Flash / 8MB Ram version of the ESP32-S3-DevkitC1
; 
; ----------------------------------------------------------------------------------------
[env:OpenEPaperLink_AP_and_Flasher]
platform = https://github.com/platformio/platform-espressif32.git
board = esp32-s3-devkitc-1
board_build.partitions = default_16MB.csv

build_unflags =
  -D ARDUINO_USB_MODE=1
  -D CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC=y
build_flags = 
	-D BUILD_ENV_NAME=$PIOENV
	-D BUILD_TIME=$UNIX_TIME
	-D OPENEPAPERLINK_PCB
	-D ARDUINO_USB_MODE=0
	-D CONFIG_ESP32S3_SPIRAM_SUPPORT=1
	-D CONFIG_SPIRAM_USE_MALLOC=1
	-D HAS_USB
	-D HAS_RGB_LED
	-D BOARD_HAS_PSRAM
	-D CONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC=y
	
	-D POWER_RAMPING
	-D POWER_HIGH_SIDE_DRIVER

	-D FLASHER_AP_SS=4
	-D FLASHER_AP_CLK=5
	-D FLASHER_AP_MOSI=7
	-D FLASHER_AP_MISO=6
	-D FLASHER_AP_RESET=15
	-D FLASHER_AP_POWER={0} 
	-D FLASHER_AP_TXD=16
	-D FLASHER_AP_RXD=18
	-D FLASHER_AP_TEST=17

	-D FLASHER_EXT_SS=40
	-D FLASHER_EXT_CLK=41
	-D FLASHER_EXT_MOSI=2
	-D FLASHER_EXT_MISO=42
	-D FLASHER_EXT_RESET=1
	-D FLASHER_EXT_POWER={8}
	-D FLASHER_EXT_TXD=38
	-D FLASHER_EXT_RXD=39
	-D FLASHER_EXT_TEST=47

	-D FLASHER_ALT_SS=3
	-D FLASHER_ALT_CLK=46
	-D FLASHER_ALT_MOSI=10
	-D FLASHER_ALT_MISO=9
	-D FLASHER_ALT_RESET=11
	-D FLASHER_ALT_POWER={-1}
	-D FLASHER_ALT_TXD=12
	-D FLASHER_ALT_RXD=14
	-D FLASHER_ALT_TEST=13

	-D FLASHER_LED=21
	-D FLASHER_RGB_LED=48

	-D USER_SETUP_LOADED
	-D DISABLE_ALL_LIBRARY_WARNINGS
	-D ILI9341_DRIVER
	-D SMOOTH_FONT
	-D LOAD_FONT2

board_build.flash_mode=qio
board_build.arduino.memory_type = qio_opi
board_build.psram_type=qspi_opi

board_upload.maximum_size = 16777216
board_upload.maximum_ram_size = 327680
board_upload.flash_size = 16MB

[env:Simple_AP]
board = esp32dev
board_build.partitions = default.csv

build_flags = 
	-D BUILD_ENV_NAME=$PIOENV
	-D BUILD_TIME=$UNIX_TIME
	-D CORE_DEBUG_LEVEL=0
	-D SIMPLE_AP

	-D FLASHER_AP_SS=5
	-D FLASHER_AP_CLK=18
	-D FLASHER_AP_MOSI=23
	-D FLASHER_AP_MISO=19
	-D FLASHER_AP_RESET=2
	-D FLASHER_AP_POWER={13,15}
	-D FLASHER_AP_TEST=-1
	-D FLASHER_AP_TXD=17
	-D FLASHER_AP_RXD=16
	-D FLASHER_LED=22

	-D USER_SETUP_LOADED
	-D DISABLE_ALL_LIBRARY_WARNINGS
	-D ILI9341_DRIVER
	-D SMOOTH_FONT
	-D LOAD_FONT2

build_src_filter = 
   +<*>-<usbflasher.cpp>-<serialconsole.cpp>
   
; ----------------------------------------------------------------------------------------
; !!! this configuration expects the alternative 2.9" Flasher PCB
; ----------------------------------------------------------------------------------------

[env:Alternative_PCB]
board = esp32dev
board_build.partitions = no_ota.csv

build_flags = 
	-D BUILD_ENV_NAME=$PIOENV
	-D BUILD_TIME=$UNIX_TIME
	-D ALTERNATIVE_PCB
	-D FLASHER_AP_SS=22
	-D FLASHER_AP_CLK=13
	-D FLASHER_AP_MOSI=23
	-D FLASHER_AP_MISO=33
	-D FLASHER_AP_RESET=27
	-D FLASHER_AP_POWER={4}
	-D FLASHER_AP_TEST=-1
	-D FLASHER_AP_TXD=26
	-D FLASHER_AP_RXD=25

	-D FLASHER_LED=19
build_src_filter = 
   +<*>-<usbflasher.cpp>-<serialconsole.cpp>
