[crowpanel_base]
extends = esp32s3_base
board = crowpanel
board_check = true
upload_protocol = esptool
board_build.partitions = default_16MB.csv ; must be here for some reason, board.json is not enough !?
build_flags = ${esp32s3_base.build_flags} -Os
  -I variants/elecrow_panel
  -D ELECROW_PANEL
  -D CONFIG_ARDUHAL_LOG_COLORS
  -D RADIOLIB_DEBUG_SPI=0
  -D RADIOLIB_DEBUG_PROTOCOL=0
  -D RADIOLIB_DEBUG_BASIC=0
  -D RADIOLIB_VERBOSE_ASSERT=0
  -D RADIOLIB_SPI_PARANOID=0
  -D MESHTASTIC_EXCLUDE_CANNEDMESSAGES=1
  -D MESHTASTIC_EXCLUDE_INPUTBROKER=1
  -D MESHTASTIC_EXCLUDE_WEBSERVER=1
  -D MESHTASTIC_EXCLUDE_SERIAL=1
  -D MESHTASTIC_EXCLUDE_SOCKETAPI=1
  -D MESHTASTIC_EXCLUDE_SCREEN=1
  -D MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR=1
  -D HAS_TELEMETRY=0
  -D CONFIG_DISABLE_HAL_LOCKS=1
  -D USE_PIN_BUZZER
  -D HAS_SCREEN=0
  -D HAS_TFT=1
  -D RAM_SIZE=6144
  -D LV_LVGL_H_INCLUDE_SIMPLE
  -D LV_CONF_INCLUDE_SIMPLE
  -D LV_COMP_CONF_INCLUDE_SIMPLE
  -D LV_USE_SYSMON=0
  -D LV_USE_PROFILER=0
  -D LV_USE_PERF_MONITOR=0
  -D LV_USE_MEM_MONITOR=0
  -D LV_USE_LOG=0
  -D LV_BUILD_TEST=0
  -D USE_LOG_DEBUG
  -D LOG_DEBUG_INC=\"DebugConfiguration.h\"
  -D USE_PACKET_API
  -D HAS_SDCARD
  -D SD_SPI_FREQUENCY=75000000

lib_deps = ${esp32s3_base.lib_deps}
  ${device-ui_base.lib_deps}
  earlephilhower/ESP8266Audio@1.9.9
  earlephilhower/ESP8266SAM@1.0.1
  lovyan03/LovyanGFX@1.2.0 ; note: v1.2.7 breaks the elecrow 7" display functionality
  hideakitai/TCA9534@0.1.1

[crowpanel_small] ; 2.4, 2.8, 3.5 inch
extends = crowpanel_base
build_flags =
  ${crowpanel_base.build_flags}
  -D CROW_SELECT=1
  -D SDCARD_USE_SOFT_SPI
  -D SDCARD_CS=7
  -D SPI_DRIVER_SELECT=2
  -D LGFX_DRIVER_TEMPLATE
  -D LGFX_DRIVER=LGFX_GENERIC
  -D GFX_DRIVER_INC=\"graphics/LGFX/LGFX_GENERIC.h\"
  -D VIEW_320x240
  -D MAP_FULL_REDRAW

[crowpanel_large] ; 4.3, 5.0, 7.0 inch
extends = crowpanel_base
build_flags =
  ${crowpanel_base.build_flags}
  -D CROW_SELECT=2
  -D SDCARD_CS=7
  -D LGFX_DRIVER=LGFX_ELECROW70
  -D GFX_DRIVER_INC=\"graphics/LGFX/LGFX_ELECROW70.h\"
  -D DISPLAY_SET_RESOLUTION

[env:elecrow-adv-24-28-tft]
extends = crowpanel_small
build_flags =
  ${crowpanel_small.build_flags}
  -D SPI_FREQUENCY=80000000
  -D LGFX_SCREEN_WIDTH=240
  -D LGFX_SCREEN_HEIGHT=320
  -D LGFX_PANEL=ST7789
  -D LGFX_ROTATION=1
  -D LGFX_CFG_HOST=SPI2_HOST
  -D LGFX_PIN_SCK=42
  -D LGFX_PIN_MOSI=39
  -D LGFX_PIN_DC=41
  -D LGFX_PIN_CS=40
  -D LGFX_PIN_BL=38
  -D LGFX_TOUCH=FT5x06
  -D LGFX_TOUCH_I2C_ADDR=0x38
  -D LGFX_TOUCH_I2C_SDA=15
  -D LGFX_TOUCH_I2C_SCL=16
  -D LGFX_TOUCH_INT=47
  -D LGFX_TOUCH_RST=48
  -D LGFX_TOUCH_ROTATION=0

[env:elecrow-adv-35-tft]
extends = crowpanel_small
build_flags =
  ${crowpanel_small.build_flags}
  -D LV_CACHE_DEF_SIZE=2097152
  -D SPI_FREQUENCY=60000000
  -D LGFX_SCREEN_WIDTH=320
  -D LGFX_SCREEN_HEIGHT=480
  -D LGFX_PANEL=ILI9488
  -D LGFX_ROTATION=0
  -D LGFX_CFG_HOST=SPI2_HOST
  -D LGFX_PIN_SCK=42
  -D LGFX_PIN_MOSI=39
  -D LGFX_PIN_DC=41
  -D LGFX_PIN_CS=40
  -D LGFX_PIN_BL=38
  -D LGFX_TOUCH=GT911
  -D LGFX_TOUCH_I2C_ADDR=0x5D
  -D LGFX_TOUCH_I2C_SDA=15
  -D LGFX_TOUCH_I2C_SCL=16
  -D LGFX_TOUCH_INT=47
  -D LGFX_TOUCH_RST=48
  -D LGFX_TOUCH_ROTATION=0
  -D DISPLAY_SET_RESOLUTION

; 4.3, 5.0, 7.0 inch 800x480 IPS (V1)
[env:elecrow-adv1-43-50-70-tft]
extends = crowpanel_large
build_flags =
  ${crowpanel_large.build_flags}
  -D VIEW_320x240
