From 7c849a194f2cd3f91d59f2d1fa3454b74df962c0 Mon Sep 17 00:00:00 2001 From: DJGummikuh Date: Thu, 15 Aug 2024 13:32:58 +0000 Subject: [PATCH] Validating input for num_segments_x and num_segments_y, addding cinttypes for those black magic macros for uint32_t printf --- dependencies.lock | 30 +++++++++++++++++++ .../components/waveshare_epaper/display.py | 19 +++++++++++- .../waveshare_epaper/waveshare_epaper.h | 1 + 3 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 dependencies.lock diff --git a/dependencies.lock b/dependencies.lock new file mode 100644 index 0000000000..b4fe56068e --- /dev/null +++ b/dependencies.lock @@ -0,0 +1,30 @@ +dependencies: + esp-tflite-micro: + component_hash: 09acb9889f98d0e7b5d9d1aa7184d455cfd30268d627b43371b7593106d0fc4b + source: + git: https://github.com/espressif/esp-tflite-micro.git + path: . + type: git + version: c5d97c9577de0eb9b8f05078da84bbb9ff0f748f + esp32_camera: + component_hash: 659f1353ee3dd6db885667c61e45fad5574c6c4d832fbe6797ea224d6f61d1e3 + source: + git: https://github.com/espressif/esp32-camera.git + path: . + type: git + version: 30aeeeed61e2b0182d673fe2cfedb1b7aa43b1b9 + espressif/esp-nn: + component_hash: b32869798bdb40dec6bc99caca48cd65d42f8a9f506b9ab9c598a076f891ede9 + source: + pre_release: true + service_url: https://api.components.espressif.com/ + type: service + version: 1.0.2 + idf: + component_hash: null + source: + type: idf + version: 4.4.7 +manifest_hash: c329277baa8ef760348eeece89727f1fecb1127f44ebc3173274cdf9723ed264 +target: esp32 +version: 1.0.0 diff --git a/esphome/components/waveshare_epaper/display.py b/esphome/components/waveshare_epaper/display.py index 913b7662c6..4fa8b84e7c 100644 --- a/esphome/components/waveshare_epaper/display.py +++ b/esphome/components/waveshare_epaper/display.py @@ -144,7 +144,9 @@ MODELS = { } RESET_PIN_REQUIRED_MODELS = ("2.13inv2", "2.13in-ttgo-b74") -SEGMENT_UPDATEABLE_MODELS = "7.5in-bgr-gd" +SEGMENT_UPDATEABLE_MODELS = { + "7.5in-bgr-gd": (800, 480), +} def validate_full_update_every_only_types_ac(value): @@ -169,6 +171,21 @@ def validate_num_segments_supported(config): raise cv.Invalid( f"'num_segments_x' and num_segment_y' are not supported by {config[CONF_MODEL]}" ) + if CONF_NUM_SEGMENTS_X in config and ( + SEGMENT_UPDATEABLE_MODELS[config[CONF_MODEL]][0] + % (config[CONF_NUM_SEGMENTS_X] * 8) + > 0 + ): + raise cv.Invalid( + f"The horizontal resolution of the display ({SEGMENT_UPDATEABLE_MODELS[config[CONF_MODEL]][0]}px) must be divisible by 'num_segments_x * 8'" + ) + if CONF_NUM_SEGMENTS_Y in config and ( + SEGMENT_UPDATEABLE_MODELS[config[CONF_MODEL]][1] % config[CONF_NUM_SEGMENTS_Y] + > 0 + ): + raise cv.Invalid( + f"The vertical resolution of the display ({SEGMENT_UPDATEABLE_MODELS[config[CONF_MODEL]][1]}px) must be divisible by 'num_segments_y'" + ) return config diff --git a/esphome/components/waveshare_epaper/waveshare_epaper.h b/esphome/components/waveshare_epaper/waveshare_epaper.h index 92e5558cec..ece746250b 100644 --- a/esphome/components/waveshare_epaper/waveshare_epaper.h +++ b/esphome/components/waveshare_epaper/waveshare_epaper.h @@ -4,6 +4,7 @@ #include "esphome/core/helpers.h" #include "esphome/components/spi/spi.h" #include "esphome/components/display/display_buffer.h" +#include namespace esphome { namespace waveshare_epaper {