; 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]
default_envs = view

[base_config]
platform = espressif32@3.4
framework = arduino
monitor_speed = 115200
monitor_flags = 
	--eol=CRLF
	--echo
	--filter=esp32_exception_decoder
lib_deps =
    askuric/Simple FOC @ 2.2.0
    infineon/TLV493D-Magnetic-Sensor @ 1.0.3
    bxparks/AceButton @ 1.9.1

build_flags =
  -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG

[env:view]
extends = base_config
; platform = https://github.com/platformio/platform-espressif32.git#feature/arduino-upstream
; platform_packages =
;    framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32#master
board = esp32doit-devkit-v1
lib_deps =
  ; askuric/Simple FOC @ 2.2.1
  ; bxparks/AceButton @ 1.9.1
  ${base_config.lib_deps}
  bodmer/TFT_eSPI@2.4.25
  fastled/FastLED @ 3.5.0
  bogde/HX711 @ 0.7.5
  adafruit/Adafruit VEML7700 Library @ 1.1.1

build_flags =
  ${base_config.build_flags}
  -DSK_DISPLAY=1
  -DSK_LEDS=1
  -DNUM_LEDS=8
  -DSENSOR_MT6701=1
  -DSK_STRAIN=1
  -DSK_INVERT_ROTATION=1
  -DSK_ALS=1

  -DPIN_UH=26
  -DPIN_UL=25
  -DPIN_VH=27
  -DPIN_VL=32
  -DPIN_WH=12
  -DPIN_WL=33
  -DPIN_BUTTON_NEXT=-1
  -DPIN_BUTTON_PREV=-1
  -DPIN_SDA=15
  -DPIN_SCL=8
  -DPIN_MT_DATA=37
  -DPIN_MT_CLOCK=13
  -DPIN_MT_CSN=14
  -DPIN_LED_DATA=7
  -DPIN_LCD_BACKLIGHT=19

  -DDESCRIPTION_FONT=Roboto_Thin_24
  -DDESCRIPTION_Y_OFFSET=20
  -DVALUE_OFFSET=30
  -DDRAW_ARC=0

  -DUSER_SETUP_LOADED=1
  -DGC9A01_DRIVER=1
  -DCGRAM_OFFSET=1
  -DTFT_WIDTH=240
  -DTFT_HEIGHT=240
  -DTFT_MISO=-1
  -DTFT_MOSI=5
  -DTFT_SCLK=20
  -DTFT_CS=21
  -DTFT_DC=22
  -DTFT_RST=4
  -DTFT_BL=-1
  -DLOAD_GLCD=1
  -DLOAD_GFXFF=1
  -DSPI_FREQUENCY=40000000

  ; Reduce loop task stack size (only works on newer IDF Arduino core)
  ; -DARDUINO_LOOP_STACK_SIZE=2048

  ; Modify the default unusable pin mask to allow GPIO 7 (allowed to use on ESP32-PICO-V3-02)
  ; Unusable bits: 6, 8, 9, 10, 20
  ; (0ULL | _FL_BIT(6) | _FL_BIT(8) | _FL_BIT(9) | _FL_BIT(10) | _FL_BIT(20))
  -DFASTLED_UNUSABLE_PIN_MASK=0x100740LL
  
  ; 0~39 except from 24, 28~31 are valid
  ; (0xFFFFFFFFFFULL & ~(0ULL | _FL_BIT(24) | _FL_BIT(28) | _FL_BIT(29) | _FL_BIT(30) | _FL_BIT(31)))
  -DSOC_GPIO_VALID_GPIO_MASK=0xFF0EFFFFFF
  ; GPIO >= 34 are input only
  ; (SOC_GPIO_VALID_GPIO_MASK & ~(0ULL | _FL_BIT(34) | _FL_BIT(35) | _FL_BIT(36) | _FL_BIT(37) | _FL_BIT(38) | _FL_BIT(39)))
  -DSOC_GPIO_VALID_OUTPUT_GPIO_MASK=0x30EFFFFFF

  
[env:handheld_tdisplay]
extends = base_config
board = esp32doit-devkit-v1
lib_deps =
  ${base_config.lib_deps}
  bodmer/TFT_eSPI@2.4.25

build_flags =
  ${base_config.build_flags}
  -DSK_DISPLAY=1
  -DSK_STRAIN=0
  -DSK_LEDS=0

  -DPIN_UH=17
  -DPIN_UL=2
  -DPIN_VH=13
  -DPIN_VL=32
  -DPIN_WH=33
  -DPIN_WL=25
  -DPIN_BUTTON_NEXT=35
  -DPIN_BUTTON_PREV=0
  -DPIN_SDA=-1
  -DPIN_SCL=-1
  -DSENSOR_MT6701=1
  -DPIN_MT_DATA=21
  -DPIN_MT_CLOCK=22
  -DPIN_MT_CSN=12
  -DPIN_LCD_BACKLIGHT=4

  -DDESCRIPTION_FONT=FreeSans9pt7b
  -DDESCRIPTION_Y_OFFSET=80
  -DVALUE_OFFSET=0
  -DDRAW_ARC=1

  -DUSER_SETUP_LOADED=1
  -DST7789_DRIVER=1
  -DCGRAM_OFFSET=1
  -DTFT_WIDTH=135
  -DTFT_HEIGHT=240
  -DTFT_MISO=-1
  -DTFT_MOSI=19
  -DTFT_SCLK=18
  -DTFT_CS=5
  -DTFT_DC=16
  -DTFT_RST=23
  -DTFT_BL=-1
  -DLOAD_GLCD=1
  -DLOAD_GFXFF=1
  -DSPI_FREQUENCY=40000000