[lvgl] Add paused option to suppress updates on boot (#16973)

Co-authored-by: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com>
This commit is contained in:
Clyde Stubbs
2026-07-07 14:50:36 +00:00
committed by GitHub
co-authored by Jonathan Swoboda
parent 76ee3fe887
commit 7f0e826c32
6 changed files with 93 additions and 0 deletions
@@ -0,0 +1,26 @@
esphome:
name: test-not-paused
esp32:
board: lolin_c3_mini
spi:
mosi_pin:
number: GPIO2
ignore_strapping_warning: true
clk_pin: GPIO1
display:
- platform: mipi_spi
data_rate: 20MHz
model: st7735
cs_pin:
number: GPIO8
ignore_strapping_warning: true
dc_pin:
number: GPIO3
lvgl:
widgets:
- obj:
id: root_obj
@@ -0,0 +1,27 @@
esphome:
name: test-paused
esp32:
board: lolin_c3_mini
spi:
mosi_pin:
number: GPIO2
ignore_strapping_warning: true
clk_pin: GPIO1
display:
- platform: mipi_spi
data_rate: 20MHz
model: st7735
cs_pin:
number: GPIO8
ignore_strapping_warning: true
dc_pin:
number: GPIO3
lvgl:
paused: true
widgets:
- obj:
id: root_obj
+35
View File
@@ -0,0 +1,35 @@
"""Tests for the LVGL ``paused`` option code generation."""
from __future__ import annotations
import re
_SET_PAUSED_RE = re.compile(r"->set_paused\((.+?)\);")
def _extract_set_paused(main_cpp: str) -> list[str]:
"""Return the normalised argument text of every set_paused() call found.
Whitespace within and around the arguments is collapsed so unrelated
code-generation formatting changes don't break these tests.
"""
return [" ".join(m.group(1).split()) for m in _SET_PAUSED_RE.finditer(main_cpp)]
class TestPausedCodeGeneration:
"""Verify that the ``paused`` option drives the set_paused() call."""
def test_paused_true_generates_set_paused(
self, generate_main, component_config_path
):
"""``paused: true`` emits a set_paused(true, false) call."""
main_cpp = generate_main(component_config_path("paused.yaml"))
calls = _extract_set_paused(main_cpp)
assert calls == ["true, false"]
def test_paused_default_omits_set_paused(
self, generate_main, component_config_path
):
"""Without ``paused`` (default false) no set_paused call is generated."""
main_cpp = generate_main(component_config_path("not_paused.yaml"))
assert _extract_set_paused(main_cpp) == []
+1
View File
@@ -35,6 +35,7 @@ lvgl:
rotation: 90
log_level: debug
resume_on_input: true
paused: true
update_when_display_idle: true
refresh_interval: 30ms
on_pause: