# Shared hardware/network boilerplate for the lvgl_clock example_*.yaml
# configs, on a Seeed Studio XIAO ESP32-C3. Same contents as
# common_base_esp32_s3_xiao.yaml - only the board and the pin substitutions
# differ - so an example swaps between them by changing the `base:` include.
#
# NO PSRAM. The C3 has ~400 KB of SRAM and no external RAM interface at all,
# so the clock's canvas (width x height x 2 bytes) has to fit in internal RAM
# alongside LVGL's own draw buffer. A 240x240 face is 115 KB, so keep
# `lvgl: buffer_size:` small (25% or less) and don't use `transparent:`
# (ARGB8888 doubles the canvas). See the memory debug sensors below.
#
# Pins are written as the XIAO's silkscreen labels (ESPHome knows them for
# this board): D8 = GPIO8, D9 = GPIO9, D10 = GPIO10, D1 = GPIO3, D2 = GPIO4,
# D3 = GPIO5. CS/DC match the Seeed Round Display shield's fixed wiring.

substitutions:
  # Pins for the SPI bus used to drive the display
  clk_pin: "D8"     # GPIO8,  SCK
  mosi_pin: "D10"   # GPIO10, MOSI
  miso_pin: "D9"    # GPIO9,  MISO - also the C3's BOOT strapping pin
  # Pins for the display itself
  reset_pin: "D2"   # GPIO4 - unused by the round display (it has no reset line)
  cs_pin: "D1"      # GPIO3
  dc_pin: "D3"      # GPIO5

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

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 -----------------------------------------------------------
# Far more important here than on the S3: with no PSRAM the canvas competes
# with WiFi and LVGL for the same ~400 KB. `block` (largest contiguous chunk)
# is what a canvas allocation actually needs - it can fail while `free` still
# looks healthy.
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"
    loop_time:
      name: "Loop Time"
