mirror of
https://github.com/esphome/esphome.git
synced 2026-05-31 07:57:40 +08:00
[mipi_spi] Run spi final validation (#15418)
CI / Create common environment (push) Has been cancelled
CI / Check pylint (push) Has been cancelled
CI / Run script/ci-custom (push) Has been cancelled
CI / Run pytest (macOS-latest, 3.11) (push) Has been cancelled
CI / Run pytest (macOS-latest, 3.14) (push) Has been cancelled
CI / Run pytest (ubuntu-latest, 3.11) (push) Has been cancelled
CI / Run pytest (ubuntu-latest, 3.13) (push) Has been cancelled
CI / Run pytest (ubuntu-latest, 3.14) (push) Has been cancelled
CI / Run pytest (windows-latest, 3.11) (push) Has been cancelled
CI / Run pytest (windows-latest, 3.14) (push) Has been cancelled
CI / Determine which jobs to run (push) Has been cancelled
CI / Run integration tests (push) Has been cancelled
CI / Run C++ unit tests (push) Has been cancelled
CI / Run CodSpeed benchmarks (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 IDF (push) Has been cancelled
CI / Run script/clang-tidy for ESP8266 (push) Has been cancelled
CI / Run script/clang-tidy for ZEPHYR (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 1/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 2/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 3/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 4/4 (push) Has been cancelled
CI / Test components batch (${{ matrix.components }}) (push) Has been cancelled
CI / pre-commit.ci lite (push) Has been cancelled
CI / Build target branch for memory impact (push) Has been cancelled
CI / Build PR branch for memory impact (push) Has been cancelled
CI / Comment memory impact (push) Has been cancelled
CI / CI Status (push) Has been cancelled
CI / Create common environment (push) Has been cancelled
CI / Check pylint (push) Has been cancelled
CI / Run script/ci-custom (push) Has been cancelled
CI / Run pytest (macOS-latest, 3.11) (push) Has been cancelled
CI / Run pytest (macOS-latest, 3.14) (push) Has been cancelled
CI / Run pytest (ubuntu-latest, 3.11) (push) Has been cancelled
CI / Run pytest (ubuntu-latest, 3.13) (push) Has been cancelled
CI / Run pytest (ubuntu-latest, 3.14) (push) Has been cancelled
CI / Run pytest (windows-latest, 3.11) (push) Has been cancelled
CI / Run pytest (windows-latest, 3.14) (push) Has been cancelled
CI / Determine which jobs to run (push) Has been cancelled
CI / Run integration tests (push) Has been cancelled
CI / Run C++ unit tests (push) Has been cancelled
CI / Run CodSpeed benchmarks (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 IDF (push) Has been cancelled
CI / Run script/clang-tidy for ESP8266 (push) Has been cancelled
CI / Run script/clang-tidy for ZEPHYR (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 1/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 2/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 3/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 4/4 (push) Has been cancelled
CI / Test components batch (${{ matrix.components }}) (push) Has been cancelled
CI / pre-commit.ci lite (push) Has been cancelled
CI / Build target branch for memory impact (push) Has been cancelled
CI / Build PR branch for memory impact (push) Has been cancelled
CI / Comment memory impact (push) Has been cancelled
CI / CI Status (push) Has been cancelled
Co-authored-by: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com>
This commit is contained in:
@@ -279,6 +279,10 @@ def _final_validate(config):
|
|||||||
|
|
||||||
from esphome.components.lvgl import DOMAIN as LVGL_DOMAIN
|
from esphome.components.lvgl import DOMAIN as LVGL_DOMAIN
|
||||||
|
|
||||||
|
if config[CONF_BUS_MODE] == TYPE_SINGLE:
|
||||||
|
spi.final_validate_device_schema(DOMAIN, require_miso=False, require_mosi=True)(
|
||||||
|
config
|
||||||
|
)
|
||||||
if not requires_buffer(config) and LVGL_DOMAIN not in global_config:
|
if not requires_buffer(config) and LVGL_DOMAIN not in global_config:
|
||||||
# If no drawing methods are configured, and LVGL is not enabled, show a test card
|
# If no drawing methods are configured, and LVGL is not enabled, show a test card
|
||||||
config[CONF_SHOW_TEST_CARD] = True
|
config[CONF_SHOW_TEST_CARD] = True
|
||||||
@@ -286,7 +290,7 @@ def _final_validate(config):
|
|||||||
if PSRAM_DOMAIN not in global_config and CONF_BUFFER_SIZE not in config:
|
if PSRAM_DOMAIN not in global_config and CONF_BUFFER_SIZE not in config:
|
||||||
# If PSRAM is not enabled, choose a small buffer size by default
|
# If PSRAM is not enabled, choose a small buffer size by default
|
||||||
if not requires_buffer(config):
|
if not requires_buffer(config):
|
||||||
return config # No buffer needed, so no need to set a buffer size
|
return # No need to pick a size
|
||||||
color_depth = get_color_depth(config)
|
color_depth = get_color_depth(config)
|
||||||
frac = denominator(config)
|
frac = denominator(config)
|
||||||
width, height, _offset_width, _offset_height = model.get_dimensions(config)
|
width, height, _offset_width, _offset_height = model.get_dimensions(config)
|
||||||
@@ -298,8 +302,6 @@ def _final_validate(config):
|
|||||||
x for x in range(2, 17) if fraction >= 1 / x
|
x for x in range(2, 17) if fraction >= 1 / x
|
||||||
)
|
)
|
||||||
|
|
||||||
return config
|
|
||||||
|
|
||||||
|
|
||||||
FINAL_VALIDATE_SCHEMA = _final_validate
|
FINAL_VALIDATE_SCHEMA = _final_validate
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
"""Tests for mpip_spi configuration validation."""
|
"""Tests for mpip_spi configuration validation."""
|
||||||
|
|
||||||
from collections.abc import Callable, Generator
|
from collections.abc import Callable, Generator
|
||||||
|
from unittest import mock
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
@@ -12,6 +13,16 @@ from esphome.core import CORE
|
|||||||
from esphome.pins import gpio_pin_schema
|
from esphome.pins import gpio_pin_schema
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(autouse=True)
|
||||||
|
def mock_spi_final_validate():
|
||||||
|
"""Mock spi.final_validate_device_schema since unit tests have no real SPI bus config."""
|
||||||
|
with mock.patch(
|
||||||
|
"esphome.components.spi.final_validate_device_schema",
|
||||||
|
return_value=lambda config: None,
|
||||||
|
):
|
||||||
|
yield
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def choose_variant_with_pins() -> Generator[Callable[[list], None]]:
|
def choose_variant_with_pins() -> Generator[Callable[[list], None]]:
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -25,7 +25,9 @@ from tests.component_tests.types import SetCoreConfigCallable
|
|||||||
|
|
||||||
def validated_config(config):
|
def validated_config(config):
|
||||||
"""Run schema + final validation and return the validated config."""
|
"""Run schema + final validation and return the validated config."""
|
||||||
return FINAL_VALIDATE_SCHEMA(CONFIG_SCHEMA(config))
|
config = CONFIG_SCHEMA(config)
|
||||||
|
FINAL_VALIDATE_SCHEMA(config)
|
||||||
|
return config
|
||||||
|
|
||||||
|
|
||||||
def test_metadata_native_quad_default_test_card(
|
def test_metadata_native_quad_default_test_card(
|
||||||
|
|||||||
Reference in New Issue
Block a user