mirror of
https://github.com/esphome/esphome.git
synced 2026-02-05 10:20:11 +08:00
[epaper_spi] Validate BUSY pin as input instead of output (#13764)
Some checks are pending
CI for docker images / Build docker containers (docker, ubuntu-24.04) (push) Waiting to run
CI for docker images / Build docker containers (docker, ubuntu-24.04-arm) (push) Waiting to run
CI for docker images / Build docker containers (ha-addon, ubuntu-24.04) (push) Waiting to run
CI for docker images / Build docker containers (ha-addon, ubuntu-24.04-arm) (push) Waiting to run
CI / Create common environment (push) Waiting to run
CI / Check pylint (push) Blocked by required conditions
CI / Run script/ci-custom (push) Blocked by required conditions
CI / Run pytest (macOS-latest, 3.11) (push) Blocked by required conditions
CI / Run pytest (ubuntu-latest, 3.11) (push) Blocked by required conditions
CI / Run pytest (ubuntu-latest, 3.13) (push) Blocked by required conditions
CI / Run pytest (windows-latest, 3.11) (push) Blocked by required conditions
CI / Determine which jobs to run (push) Blocked by required conditions
CI / Run integration tests (push) Blocked by required conditions
CI / Run C++ unit tests (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 IDF (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP8266 (push) Blocked by required conditions
CI / Run script/clang-tidy for ZEPHYR (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 1/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 2/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 3/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 4/4 (push) Blocked by required conditions
CI / Test components batch (${{ matrix.components }}) (push) Blocked by required conditions
CI / pre-commit.ci lite (push) Blocked by required conditions
CI / Build target branch for memory impact (push) Blocked by required conditions
CI / Build PR branch for memory impact (push) Blocked by required conditions
CI / Comment memory impact (push) Blocked by required conditions
CI / CI Status (push) Blocked by required conditions
Some checks are pending
CI for docker images / Build docker containers (docker, ubuntu-24.04) (push) Waiting to run
CI for docker images / Build docker containers (docker, ubuntu-24.04-arm) (push) Waiting to run
CI for docker images / Build docker containers (ha-addon, ubuntu-24.04) (push) Waiting to run
CI for docker images / Build docker containers (ha-addon, ubuntu-24.04-arm) (push) Waiting to run
CI / Create common environment (push) Waiting to run
CI / Check pylint (push) Blocked by required conditions
CI / Run script/ci-custom (push) Blocked by required conditions
CI / Run pytest (macOS-latest, 3.11) (push) Blocked by required conditions
CI / Run pytest (ubuntu-latest, 3.11) (push) Blocked by required conditions
CI / Run pytest (ubuntu-latest, 3.13) (push) Blocked by required conditions
CI / Run pytest (windows-latest, 3.11) (push) Blocked by required conditions
CI / Determine which jobs to run (push) Blocked by required conditions
CI / Run integration tests (push) Blocked by required conditions
CI / Run C++ unit tests (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 IDF (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP8266 (push) Blocked by required conditions
CI / Run script/clang-tidy for ZEPHYR (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 1/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 2/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 3/4 (push) Blocked by required conditions
CI / Run script/clang-tidy for ESP32 Arduino 4/4 (push) Blocked by required conditions
CI / Test components batch (${{ matrix.components }}) (push) Blocked by required conditions
CI / pre-commit.ci lite (push) Blocked by required conditions
CI / Build target branch for memory impact (push) Blocked by required conditions
CI / Build PR branch for memory impact (push) Blocked by required conditions
CI / Comment memory impact (push) Blocked by required conditions
CI / CI Status (push) Blocked by required conditions
This commit is contained in:
@@ -76,50 +76,42 @@ def model_schema(config):
|
||||
model.get_default(CONF_MINIMUM_UPDATE_INTERVAL, "1s")
|
||||
)
|
||||
cv_dimensions = cv.Optional if model.get_default(CONF_WIDTH) else cv.Required
|
||||
return (
|
||||
display.FULL_DISPLAY_SCHEMA.extend(
|
||||
spi.spi_device_schema(
|
||||
cs_pin_required=False,
|
||||
default_mode="MODE0",
|
||||
default_data_rate=model.get_default(CONF_DATA_RATE, 10_000_000),
|
||||
)
|
||||
)
|
||||
.extend(
|
||||
{
|
||||
model.option(pin): pins.gpio_output_pin_schema
|
||||
for pin in (CONF_RESET_PIN, CONF_CS_PIN, CONF_BUSY_PIN)
|
||||
}
|
||||
)
|
||||
.extend(
|
||||
{
|
||||
cv.Optional(CONF_ROTATION, default=0): validate_rotation,
|
||||
cv.Required(CONF_MODEL): cv.one_of(model.name, upper=True),
|
||||
cv.Optional(CONF_UPDATE_INTERVAL, default=cv.UNDEFINED): cv.All(
|
||||
update_interval, cv.Range(min=minimum_update_interval)
|
||||
),
|
||||
cv.Optional(CONF_TRANSFORM): cv.Schema(
|
||||
{
|
||||
cv.Required(CONF_MIRROR_X): cv.boolean,
|
||||
cv.Required(CONF_MIRROR_Y): cv.boolean,
|
||||
}
|
||||
),
|
||||
cv.Optional(CONF_FULL_UPDATE_EVERY, default=1): cv.int_range(1, 255),
|
||||
model.option(CONF_DC_PIN, fallback=None): pins.gpio_output_pin_schema,
|
||||
cv.GenerateID(): cv.declare_id(class_name),
|
||||
cv.GenerateID(CONF_INIT_SEQUENCE_ID): cv.declare_id(cg.uint8),
|
||||
cv_dimensions(CONF_DIMENSIONS): DIMENSION_SCHEMA,
|
||||
model.option(CONF_ENABLE_PIN): cv.ensure_list(
|
||||
pins.gpio_output_pin_schema
|
||||
),
|
||||
model.option(CONF_INIT_SEQUENCE, cv.UNDEFINED): cv.ensure_list(
|
||||
map_sequence
|
||||
),
|
||||
model.option(CONF_RESET_DURATION, cv.UNDEFINED): cv.All(
|
||||
cv.positive_time_period_milliseconds,
|
||||
cv.Range(max=core.TimePeriod(milliseconds=500)),
|
||||
),
|
||||
}
|
||||
return display.FULL_DISPLAY_SCHEMA.extend(
|
||||
spi.spi_device_schema(
|
||||
cs_pin_required=False,
|
||||
default_mode="MODE0",
|
||||
default_data_rate=model.get_default(CONF_DATA_RATE, 10_000_000),
|
||||
)
|
||||
).extend(
|
||||
{
|
||||
cv.Optional(CONF_ROTATION, default=0): validate_rotation,
|
||||
cv.Required(CONF_MODEL): cv.one_of(model.name, upper=True),
|
||||
cv.Optional(CONF_UPDATE_INTERVAL, default=cv.UNDEFINED): cv.All(
|
||||
update_interval, cv.Range(min=minimum_update_interval)
|
||||
),
|
||||
cv.Optional(CONF_TRANSFORM): cv.Schema(
|
||||
{
|
||||
cv.Required(CONF_MIRROR_X): cv.boolean,
|
||||
cv.Required(CONF_MIRROR_Y): cv.boolean,
|
||||
}
|
||||
),
|
||||
cv.Optional(CONF_FULL_UPDATE_EVERY, default=1): cv.int_range(1, 255),
|
||||
model.option(CONF_BUSY_PIN): pins.gpio_input_pin_schema,
|
||||
model.option(CONF_CS_PIN): pins.gpio_output_pin_schema,
|
||||
model.option(CONF_DC_PIN, fallback=None): pins.gpio_output_pin_schema,
|
||||
model.option(CONF_RESET_PIN): pins.gpio_output_pin_schema,
|
||||
cv.GenerateID(): cv.declare_id(class_name),
|
||||
cv.GenerateID(CONF_INIT_SEQUENCE_ID): cv.declare_id(cg.uint8),
|
||||
cv_dimensions(CONF_DIMENSIONS): DIMENSION_SCHEMA,
|
||||
model.option(CONF_ENABLE_PIN): cv.ensure_list(pins.gpio_output_pin_schema),
|
||||
model.option(CONF_INIT_SEQUENCE, cv.UNDEFINED): cv.ensure_list(
|
||||
map_sequence
|
||||
),
|
||||
model.option(CONF_RESET_DURATION, cv.UNDEFINED): cv.All(
|
||||
cv.positive_time_period_milliseconds,
|
||||
cv.Range(max=core.TimePeriod(milliseconds=500)),
|
||||
),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -289,3 +289,56 @@ def test_model_with_full_update_every(
|
||||
"full_update_every": 10,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def test_busy_pin_input_mode_ssd1677(
|
||||
set_core_config: SetCoreConfigCallable,
|
||||
set_component_config: Callable[[str, Any], None],
|
||||
) -> None:
|
||||
"""Test that busy_pin has input mode and cs/dc/reset pins have output mode for ssd1677."""
|
||||
set_core_config(
|
||||
PlatformFramework.ESP32_IDF,
|
||||
platform_data={KEY_BOARD: "esp32dev", KEY_VARIANT: VARIANT_ESP32},
|
||||
)
|
||||
|
||||
# Configure SPI component which is required by epaper_spi
|
||||
set_component_config("spi", {"id": "spi_bus", "clk_pin": 18, "mosi_pin": 19})
|
||||
|
||||
result = run_schema_validation(
|
||||
{
|
||||
"id": "test_display",
|
||||
"model": "ssd1677",
|
||||
"dc_pin": 21,
|
||||
"busy_pin": 22,
|
||||
"reset_pin": 23,
|
||||
"cs_pin": 5,
|
||||
"dimensions": {
|
||||
"width": 200,
|
||||
"height": 200,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
# Verify that busy_pin has input mode set
|
||||
assert CONF_BUSY_PIN in result
|
||||
busy_pin_config = result[CONF_BUSY_PIN]
|
||||
assert "mode" in busy_pin_config
|
||||
assert busy_pin_config["mode"]["input"] is True
|
||||
|
||||
# Verify that cs_pin has output mode set
|
||||
assert CONF_CS_PIN in result
|
||||
cs_pin_config = result[CONF_CS_PIN]
|
||||
assert "mode" in cs_pin_config
|
||||
assert cs_pin_config["mode"]["output"] is True
|
||||
|
||||
# Verify that dc_pin has output mode set
|
||||
assert CONF_DC_PIN in result
|
||||
dc_pin_config = result[CONF_DC_PIN]
|
||||
assert "mode" in dc_pin_config
|
||||
assert dc_pin_config["mode"]["output"] is True
|
||||
|
||||
# Verify that reset_pin has output mode set
|
||||
assert CONF_RESET_PIN in result
|
||||
reset_pin_config = result[CONF_RESET_PIN]
|
||||
assert "mode" in reset_pin_config
|
||||
assert reset_pin_config["mode"]["output"] is True
|
||||
|
||||
Reference in New Issue
Block a user