Last active
April 16, 2025 20:07
-
-
Save GuySie/5351c5184d93089188b02c2f10da9809 to your computer and use it in GitHub Desktop.
CYD LVGL test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ============================================================ | |
# Edit substitutions for your naming, devices, and passwords here. | |
substitutions: | |
name: cyd-lvgl-test | |
friendly_name: "CYD LVGL Test" | |
api_key: !secret api_key | |
ota_password: !secret ota_password | |
# ap_password: !secret ap_password | |
wifi_ssid: !secret wifi_ssid | |
wifi_password: !secret wifi_password | |
# ============================================================ | |
# An experiment by Guy Sie | |
# - [GitHub](https://github.com/guysie) | |
# - [Twitter](https://twitter.com/guysie) | |
# | |
# Based on example ESPHome code by Jonny Bergdahl | |
# - [GitHub](https://github.com/jonnybergdahl) | |
# - [Twitter](https://twitter.com/jonnybergdahl) | |
# - [YouTube](https://www.youtube.com/jonnybergdahl) | |
# ============================================================ | |
# ESPHome YAML start | |
# | |
esphome: | |
name: ${name} | |
friendly_name: ${friendly_name} | |
esp32: | |
board: esp32dev | |
framework: | |
type: esp-idf | |
# Enable logging | |
logger: | |
psram: | |
#http_request: | |
# verify_ssl: false | |
# buffer_size_rx: 16 | |
# buffer_size_tx: 16 | |
# Enable Home Assistant API | |
api: | |
encryption: | |
key: ${api_key} | |
ota: | |
platform: esphome | |
password: ${ota_password} | |
wifi: | |
ssid: ${wifi_ssid} | |
password: ${wifi_password} | |
# Enable fallback hotspot (captive portal) in case wifi connection fails | |
ap: | |
ssid: "${name}" | |
password: ${ap_password} | |
#captive_portal: | |
# ============================================================ | |
# ESPHome Display related setup | |
# | |
# Create color scheme | |
color: | |
- id: white | |
hex: ffffff | |
# ============================================================ | |
# Home Assistant related setup | |
# | |
light: | |
# Set up display backlight | |
- platform: monochromatic | |
output: backlight_pwm | |
name: Display Backlight | |
id: backlight | |
restore_mode: ALWAYS_ON | |
# Set up LED on the back and turn it off by default | |
- platform: rgb | |
name: RGB | |
id: led | |
red: led_red | |
green: led_green | |
blue: led_blue | |
restore_mode: ALWAYS_OFF | |
sensor: | |
# Reports the WiFi signal strength/RSSI in dB | |
- platform: wifi_signal | |
name: "WiFi Signal dB" | |
id: wifi_signal_db | |
update_interval: 60s | |
entity_category: "diagnostic" | |
# Reports the WiFi signal strength in % | |
- platform: copy | |
source_id: wifi_signal_db | |
name: "WiFi Signal Percent" | |
filters: | |
- lambda: return min(max(2 * (x + 100.0), 0.0), 100.0); | |
unit_of_measurement: "Signal %" | |
entity_category: "diagnostic" | |
# ============================================================ | |
# Hardware related setup | |
# | |
# Setup SPI for the display. The ESP32-2432S028R uses separate SPI buses for display and touch | |
spi: | |
- id: tft | |
clk_pin: GPIO14 | |
mosi_pin: GPIO13 | |
miso_pin: GPIO12 | |
- id: touch | |
clk_pin: GPIO25 | |
mosi_pin: GPIO32 | |
miso_pin: GPIO39 | |
# Setup board power switches | |
switch: | |
- platform: restart | |
name: "$friendly_name restart" | |
- platform: shutdown | |
name: "$friendly_name shutdown" | |
- platform: safe_mode | |
name: "$friendly_name restart (Safe Mode)" | |
# Setup a pin to control the backlight | |
output: | |
- platform: ledc | |
pin: GPIO21 | |
id: backlight_pwm | |
# Setup channels for the red/green/blue of the LED on the back | |
- platform: ledc | |
pin: GPIO4 | |
id: led_red | |
inverted: true | |
- platform: ledc | |
pin: GPIO16 | |
id: led_green | |
inverted: true | |
- platform: ledc | |
pin: GPIO17 | |
id: led_blue | |
inverted: true | |
# Set up sound | |
# TO DO: If speaker added to JST, we can use it to provide audio feedback on button presses. | |
#i2s_audio: | |
# i2s_lrclk_pin: GPIO25 | |
# i2s_bclk_pin: GPIO26 | |
#media_player: | |
# - platform: i2s_audio | |
# name: ESPHome I2S Media Player | |
# dac_type: internal | |
# mode: stereo | |
# Setup the ili9xxx platform | |
# | |
# Display is used as 240x320 by default so we rotate it to 90° | |
# | |
# We print date and time wth the strftime() function, see the ESPHome documentation to | |
# format date and atime to your locale. | |
display: | |
- platform: ili9xxx | |
id: cyd | |
model: ILI9341 | |
spi_id: tft | |
cs_pin: GPIO15 | |
dc_pin: GPIO2 | |
color_palette: 8BIT | |
transform: | |
mirror_x: false | |
mirror_y: false | |
swap_xy: true | |
color_order: bgr | |
invert_colors: false | |
dimensions: | |
height: 240 | |
width: 320 | |
auto_clear_enabled: false | |
update_interval: never | |
# show_test_card: true | |
# dimensions: | |
# width: 240 | |
# height: 320 | |
# rotation: 90 | |
# invert_colors: false # invert_colors is Required | |
# Draw interface for touchscreen button control, display of current and target temperature, and graph of current temperature | |
# Only show target temperature and buttons if thermostat is in heating mode | |
# Buttons change shading to look raised or sunken based on heating mode or binary sensor | |
# Set up the xpt2046 touch platform | |
touchscreen: | |
platform: xpt2046 | |
spi_id: touch | |
cs_pin: GPIO33 | |
interrupt_pin: GPIO36 | |
update_interval: 50ms | |
threshold: 400 | |
calibration: | |
x_min: 280 | |
x_max: 3860 | |
y_min: 340 | |
y_max: 3860 | |
transform: | |
swap_xy: true | |
# In some variants of the CYD swap_x_y and mirror_y must be TRUE | |
# mirror_x: false | |
# mirror_y: true | |
# swap_x_y: true | |
lvgl: | |
buffer_size: 25% | |
displays: | |
- cyd | |
# pages: | |
# - id: main_page | |
# widgets: | |
# - obj: # a properly placed coontainer object for all these controls | |
# align: CENTER | |
# width: 320 | |
# height: 240 | |
# x: 0 | |
# y: 0 | |
# bg_opa: TRANSP | |
# border_opa: TRANSP | |
# layout: # enable the FLEX layout for the children widgets | |
# type: FLEX | |
# flex_flow: COLUMN_WRAP # the order of the widgets starts top left | |
# flex_align_cross: START | |
# widgets: | |
# - image: | |
# id: albumart | |
# align: CENTER | |
# src: holdplace | |
# - label: | |
# id: title | |
# align: CENTER | |
# text: 'Media Title' | |
# - label: | |
# id: artist | |
# align: CENTER | |
# text: 'Media Artist' | |
# - label: | |
# id: album | |
# align: CENTER | |
# text: 'Media Album' | |
# - label: | |
# id: albumurl | |
# align: CENTER | |
# text: 'Media Cover URL' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment