; 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]
lib_dir = lib
include_dir = lib

[common_env_data]
upload_speed = 921600
monitor_speed =  115200
platform = espressif8266 @ 4.0.1
platform32 = espressif32 @ 5.2.0
framework = arduino
board = d1_mini
build_unflags = 
build_flags = 
	-Wl,-Map,output.map
	-DBAUD=${common_env_data.monitor_speed}
	#-D SKIP_SLEEPMODE
	#-D FORCE_GRAVITY_MODE
	#-D DOUBLERESETDETECTOR_DEBUG=true
	-DACTIVATE_OTA
	-DCFG_DISABLE_LOGGING # Turn off verbose/notice logging to reduce size and dont overload uart (applies to LOG_LEVEL6)
	-DGYRO_DISABLE_LOGGING
	-DCALC_DISABLE_LOGGING
	-DHELPER_DISABLE_LOGGING
	-DPUSH_DISABLE_LOGGING
	-DTSEN_DISABLE_LOGGING
	-DWIFI_DISABLE_LOGGING
	-DWEB_DISABLE_LOGGING
	-DMAIN_DISABLE_LOGGING
	-DUSE_LITTLEFS=true
	-DUSER_SSID=\""\""           # =\""myssid\""
	-DUSER_SSID_PWD=\""\""       # =\""mypwd\""	
	-DCFG_APPVER="\"1.2.0\""
	-DCFG_GITREV=\""beta-3\""
	#!python script/git_rev.py
lib_deps =
	# Using local copy of these libraries
  # https://github.com/mp-se/i2cdevlib.git#<document> 		
	# https://github.com/mp-se/OneWire																		  
	# https://github.com/mp-se/Arduino-Temperature-Control-Library
	# https://github.com/khoih-prog/ESP_WiFiManager
	# https://github.com/khoih-prog/ESP_DoubleResetDetector
	https://github.com/mp-se/tinyexpr											#	https://github.com/codeplea/tinyexpr
	https://github.com/mp-se/Arduino-Log#1.1.1    				# https://github.com/thijse/Arduino-Log
	https://github.com/mp-se/ArduinoJson#v6.18.5 					# https://github.com/bblanchon/ArduinoJson
	https://github.com/mp-se/arduinoCurveFitting#v1.0.6   # https://github.com/Rotario/arduinoCurveFitting
	https://github.com/mp-se/arduino-mqtt#v2.5.0				  # https://github.com/256dpi/arduino-mqtt
lib_deps32 = 
	https://github.com/mp-se/NimBLE-Arduino#1.3.8	 				# https://github.com/h2zero/NimBLE-Arduino
extra_scripts =  
	script/copy_firmware.py
	script/create_versionjson.py

; [env:gravity-debug]
; upload_speed = ${common_env_data.upload_speed}
; monitor_speed = ${common_env_data.monitor_speed}
; framework = ${common_env_data.framework}
; platform = ${common_env_data.platform}
; extra_scripts = ${common_env_data.extra_scripts}
; build_unflags =	${common_env_data.build_unflags}
; build_flags = 
;   ${common_env_data.build_flags}
; 	#-D DEBUG_ESP_HTTP_CLIENT	
; 	#-D DEBUG_ESP_HTTP_SERVER	
; 	#-D DEBUG_ESP_PORT=Serial			  	
; 	#-D DEBUG_ESP_WIFI
; 	#-D DEBUG_ESP_SSL
; 	#-D DEBUG_ESP_CORE
; 	-DPIO_FRAMEWORK_ARDUINO_ENABLE_EXCEPTIONS
; 	-DCOLLECT_PERFDATA	# Collect runtime data for a few defined methods to measure time, dumped to serial and/or influxdb 
; 	-DLOG_LEVEL=6 
; lib_deps = 
; 	https://github.com/mp-se/incbin	#	https://github.com/graphitemaster/incbin
; 	${common_env_data.lib_deps}
; board = ${common_env_data.board}
; build_type = release
; board_build.filesystem = littlefs
; monitor_filters = esp8266_exception_decoder

[env:gravity-release]
upload_speed = ${common_env_data.upload_speed}
monitor_speed = ${common_env_data.monitor_speed}
framework = ${common_env_data.framework}
platform = ${common_env_data.platform}
extra_scripts = ${common_env_data.extra_scripts}
build_unflags = ${common_env_data.build_unflags}
build_flags = 
  	${common_env_data.build_flags}
	-D LOG_LEVEL=4
	#-DUSE_SERIAL_PINS # Use the TX/RX pins for the serial port
lib_deps = 
	https://github.com/mp-se/incbin	#	https://github.com/graphitemaster/incbin
	${common_env_data.lib_deps}
board = ${common_env_data.board}
build_type = release
board_build.filesystem = littlefs
build_src_filter = +<*> -<tests/tests*.cpp>

[env:gravity-unit]
upload_speed = ${common_env_data.upload_speed}
monitor_speed = ${common_env_data.monitor_speed}
framework = ${common_env_data.framework}
platform = ${common_env_data.platform}
extra_scripts = ${common_env_data.extra_scripts}
build_unflags = ${common_env_data.build_unflags}
build_flags = 
  	${common_env_data.build_flags}
	-D LOG_LEVEL=4
lib_deps = 
	https://github.com/mp-se/incbin						# https://github.com/graphitemaster/incbin
	https://github.com/bxparks/AUnit#v1.6.1
	${common_env_data.lib_deps}
board = ${common_env_data.board}
build_type = release
board_build.filesystem = littlefs
build_src_filter = +<*> -<main.cpp>

[env:gravity32-release]
framework = ${common_env_data.framework}
platform = ${common_env_data.platform32}
upload_speed = ${common_env_data.upload_speed}
monitor_speed = ${common_env_data.monitor_speed}
extra_scripts = ${common_env_data.extra_scripts}
build_unflags = 
	${common_env_data.build_unflags}
build_flags = 
	-Wl,-Map,output.map
	#-DCORE_DEBUG_LEVEL=0
	${common_env_data.build_flags}
	-D LOG_LEVEL=5
	-DESP32D1
	-DCORE_DEBUG_LEVEL=0
	#-DUSE_SERIAL_PINS # Use the TX/RX pins for the serial port
lib_deps = 
	${common_env_data.lib_deps}
	${common_env_data.lib_deps32}	
lib_ignore = 
board = wemos_d1_mini32 
build_type = release
board_build.partitions = part32.csv
board_build.filesystem = littlefs 
board_build.embed_txtfiles =
	html/calibration.min.htm
	html/config.min.htm
	html/firmware.min.htm
	html/format.min.htm
	html/about.min.htm
	html/index.min.htm
	html/test.min.htm
build_src_filter = +<*> -<tests/tests*.cpp>

[env:gravity32c3-release]
framework = ${common_env_data.framework}
platform = ${common_env_data.platform32}
upload_speed = ${common_env_data.upload_speed}
monitor_speed = ${common_env_data.monitor_speed}
extra_scripts = ${common_env_data.extra_scripts}
build_unflags = 
	${common_env_data.build_unflags}
build_flags = 
	-Wl,-Map,output.map
	${common_env_data.build_flags}
	-DLOG_LEVEL=5
	-DCORE_DEBUG_LEVEL=0
	-DESP32C3
	-DARDUINO_ESP32C3_DEV
	#-DUSE_SERIAL_PINS # Use the TX/RX pins for the serial port
lib_deps = 
	${common_env_data.lib_deps}
	${common_env_data.lib_deps32}
lib_ignore = 
board = lolin_c3_mini 
build_type = release
board_build.partitions = part32.csv
board_build.filesystem = littlefs 
board_build.embed_txtfiles =
	html/calibration.min.htm
	html/config.min.htm
	html/firmware.min.htm
	html/format.min.htm
	html/about.min.htm
	html/index.min.htm
	html/test.min.htm
build_src_filter = +<*> -<tests/tests*.cpp>

[env:gravity32c3v1-release]
framework = ${common_env_data.framework}
platform = ${common_env_data.platform32}
upload_speed = ${common_env_data.upload_speed}
monitor_speed = ${common_env_data.monitor_speed}
extra_scripts = ${common_env_data.extra_scripts}
build_unflags = 
	${common_env_data.build_unflags}
build_flags = 
	-Wl,-Map,output.map
	${common_env_data.build_flags}
	-DLOG_LEVEL=5
	-DCORE_DEBUG_LEVEL=0
	-DESP32C3
	-DARDUINO_ESP32C3_DEV
	-DREDUCE_WIFI_POWER # Enable this if v1.0 chip is used
	#-DUSE_SERIAL_PINS # Use the TX/RX pins for the serial port
lib_deps = 
	${common_env_data.lib_deps}
	${common_env_data.lib_deps32}
lib_ignore = 
board = lolin_c3_mini 
build_type = release
board_build.partitions = part32.csv
board_build.filesystem = littlefs 
board_build.embed_txtfiles =
	html/calibration.min.htm
	html/config.min.htm
	html/firmware.min.htm
	html/format.min.htm
	html/about.min.htm
	html/index.min.htm
	html/test.min.htm
build_src_filter = +<*> -<tests/tests*.cpp>

[env:gravity32s2-release]
framework = ${common_env_data.framework}
platform = ${common_env_data.platform32}
upload_speed = ${common_env_data.upload_speed}
monitor_speed = ${common_env_data.monitor_speed}
extra_scripts = ${common_env_data.extra_scripts}
build_unflags = 
	${common_env_data.build_unflags}
build_flags = 
	-Wl,-Map,output.map
	${common_env_data.build_flags}
	-DLOG_LEVEL=5
	-DCORE_DEBUG_LEVEL=0
	-DESP32S2
	-DARDUINO_ESP32S2_DEV
	#-DUSE_SERIAL_PINS # Use the TX/RX pins for the serial port
lib_deps = 
	${common_env_data.lib_deps}
lib_ignore = 
board = lolin_s2_mini 
build_type = release
board_build.partitions = part32.csv
board_build.filesystem = littlefs 
board_build.embed_txtfiles =
	html/calibration.min.htm
	html/config.min.htm
	html/firmware.min.htm
	html/format.min.htm
	html/about.min.htm
	html/index.min.htm
	html/test.min.htm
build_src_filter = +<*> -<tests/tests*.cpp>

[env:gravity32c3-debug]
framework = ${common_env_data.framework}
platform = ${common_env_data.platform32}
upload_speed = ${common_env_data.upload_speed}
monitor_speed = ${common_env_data.monitor_speed}
monitor_filters = time, colorize, log2file, esp32_exception_decoder
extra_scripts = ${common_env_data.extra_scripts}
upload_port = COM8
debug_tool = esp-prog
debug_init_break = break setup
build_unflags = 
	-DCFG_DISABLE_LOGGING 
	-DGYRO_DISABLE_LOGGING
	-DCALC_DISABLE_LOGGING
	-DHELPER_DISABLE_LOGGING
	-DPUSH_DISABLE_LOGGING
	-DTSEN_DISABLE_LOGGING
	-DWIFI_DISABLE_LOGGING
	-DWEB_DISABLE_LOGGING
	-DMAIN_DISABLE_LOGGING
	${common_env_data.build_unflags}
build_flags = 
	-Wl,-Map,output.map
	${common_env_data.build_flags}
	-DLOG_LEVEL=6
	-DCORE_DEBUG_LEVEL=5
	-DJTAG_DEBUG
	-DESP32C3
	#-DUSE_SERIAL_PINS # Use the TX/RX pins for the serial port
	-DARDUINO_ESP32C3_DEV
	-DCOLLECT_PERFDATA	# Collect runtime data for a few defined methods to measure time, dumped to serial and/or influxdb 
lib_deps = 
	${common_env_data.lib_deps}
	${common_env_data.lib_deps32}
lib_ignore = 
board = esp32-c3-devkitm-1
build_type = debug
board_build.partitions = part32.csv
board_build.filesystem = littlefs 
board_build.embed_txtfiles =
	html/calibration.min.htm
	html/config.min.htm
	html/firmware.min.htm
	html/format.min.htm
	html/about.min.htm
	html/index.min.htm
	html/test.min.htm
build_src_filter = +<*> -<tests/tests*.cpp>

# This is a version for the floaty hardware. No DSB18 sensor and no battery measurement.
[env:gravity32lite-release] 
framework = ${common_env_data.framework}
platform = ${common_env_data.platform32}
upload_speed = ${common_env_data.upload_speed}
monitor_speed = ${common_env_data.monitor_speed}
extra_scripts = ${common_env_data.extra_scripts}
build_unflags = 
	${common_env_data.build_unflags}
build_flags = 
	-Wl,-Map,output.map
	${common_env_data.build_flags}
	-DLOG_LEVEL=5
	-DCORE_DEBUG_LEVEL=0
	-DESP32LITE
	-DFLOATY
	#-DUSE_SERIAL_PINS # Use the TX/RX pins for the serial port
lib_deps = 
	${common_env_data.lib_deps}
	${common_env_data.lib_deps32}
lib_ignore = 
board = lolin32_lite 
build_type = release
board_build.partitions = part32.csv
board_build.filesystem = littlefs 
board_build.embed_txtfiles =
	html/calibration.min.htm
	html/config.min.htm
	html/firmware.min.htm
	html/format.min.htm
	html/about.min.htm
	html/index.min.htm
	html/test.min.htm
build_src_filter = +<*> -<tests/tests*.cpp>
