From 8d0c8cf965a913b0c2935d07f604bbce1bb1bb7e Mon Sep 17 00:00:00 2001 From: Michael Davidson Date: Tue, 19 Dec 2023 22:47:50 +1100 Subject: [PATCH] Black, flake8, and clang fixes --- .../components/graphical_layout/__init__.py | 18 ++++++++++++------ .../display_rendering_panel.cpp | 4 +--- .../graphical_layout/display_rendering_panel.h | 2 +- .../display_rendering_panel.py | 3 ++- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/esphome/components/graphical_layout/__init__.py b/esphome/components/graphical_layout/__init__.py index 8596ab4d03..4e4e56aec8 100644 --- a/esphome/components/graphical_layout/__init__.py +++ b/esphome/components/graphical_layout/__init__.py @@ -70,12 +70,18 @@ ITEM_TYPE_SCHEMA = cv.typed_schema( } ), display_rendering_panel.CONF_TYPE: BASE_ITEM_SCHEMA.extend( - { - cv.GenerateID(): cv.declare_id(display_rendering_panel.DisplayRenderingPanel), - cv.Required(display_rendering_panel.CONF_WIDTH): cv.templatable(cv.int_range(min=1)), - cv.Required(display_rendering_panel.CONF_HEIGHT): cv.templatable(cv.int_range(min=1)), - cv.Required(display_rendering_panel.CONF_LAMBDA): cv.lambda_, - } + { + cv.GenerateID(): cv.declare_id( + display_rendering_panel.DisplayRenderingPanel + ), + cv.Required(display_rendering_panel.CONF_WIDTH): cv.templatable( + cv.int_range(min=1) + ), + cv.Required(display_rendering_panel.CONF_HEIGHT): cv.templatable( + cv.int_range(min=1) + ), + cv.Required(display_rendering_panel.CONF_LAMBDA): cv.lambda_, + } ), } ) diff --git a/esphome/components/graphical_layout/display_rendering_panel.cpp b/esphome/components/graphical_layout/display_rendering_panel.cpp index f4fe8d8d2e..0bf3c2c30d 100644 --- a/esphome/components/graphical_layout/display_rendering_panel.cpp +++ b/esphome/components/graphical_layout/display_rendering_panel.cpp @@ -18,9 +18,7 @@ const display::Rect DisplayRenderingPanel::measure_item(display::Display *displa return display::Rect(0, 0, this->width_, this->width_); } -void DisplayRenderingPanel::render(display::Display *display, display::Rect bounds) { - this->lambda_(*display); -} +void DisplayRenderingPanel::render(display::Display *display, display::Rect bounds) { this->lambda_(*display); } } // namespace graphical_layout } // namespace esphome diff --git a/esphome/components/graphical_layout/display_rendering_panel.h b/esphome/components/graphical_layout/display_rendering_panel.h index d2acd7a3f6..6c78ce9fb2 100644 --- a/esphome/components/graphical_layout/display_rendering_panel.h +++ b/esphome/components/graphical_layout/display_rendering_panel.h @@ -10,7 +10,7 @@ namespace graphical_layout { using display_writer_t = std::function; /** The DisplayRenderingPanel is a UI item that renders a custom lambda to the display whilst - * participating in the layout process + * participating in the layout process */ class DisplayRenderingPanel : public LayoutItem { public: diff --git a/esphome/components/graphical_layout/display_rendering_panel.py b/esphome/components/graphical_layout/display_rendering_panel.py index a25d3d16fb..a25ca8c22d 100644 --- a/esphome/components/graphical_layout/display_rendering_panel.py +++ b/esphome/components/graphical_layout/display_rendering_panel.py @@ -10,6 +10,7 @@ CONF_HEIGHT = "height" CONF_WIDTH = "width" CONF_LAMBDA = "lambda" + async def config_to_layout_item(item_config, child_item_builder): var = cg.new_Pvariable(item_config[CONF_ID]) @@ -20,7 +21,7 @@ async def config_to_layout_item(item_config, child_item_builder): cg.add(var.set_height(height)) lambda_ = await cg.process_lambda( - item_config[CONF_LAMBDA], [(DisplayRef, "it")], return_type=cg.void + item_config[CONF_LAMBDA], [(DisplayRef, "it")], return_type=cg.void ) cg.add(var.set_lambda(lambda_))