From d0ced3471e8acce2c72e11458005d870ee5eb88c Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Thu, 21 Mar 2024 14:25:11 +1100 Subject: [PATCH] SPI: Make some validation failures give more useful messages. (#6413) --- esphome/components/spi/__init__.py | 9 +++++++++ tests/components/xpt2046/test.esp32-c3-idf.yaml | 9 +++++---- tests/components/xpt2046/test.esp32-c3.yaml | 9 +++++---- tests/components/xpt2046/test.esp32-idf.yaml | 9 +++++---- tests/components/xpt2046/test.esp32.yaml | 9 +++++---- tests/components/xpt2046/test.esp8266.yaml | 9 +++++---- tests/components/xpt2046/test.rp2040.yaml | 9 +++++---- 7 files changed, 39 insertions(+), 24 deletions(-) diff --git a/esphome/components/spi/__init__.py b/esphome/components/spi/__init__.py index 2847c5bfa1..fdf19bb56e 100644 --- a/esphome/components/spi/__init__.py +++ b/esphome/components/spi/__init__.py @@ -268,6 +268,9 @@ SPI_SCHEMA = cv.All( *sum(get_hw_interface_list(), ["software", "hardware", "any"]), lower=True, ), + cv.Optional(CONF_DATA_PINS): cv.invalid( + "'data_pins' should be used with 'type: quad' only" + ), } ), cv.has_at_least_one_key(CONF_MISO_PIN, CONF_MOSI_PIN), @@ -287,6 +290,12 @@ SPI_QUAD_SCHEMA = cv.All( *sum(get_hw_interface_list(), ["hardware"]), lower=True, ), + cv.Optional(CONF_MISO_PIN): cv.invalid( + "'miso_pin' should not be used with quad SPI" + ), + cv.Optional(CONF_MOSI_PIN): cv.invalid( + "'mosi_pin' should not be used with quad SPI" + ), } ), cv.only_on([PLATFORM_ESP32]), diff --git a/tests/components/xpt2046/test.esp32-c3-idf.yaml b/tests/components/xpt2046/test.esp32-c3-idf.yaml index 38a1da74ae..f3a2cf9aae 100644 --- a/tests/components/xpt2046/test.esp32-c3-idf.yaml +++ b/tests/components/xpt2046/test.esp32-c3-idf.yaml @@ -23,10 +23,11 @@ touchscreen: display: xpt_display update_interval: 50ms threshold: 400 - calibration_x_min: 3860 - calibration_x_max: 280 - calibration_y_min: 340 - calibration_y_max: 3860 + calibration: + x_min: 3860 + x_max: 280 + y_min: 340 + y_max: 3860 on_touch: - logger.log: format: Touch at (%d, %d) diff --git a/tests/components/xpt2046/test.esp32-c3.yaml b/tests/components/xpt2046/test.esp32-c3.yaml index 38a1da74ae..f3a2cf9aae 100644 --- a/tests/components/xpt2046/test.esp32-c3.yaml +++ b/tests/components/xpt2046/test.esp32-c3.yaml @@ -23,10 +23,11 @@ touchscreen: display: xpt_display update_interval: 50ms threshold: 400 - calibration_x_min: 3860 - calibration_x_max: 280 - calibration_y_min: 340 - calibration_y_max: 3860 + calibration: + x_min: 3860 + x_max: 280 + y_min: 340 + y_max: 3860 on_touch: - logger.log: format: Touch at (%d, %d) diff --git a/tests/components/xpt2046/test.esp32-idf.yaml b/tests/components/xpt2046/test.esp32-idf.yaml index 7f8617d176..bb166866f4 100644 --- a/tests/components/xpt2046/test.esp32-idf.yaml +++ b/tests/components/xpt2046/test.esp32-idf.yaml @@ -23,10 +23,11 @@ touchscreen: display: xpt_display update_interval: 50ms threshold: 400 - calibration_x_min: 3860 - calibration_x_max: 280 - calibration_y_min: 340 - calibration_y_max: 3860 + calibration: + x_min: 3860 + x_max: 280 + y_min: 340 + y_max: 3860 on_touch: - logger.log: format: Touch at (%d, %d) diff --git a/tests/components/xpt2046/test.esp32.yaml b/tests/components/xpt2046/test.esp32.yaml index 7f8617d176..bb166866f4 100644 --- a/tests/components/xpt2046/test.esp32.yaml +++ b/tests/components/xpt2046/test.esp32.yaml @@ -23,10 +23,11 @@ touchscreen: display: xpt_display update_interval: 50ms threshold: 400 - calibration_x_min: 3860 - calibration_x_max: 280 - calibration_y_min: 340 - calibration_y_max: 3860 + calibration: + x_min: 3860 + x_max: 280 + y_min: 340 + y_max: 3860 on_touch: - logger.log: format: Touch at (%d, %d) diff --git a/tests/components/xpt2046/test.esp8266.yaml b/tests/components/xpt2046/test.esp8266.yaml index a998d2df14..a917290e8e 100644 --- a/tests/components/xpt2046/test.esp8266.yaml +++ b/tests/components/xpt2046/test.esp8266.yaml @@ -23,10 +23,11 @@ touchscreen: display: xpt_display update_interval: 50ms threshold: 400 - calibration_x_min: 3860 - calibration_x_max: 280 - calibration_y_min: 340 - calibration_y_max: 3860 + calibration: + x_min: 3860 + x_max: 280 + y_min: 340 + y_max: 3860 on_touch: - logger.log: format: Touch at (%d, %d) diff --git a/tests/components/xpt2046/test.rp2040.yaml b/tests/components/xpt2046/test.rp2040.yaml index 3e5d602247..a7a49309ac 100644 --- a/tests/components/xpt2046/test.rp2040.yaml +++ b/tests/components/xpt2046/test.rp2040.yaml @@ -23,10 +23,11 @@ touchscreen: display: xpt_display update_interval: 50ms threshold: 400 - calibration_x_min: 3860 - calibration_x_max: 280 - calibration_y_min: 340 - calibration_y_max: 3860 + calibration: + x_min: 3860 + x_max: 280 + y_min: 340 + y_max: 3860 on_touch: - logger.log: format: Touch at (%d, %d)