Files
waveshare-panel/waveshare-test.yaml
T

260 lines
5.8 KiB
YAML
Raw Normal View History

# Andrew Villeneuve 2026/05
# Waveshare 2.9inch Touch ePaper HAT integration demo
#
# Platform: https://www.waveshare.com/2.9inch-Touch-e-Paper-HAT.htm
#
# Pin mappings
# ---
# |Function |ESP Pin |HAT Pin |Wire |
# |--- |--- |--- |--- |
# |5V |VIN |Pin2/5V |Red |
# |GND |GND |Pin6/GND |Blk |
2026-05-06 15:35:01 -07:00
# |Display SCLK |GPIO18 |Pin23/GPIO11/SPI0_SCLK |Blue |
# |Display MOSI |GPIO23 |Pin19/GPIO10/SPI0_MOSI |Green |
# |Display CS |GPIO19 |Pin24/GPIO8/SPI0_CE0 |Mgnta |
2026-05-06 15:35:01 -07:00
# |Display DC |GPIO17 |Pin22/GPIO25 |White |
# |Display Busy |GPIO4 |Pin24/GPIO24 |Brown |
# |Display RST |GPIO5 |Pin11/GPIO17/SPI1_CE1 |Orange |
2026-05-06 15:35:01 -07:00
# |Touch SDA |GPIO21 |Pin3/GPIO2/I2C1_SDA |Gray |
# |Touch SCL |GPIO22 |Pin5/GPIO3/I2C1_SCL |Purple |
2026-05-07 16:28:08 -07:00
# |Touch RST |GPIO15 |Pin13/GPIO27 |Blue |
# |Touch INT |GPIO16 |Pin15/GPIO22 |White |
#
# Exposed Entities
# ---
#
### Boilerplate ###
esphome:
name: waveshare-epaper-test
esp32:
board: nodemcu-32s
framework:
type: esp-idf
# Enable logging
logger:
level: DEBUG
# Enable Home Assistant API
api:
encryption:
key: !secret enckey
ota:
- platform: esphome
password: !secret apipw
wifi:
ssid: !secret wifi_ssid
password: !secret wappw
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: ${fallbackssid}
password: !secret hotspotpw
captive_portal:
### Setup Interfaces ###
# For the display
spi:
2026-05-06 15:35:01 -07:00
clk_pin: GPIO18
mosi_pin: GPIO23
# For the touchscreen
2026-05-06 15:35:01 -07:00
i2c:
2026-05-07 16:28:08 -07:00
id: i2c_bus
2026-05-06 15:35:01 -07:00
sda: GPIO21
scl: GPIO22
scan: false
2026-05-07 16:28:08 -07:00
touchscreen:
platform: icnt86x
id: touchscreen0
address: 0x48
reset_pin: GPIO15
update_interval: 50ms
calibration:
x_min: 0
x_max: 295
y_min: 0
y_max: 127
transform:
mirror_x: true
mirror_y: true
### Okay, now the Good Stuff ###
# Load some fonts for the display renderer (we don't neeed these with LVGL)
font:
- file: "FreeSans.ttf"
id: font1
size: 26
bpp: 2
- file: "FreeSans.ttf"
id: headerfont
size: 80
- file: "FreeSans.ttf"
id: console
size: 30
# Pull in some icons from the material design library
image:
2026-05-06 15:35:01 -07:00
defaults:
transparency: chroma_key
invert_alpha: false
resize: 54x54
binary:
- file: "mdi:home-lock-open"
id: home_lock_open
2026-05-06 15:35:01 -07:00
- file: "mdi:home-lock"
id: home_lock
# Force a full display refresh when we press the "boot" button on the devboard
binary_sensor:
- platform: gpio
pin:
number: GPIO0
mode:
input: true
pullup: true
inverted: true
id: boot_button
internal: true
2026-05-07 16:28:08 -07:00
on_click:
then:
- component.update: lvgl0
- delay: 1s
- component.update: display0
display:
- platform: waveshare_epaper_2bit
id: display0
cs_pin: GPIO19
2026-05-06 15:35:01 -07:00
dc_pin: GPIO17
busy_pin: GPIO4
reset_pin: GPIO5
model: 2.90inv2-r2-2bpp
full_update_every: 30
rotation: 270°
auto_clear_enabled: false
update_interval: never
# show_test_card: true
# lambda: |-
# it.print(0, 0, id(headerfont), "Bleat!");
lvgl:
- id: lvgl0
displays:
- display0
2026-05-07 16:28:08 -07:00
touchscreens:
- touchscreen0
# on_draw_end:
# - component.update: display0
bg_color: 0xFFFFFF
# Black: 0x000000
# Dark Grey: 0x555555
# Light Grey: 0xAAAAAA
# White: 0xFFFFFF
theme:
label:
text_color: 0x000000
2026-05-06 15:35:01 -07:00
button:
bg_color: 0xAAAAAA
text_color: 0xFFFFFF
height: 64
width: 64
pad_all: 0
border_width: 5
border_color: 0xFFFFFF
obj:
bg_color: 0xFFFFFF
widgets:
- label:
2026-05-07 16:28:08 -07:00
text: 'Test 2bpp 1636'
align: TOP_LEFT
text_font: font1
2026-05-06 15:35:01 -07:00
- button:
id: button0
align: TOP_RIGHT
2026-05-07 16:28:08 -07:00
on_click:
- logger.log: "button0 clicked (unlock)"
2026-05-06 15:35:01 -07:00
widgets:
- image:
src: home_lock_open
outline_width: 1
- button:
id: button1
align: BOTTOM_RIGHT
2026-05-07 16:28:08 -07:00
on_click:
- logger.log: "button1 clicked (lock)"
2026-05-06 15:35:01 -07:00
widgets:
- image:
src: home_lock
outline_width: 1
2026-05-07 17:06:20 -07:00
- slider:
id: slider0
align: LEFT_MID
width: 180
height: 16
min_value: 0
max_value: 100
value: 50
on_value:
- logger.log:
format: "Slider: %.0f"
args: ['x']
- component.update: lvgl0
- lambda: id(display0).display_partial();
# - label:
# text: "0xFFFFFF"
# text_color: 0xFFFFFF
# x: 0
# y: 15
# - label:
# text: "0xAAAAAA"
# text_color: 0xAAAAAA
# x: 0
# y: 30
# - label:
# text: "0x555555"
# text_color: 0x555555
# x: 0
# y: 45
# - label:
# text: "0x000000"
# text_color: 0x000000
# x: 0
# y: 60
2026-05-06 15:35:01 -07:00
# - obj:
# align: BOTTOM_LEFT
# width: 33%
# height: 30%
# bg_color: 0x000000 #Black
# - obj:
# align: BOTTOM_MID
# width: 33%
# height: 30%
# bg_color: 0x555555 #Dark Grey
# - obj:
# align: BOTTOM_RIGHT
# width: 33%
# height: 30%
# bg_color: 0xAAAAAA #Light Grey
# - obj:
# align: TOP_RIGHT
# width: 33%
# height: 30%
# bg_color: 0xFFFFFF #White
# - obj:
# align: LEFT_MID
# width: 66%
# height: 30%
# bg_color: 0x000000
# bg_grad_color: 0xFFFFFF
# bg_grad_dir: HOR