; * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
; PlatformIO Project Configuration file for GUIslice
; - https://github.com/ImpulseAdventure/GUIslice
;
; - This file will be used to select the MCU, Display
;   and Touch drivers to use with GUIslice
;
; * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

; =========================================================
; Section 1: PlatformIO GENERAL SETTINGS
; =========================================================

[platformio]

; Source files to build:
; - Path to main application code or
;   one of the GUIslice examples to run
;
;src_dir = examples/arduino/ex01_ard_basic
;src_dir = examples/arduino/ex02_ard_btn_txt
src_dir = examples/arduino/ex04_ard_ctrls
;src_dir = examples/arduino/ex07_ard_slider
;src_dir = ...

; Extra config:
; - PlatformIO config to build from project root
lib_dir = .

; Default environments to load
;default_envs =
;	Arduino-ILI9341-STMPE610
;	ESP32-TFT_eSPI-STMPE610

[env]
; GUIslice compilation more straightforward in "deep" LDF mode
lib_ldf_mode = deep
; To enable inspect/cppcheck w/o LTO1 error, disable LTO
build_unflags =
;	-flto

; ---------------------------------------------------------
[common]
; Define any additional compilation flags here
build_flags =
;	-Wall
;	-Wextra
;	-Wunused-variable

; =========================================================
; Section 2: UPLOAD SETTINGS
; =========================================================

[upload-avrisp]
; Board default is:
; - upload_protocol = arduino
upload_protocol = stk500v2
upload_flags = 
	-Pusb

; =========================================================
; Section 3: DISPLAY DRIVERS
; =========================================================

; ---------------------------------------------------------
; Display: Adafruit/Adafruit_ILI9341
; ---------------------------------------------------------
; NOTE:
; - Need to use lib_ldf_mode=deep otherwise the Adafruit
;   libraries report "no such file" compilation errors on
;   "Adafruit_I2CDevice.h"
[disp-ILI9341]
lib_deps =
	SPI
	Wire
	adafruit/Adafruit BusIO
	adafruit/Adafruit GFX Library
	adafruit/Adafruit ILI9341
	adafruit/Adafruit STMPE610
build_flags =

; ---------------------------------------------------------
; Display: prenticedavid/MCUFRIEND_kbv
; ---------------------------------------------------------
[disp-mcufriend]
lib_deps =
	Wire
	adafruit/Adafruit BusIO
	adafruit/Adafruit GFX Library
	prenticedavid/MCUFRIEND_kbv
build_flags =

; ---------------------------------------------------------
; Display: ILI9341_t3
; ---------------------------------------------------------
[disp-ILI9341_t3]
; NOTE (lib_deps):
; - Need to specify the github sources otherwise PIO
;   compilation reports "no such file" on SPI.h
lib_deps =
	https://github.com/PaulStoffregen/Wire
    https://github.com/PaulStoffregen/SPI
    https://github.com/PaulStoffregen/ILI9341_t3
build_flags =

; ---------------------------------------------------------
; Display: bodmer/TFT_eSPI
; ---------------------------------------------------------
[disp-TFT_eSPI]
lib_deps =
	TFT_eSPI

; TFT_eSPI display configuration
; - Example from: Setup1_ILI9341-cal-esp32-feather.h
;   Adafruit Feather ESP32 + Adafruit 2.4" Featherwing TFT
;
; - If using TFT_eSPI, configure to match the settings in the
;   User Setup included within TFT_eSPI/User_Setup_Select.h
; - You must use "-DUSER_SETUP_LOADED=1" here to disable the
;   default config files within TFT_eSPI from being used.
build_flags =
	-D USER_SETUP_LOADED=1
	-D ILI9341_DRIVER
	-D TFT_CS=15
	-D TFT_DC=33
	-D TFT_RST=-1
	-D TFT_MOSI=18
	-D TFT_SCLK=5
	-D TOUCH_CS=32
	-D LOAD_GLCD
	-D LOAD_FONT2
	-D LOAD_FONT4
	-D LOAD_FONT6
	-D LOAD_FONT7
	-D LOAD_FONT8
	-D LOAD_GFXFF
	-D SMOOTH_FONT
	-D SPI_FREQUENCY=40000000
	-D SPI_READ_FREQUENCY=20000000
	-D SPI_TOUCH_FREQUENCY=2500000
	-D SUPPORT_TRANSACTIONS

; ---------------------------------------------------------
; Display: M5stack/m5stack
; ---------------------------------------------------------
[disp-M5Stack]
lib_deps =
	m5stack/M5Stack
build_flags =

; =========================================================
; Section 4: TOUCH DRIVERS
; =========================================================

; ---------------------------------------------------------
; Touch: Adafruit/Adafruit_STMPE610
; ---------------------------------------------------------
[touch-STMPE610]
lib_deps =
	Wire
	adafruit/Adafruit STMPE610
build_flags =

; ---------------------------------------------------------
; Touch: Adafruit/Adafruit_FT6206
; ---------------------------------------------------------
[touch-FT6206]
lib_deps =
	Wire
	adafruit/Adafruit FT6206 Library
build_flags =

; ---------------------------------------------------------
; Touch: Adafruit/Adafruit_Touchscreen (4wire)
; ---------------------------------------------------------
[touch-4wire]
lib_deps =
	adafruit/Adafruit TouchScreen
build_flags =

; ---------------------------------------------------------
; Touch: PaulStoffregen/XPT2046_Touchscreen
; ---------------------------------------------------------
[touch-XPT2046_ps]
lib_deps =
	PaulStoffregen/XPT2046_Touchscreen
build_flags =


; ---------------------------------------------------------
; Touch: None
; ---------------------------------------------------------
[touch-none]
lib_deps =
build_flags =


; =========================================================
; Section 5: MCU Settings
;
; - For additional settings, please refer to:
;   https://docs.platformio.org/en/latest/boards/index.html
;
; =========================================================

; ---------------------------------------------------------
; MCU: "Arduino"
; - Includes:
;   - Atmel AVR
;     - Arduino UNO (board=uno)
;   - Atmel megaAVR
;     - ATmega2560 (board=ATmega2560)
;   - Atmel SAM
;     - Adafruit Grand Central M4 (board=adafruit_grandcentral_m4)
;     - Arduino Due (board=due)
;     - Arduino Zero (board=zero
;   - etc.
; ---------------------------------------------------------
[mcu-Arduino]
platform = atmelavr
board = ATmega2560
framework = arduino
extends = upload-avrisp

; ---------------------------------------------------------
; MCU: ESP32
; - Includes:
;   - Adafruit ESP32 Feather (board=featheresp32)
;   - etc.
; ---------------------------------------------------------
[mcu-ESP32]
platform = espressif32
board = featheresp32
framework = arduino

; ---------------------------------------------------------
; MCU: M5Stack (ESP32)
; - Includes:
;   - M5stack (board=m5stack-core-esp32)
;   - etc.
; ---------------------------------------------------------
[mcu-M5Stack]
platform = espressif32
board = m5stack-core-esp32
framework = arduino

; ---------------------------------------------------------
; MCU: Teensy
; - Includes:
;   - Teensy 3.1/3.2 (board=teensy31)
;   - Teensy 4.0 (board=teensy40)
;   - etc.
; ---------------------------------------------------------
[mcu-Teensy]
platform = teensy
board = teensy31
framework = arduino

; Disable ks0108 as PIO compile for T3 will fail even
; though the ks0108 library is not being used/included.
lib_ignore = ks0108

; =========================================================
; Section 6: ENVIRONMENTS
; =========================================================

; ---------------------------------------------------------
; PlatformIO Example GUIslice Environments
;
; - The following section contains a few example
;   environment configurations that combine a
;   MCU, Display and Touch driver while also loading
;   a corresponding example config from GUIslice.
; - The GUIslice configuration is pulled from the
;   associated GUIslice /configs/ file.
; - If you have an existing GUIslice config file,
;   it is relatively easy to add your own environment
;   here to load the config.
; ---------------------------------------------------------

[env:Arduino-ILI9341-STMPE610]
extends = mcu-Arduino
lib_deps =
	${disp-ILI9341.lib_deps}
	${touch-STMPE610.lib_deps}
build_flags =
	${common.build_flags}
	${disp-ILI9341.build_flags}
	${touch-STMPE610.build_flags}
	-D USER_CONFIG_LOADED
	-D USER_CONFIG_INC_FILE
	-D USER_CONFIG_INC_FNAME=\"../configs/ard-shld-adafruit_28_res.h\"

[env:Arduino-ILI9341-FT6206]
extends = mcu-Arduino
lib_deps =
	${disp-ILI9341.lib_deps}
	${touch-FT6206.lib_deps}
build_flags =
	${common.build_flags}
	${disp-ILI9341.build_flags}
	${touch-FT6206.build_flags}
	-D USER_CONFIG_LOADED
	-D USER_CONFIG_INC_FILE
	-D USER_CONFIG_INC_FNAME=\"../configs/ard-shld-adafruit_28_cap.h\"

[env:Arduino-mcufriend-NoTouch]
extends = mcu-Arduino
lib_deps =
	${disp-mcufriend.lib_deps}
build_flags =
	${common.build_flags}
	${disp-mcufriend.build_flags}
	-D USER_CONFIG_LOADED
	-D USER_CONFIG_INC_FILE
	-D USER_CONFIG_INC_FNAME=\"../configs/ard-shld-mcufriend.h\"

[env:Arduino-mcufriend-4wire]
extends = mcu-Arduino
lib_deps =
	${disp-mcufriend.lib_deps}
	${touch-4wire.lib_deps}

build_flags =
	${common.build_flags}
	${disp-mcufriend.build_flags}
	${touch-4wire.build_flags}
	-D USER_CONFIG_LOADED
	-D USER_CONFIG_INC_FILE
	-D USER_CONFIG_INC_FNAME=\"../configs/ard-shld-mcufriend_4wire.h\"
; TODO: Determine why the override isn't working
; Undefine some settings so we can override
;	-U ADATOUCH_PIN_YP
;	-U ADATOUCH_PIN_XM
;	-U ADATOUCH_PIN_YM
;	-U ADATOUCH_PIN_XP
;	-U ADATOUCH_X_MIN
;	-U ADATOUCH_X_MAX
;	-U ADATOUCH_Y_MIN
;	-U ADATOUCH_Y_MAX
; Provide new pinout & calibration
;	-D ADATOUCH_PIN_YP = A1
;	-D ADATOUCH_PIN_XM = A2
;	-D ADATOUCH_PIN_YM = 7 
;	-D ADATOUCH_PIN_XP = 6 
;	-D ADATOUCH_X_MIN = 145
;	-D ADATOUCH_X_MAX = 905
;	-D ADATOUCH_Y_MIN = 937
;	-D ADATOUCH_Y_MAX = 165

[env:Teensy-ILI9341_t3-NoTouch]
extends = mcu-Teensy
lib_deps =
	${disp-ILI9341_t3.lib_deps}
build_flags =
	${common.build_flags}
	${disp-ILI9341_t3.build_flags}
	-D USER_CONFIG_LOADED
	-D USER_CONFIG_INC_FILE
	-D USER_CONFIG_INC_FNAME=\"../configs/teensy-adagfx-ili9341_t3-NoTouch-audio.h\"

[env:Teensy-ILI9341_t3-XPT2046]
extends = mcu-Teensy
lib_deps =
	${disp-ILI9341_t3.lib_deps}
	${touch-XPT2046_ps.lib_deps}
build_flags =
	${common.build_flags}
	${disp-ILI9341_t3.build_flags}
	${touch-XPT2046_ps.build_flags}
	-D USER_CONFIG_LOADED
	-D USER_CONFIG_INC_FILE
	-D USER_CONFIG_INC_FNAME=\"../configs/teensy-adagfx-ili9341_t3-xpt2046-audio.h\"


[env:ESP32-TFT_eSPI-STMPE610]
extends = mcu-ESP32
lib_deps =
	${disp-TFT_eSPI.lib_deps}
	${touch-STMPE610.lib_deps}
build_flags =
	${common.build_flags}
	${disp-TFT_eSPI.build_flags}
	${touch-STMPE610.build_flags}
	-D USER_CONFIG_LOADED=1
	-D USER_CONFIG_INC_FILE=1
	-D USER_CONFIG_INC_FNAME=\"../configs/esp-shld-adafruit_24_feather_touch-espi.h\"

[env:M5Stack-M5Stack-NoTouch]
extends = mcu-M5Stack
lib_deps =
	${disp-M5Stack.lib_deps}
build_flags =
	${common.build_flags}
	${disp-M5Stack.build_flags}
	-D USER_CONFIG_LOADED=1
	-D USER_CONFIG_INC_FILE=1
	-D USER_CONFIG_INC_FNAME=\"../configs/esp-shld-m5stack.h\"

; ---------------------------------------------------------
; PlatformIO Custom GUIslice Environment
;
; - Instead of using a GUIslice config file directly, an
;   alternative approach is to define all of the GUIslice
;   config settings here in a custom environment.
; - The settings here match the same ones found in the
;   GUIslice config. To convert between the formats:
;
;   GUIslice config          platformio config
;   -----------------------  --------------------
;   #define <PARAM>          -D <PARAM>
;   #define <PARAM> <VALUE>  -D <PARAM>=<VALUE>
;
; ---------------------------------------------------------

[env:CustomConfig]
; Define your MCU, Display Driver and Touch Driver here
extends = mcu-Arduino
lib_deps =
	${disp-ILI9341.lib_deps}
	${touch-STMPE610.lib_deps}
build_flags =
	${common.build_flags}
	${disp-ILI9341.build_flags}
	${touch-STMPE610.build_flags}
; Specify your user config details here
; Example from /configs/ard-shld-adafruit_28_res.h
	-D USER_CONFIG_LOADED
	-D DRV_DISP_ADAGFX
	-D DRV_DISP_ADAGFX_ILI9341
	-D DRV_TOUCH_ADA_STMPE610
	-D ADAGFX_PIN_CS=10
	-D ADAGFX_PIN_DC=9
	-D ADAGFX_PIN_RST=0
	-D ADAGFX_SPI_HW=1
	-D ADAGFX_PIN_MOSI=11
	-D ADAGFX_PIN_MISO=12
	-D ADAGFX_PIN_CLK=13
	-D ADAGFX_PIN_SDCS=4
	-D GSLC_ROTATE=1
	-D ADATOUCH_I2C_HW=0
	-D ADATOUCH_SPI_HW=1
	-D ADATOUCH_SPI_SW=0
	-D ADATOUCH_I2C_ADDR=0x41
	-D ADATOUCH_PIN_CS=8
	-D ADATOUCH_X_MIN=244
	-D ADATOUCH_X_MAX=3858
	-D ADATOUCH_Y_MIN=141
	-D ADATOUCH_Y_MAX=3717
	-D ADATOUCH_REMAP_YX=0
	-D DEBUG_ERR=1
	-D GSLC_FEATURE_COMPOUND=0
	-D GSLC_FEATURE_XTEXTBOX_EMBED=0
	-D GSLC_FEATURE_INPUT=0
	-D GSLC_SD_EN=0
	-D GSLC_TOUCH_MAX_EVT=1
	-D GSLC_SD_BUFFPIXEL=50
	-D GSLC_CLIP_EN=1
	-D GSLC_BMP_TRANS_EN=1
	-D GSLC_BMP_TRANS_RGB=0xFF,0x00,0xFF
	-D GSLC_USE_FLOAT=0
	-D GSLC_DEV_TOUCH=\"\"
	-D GSLC_USE_PROGMEM=1
	-D GSLC_LOCAL_STR=0
	-D GSLC_LOCAL_STR_LEN=30
; ...