[heltec_v4_r8_base] 
extends = esp32s3_base
board = heltec_v4_r8
board_check = true
board_build.partitions = default_16MB.csv
build_flags = 
  ${esp32s3_base.build_flags}
  -D HELTEC_V4_R8
  -D HAS_LORA_FEM=1
  -D BOARD_HAS_PSRAM
  -I variants/esp32s3/heltec_v4_r8
  -ULED_BUILTIN

[env:heltec-v4-r8-oled]
custom_meshtastic_hw_model = 132
custom_meshtastic_hw_model_slug = HELTEC_V4_R8
custom_meshtastic_architecture = esp32-s3
custom_meshtastic_actively_supported = true
custom_meshtastic_support_level = 1
custom_meshtastic_display_name = Heltec V4 R8
custom_meshtastic_images = heltec_v4_r8.svg
custom_meshtastic_tags = Heltec
custom_meshtastic_requires_dfu = true
custom_meshtastic_partition_scheme = 16MB

extends = heltec_v4_r8_base
build_flags = 
  ${heltec_v4_r8_base.build_flags}
  -D HELTEC_V4_R8_OLED
  -D USE_SSD1306 ; Heltec_v4_R8 has an SSD1315 display (compatible with SSD1306 driver)
  -D LED_POWER=46
  -D RESET_OLED=21
  -D I2C_SDA=17
  -D I2C_SCL=18

[env:heltec-v4-r8-tft]
custom_meshtastic_hw_model = 132
custom_meshtastic_hw_model_slug = HELTEC_V4_R8
custom_meshtastic_architecture = esp32-s3
custom_meshtastic_actively_supported = true
custom_meshtastic_support_level = 1
custom_meshtastic_display_name = Heltec V4 R8 TFT
custom_meshtastic_images = heltec_v4_r8_tft.svg
custom_meshtastic_tags = Heltec
custom_meshtastic_requires_dfu = true
custom_meshtastic_partition_scheme = 16MB

extends = heltec_v4_r8_base
build_flags = 
  ${heltec_v4_r8_base.build_flags} ;-Os
  -D HELTEC_V4_R8_TFT
  -D I2C_SDA=17
  -D I2C_SCL=18
  -D PIN_BUTTON2=46
  -D ALT_BUTTON_PIN=PIN_BUTTON2
  -D ALT_BUTTON_ACTIVE_LOW=false
  -D PIN_BUZZER=4
  -D USE_PIN_BUZZER=PIN_BUZZER
  -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 CONFIG_DISABLE_HAL_LOCKS=1
  -D INPUTDRIVER_BUTTON_TYPE=0
  -D HAS_SCREEN=1
  -D HAS_TFT=1
  -D RAM_SIZE=5120
  -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 LGFX_DRIVER=LGFX_HELTEC_V4_TFT
  -D GFX_DRIVER_INC=\"graphics/LGFX/LGFX_HELTEC_V4_TFT.h\"
  -D VIEW_240x320
  -D DISPLAY_SET_RESOLUTION
  -D DISPLAY_SIZE=240x320 ; portrait mode
  -D LGFX_SPI_3WIRE=false
  -D LGFX_PIN_SCK=16
  -D LGFX_PIN_MOSI=15
  -D LGFX_PIN_MISO=45
  -D LGFX_PIN_DC=48
  -D LGFX_PIN_CS=47
  -D LGFX_PIN_BL=44
  -D LGFX_PIN_RST=21
  -D CUSTOM_TOUCH_DRIVER
  -D TOUCH_SDA_PIN=I2C_SDA
  -D TOUCH_SCL_PIN=I2C_SCL
  -D TOUCH_INT_PIN=-1
  -D TOUCH_RST_PIN=-1
;base UI
  -D TFT_CS=LGFX_PIN_CS
  -D ST7789_CS=TFT_CS
  -D ST7789_RS=LGFX_PIN_DC
  -D ST7789_SDA=LGFX_PIN_MOSI
  -D ST7789_SCK=LGFX_PIN_SCK
  -D ST7789_RESET=LGFX_PIN_RST
  -D ST7789_MISO=LGFX_PIN_MISO
  -D ST7789_BUSY=-1
  -D ST7789_BL=LGFX_PIN_BL
  -D ST7789_SPI_HOST=SPI3_HOST
  -D TFT_BL=ST7789_BL
  -D SPI_FREQUENCY=75000000
  -D SPI_READ_FREQUENCY=SPI_FREQUENCY
  -D SPI_3_WIRE=false
  -D TFT_HEIGHT=320
  -D TFT_WIDTH=240
  -D TFT_OFFSET_X=0
  -D TFT_OFFSET_Y=0
  -D TFT_OFFSET_ROTATION=0
  -D SCREEN_ROTATE
  -D SCREEN_TRANSITION_FRAMERATE=5
  -D BRIGHTNESS_DEFAULT=130 ; Medium Low Brightness
  -D HAS_TOUCHSCREEN=1
  -D TOUCH_I2C_PORT=0
  -D TOUCH_SLAVE_ADDRESS=0x2E
  -D SCREEN_TOUCH_INT=TOUCH_INT_PIN
  -D SCREEN_TOUCH_RST=TOUCH_RST_PIN

; Have SPI interface SD card slot
  -D HAS_SDCARD
  -D SDCARD_USE_SPI1
  -D SDCARD_USER_SPI_BEGIN
  -D SPI_MOSI=LGFX_PIN_MOSI
  -D SPI_SCK=LGFX_PIN_SCK
  -D SPI_MISO=LGFX_PIN_MISO
  -D SPI_CS=3
  -D SDCARD_CS=SPI_CS
  -D SD_SPI_FREQUENCY=SPI_FREQUENCY

lib_deps = ${heltec_v4_r8_base.lib_deps}
  ${device-ui_base.lib_deps}
  # renovate: datasource=custom.pio depName=LovyanGFX packageName=lovyan03/library/LovyanGFX
  lovyan03/LovyanGFX@1.2.19
  # renovate: datasource=git-refs depName=Quency-D_chsc6x packageName=https://github.com/Quency-D/chsc6x gitBranch=master
  https://github.com/Quency-D/chsc6x/archive/3b2b6cebf3177b3e2c33d06e07909b0b10159516.zip