# Shared hardware/network boilerplate for the lvgl_clock example_*.yaml
# configs, on a Seeed Studio XIAO ESP32-S3 (8 MB PSRAM). Same contents as
# common_base_esp32_s3_devkit.yaml - only the board and the pin substitutions
# differ - so an example swaps between them by changing the `base:` include.
#
# Pins are written as the XIAO's silkscreen labels (ESPHome knows them for
# this board): D8 = GPIO7, D9 = GPIO8, D10 = GPIO9, D1 = GPIO2, D2 = GPIO3,
# D3 = GPIO4. CS/DC match the Seeed Round Display shield's fixed wiring, so
# that panel needs no overrides.

substitutions:
  # Pins for the SPI bus used to drive the display
  clk_pin: "D8"     # GPIO7,  SCK
  mosi_pin: "D10"   # GPIO9,  MOSI
  miso_pin: "D9"    # GPIO8,  MISO
  # Pins for the display itself
  reset_pin: "D7"   # GPIO6,  RESET
  cs_pin: "D1"      # GPIO2
  dc_pin: "D3"      # GPIO4

esp32:
  board: seeed_xiao_esp32s3
  framework:
    type: esp-idf

# The XIAO ESP32-S3 carries 8 MB of octal PSRAM - required for LVGL at the
# larger panel sizes.
psram:
  mode: octal
  speed: 80MHz

logger:
wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

api:
  encryption:
    key: !secret api_key
ota:
  - platform: esphome
    password: !secret ota_password

external_components:
  - source: ../components
    components: [lvgl_clock]

time:
  - platform: sntp
    id: clock_time
    timezone: "CET-1CEST,M3.5.0,M10.5.0/3"

# marker only - enables the lvgl_clock widget, takes no options itself.
lvgl_clock:

# Shared colour palette for the lvgl_clock example_*.yaml configs.

color:
  - id: cc_hands
    red: 100%
    green: 100%
    blue: 100%
  - id: cc_bg
    red: 0%
    green: 0%
    blue: 0%
  - id: cc_faces  # unlit "ghost" segments / little-clock faces
    red: 12%
    green: 12%
    blue: 14%

# --- Memory debug -----------------------------------------------------------
# The clock's canvas is the biggest single allocation in this config (a 240x240
# ARGB8888 face is ~230 KB, RGB565 ~115 KB) and LVGL wants its own buffers on
# top, so it's worth watching the heap. `free` is what's left in internal RAM,
# `block` the largest contiguous chunk - a canvas fails to allocate when
# `block` drops below its size even if `free` looks fine. `psram` is the
# separate 8 MB pool the big buffers come from.
debug:
  update_interval: 30s

sensor:
  - platform: debug
    free:
      name: "Heap Free"
    block:
      name: "Heap Max Block"
    min_free:
      name: "Heap Min Free"
    fragmentation:
      name: "Heap Fragmentation"
    psram:
      name: "PSRAM Free"
    loop_time:
      name: "Loop Time"
