mirror of
https://github.com/esphome/esphome.git
synced 2026-10-13 17:52:51 +00:00
[mipi_rgb] Keep the init sequence in flash (#20090)
This commit is contained in:
@@ -9,6 +9,7 @@ here.
|
||||
|
||||
from collections.abc import Callable
|
||||
from pathlib import Path
|
||||
import re
|
||||
|
||||
# A model with no reset_pin default: SWRESET ({1, 0}) is prepended ahead of the
|
||||
# inherited ST7701S reset_delay ({50, 255}).
|
||||
@@ -54,6 +55,18 @@ display:
|
||||
"""
|
||||
|
||||
|
||||
def _init_sequence(main_cpp: str, display_id: str) -> str:
|
||||
"""Return the shared PROGMEM init sequence table passed to a display, as rendered."""
|
||||
match = re.search(rf"{display_id}->set_init_sequence\((\w+), \d+\);", main_cpp)
|
||||
assert match is not None
|
||||
table = re.search(
|
||||
rf"static constexpr uint8_t {match.group(1)}\[\] PROGMEM = (\{{[^;]*\}});",
|
||||
main_cpp,
|
||||
)
|
||||
assert table is not None
|
||||
return table.group(1)
|
||||
|
||||
|
||||
def test_swreset_and_reset_delay_without_reset_pin(
|
||||
generate_main: Callable[[str | Path], str],
|
||||
tmp_path: Path,
|
||||
@@ -64,7 +77,7 @@ def test_swreset_and_reset_delay_without_reset_pin(
|
||||
|
||||
main_cpp = generate_main(yaml_file)
|
||||
|
||||
assert "no_reset_display->set_init_sequence({1, 0, 50, 255," in main_cpp
|
||||
assert _init_sequence(main_cpp, "no_reset_display").startswith("{1, 0, 50, 255,")
|
||||
|
||||
|
||||
def test_reset_delay_only_with_reset_pin(
|
||||
@@ -77,5 +90,4 @@ def test_reset_delay_only_with_reset_pin(
|
||||
|
||||
main_cpp = generate_main(yaml_file)
|
||||
|
||||
assert "has_reset_display->set_init_sequence({50, 255," in main_cpp
|
||||
assert "has_reset_display->set_init_sequence({1, 0," not in main_cpp
|
||||
assert _init_sequence(main_cpp, "has_reset_display").startswith("{50, 255,")
|
||||
|
||||
Reference in New Issue
Block a user