display: rename DisplayBufferRef to DisplayRef (#5002)

This commit is contained in:
Kamil Trzciński
2023-07-11 06:38:28 +09:00
committed by GitHub
parent ddde1ee31e
commit 98fd092053
15 changed files with 16 additions and 24 deletions
+3 -2
View File
@@ -18,10 +18,11 @@ from esphome.core import coroutine_with_priority
IS_PLATFORM_COMPONENT = True
display_ns = cg.esphome_ns.namespace("display")
Display = display_ns.class_("Display")
DisplayBuffer = display_ns.class_("DisplayBuffer")
DisplayPage = display_ns.class_("DisplayPage")
DisplayPagePtr = DisplayPage.operator("ptr")
DisplayBufferRef = DisplayBuffer.operator("ref")
DisplayRef = Display.operator("ref")
DisplayPageShowAction = display_ns.class_("DisplayPageShowAction", automation.Action)
DisplayPageShowNextAction = display_ns.class_(
"DisplayPageShowNextAction", automation.Action
@@ -96,7 +97,7 @@ async def setup_display_core_(var, config):
pages = []
for conf in config[CONF_PAGES]:
lambda_ = await cg.process_lambda(
conf[CONF_LAMBDA], [(DisplayBufferRef, "it")], return_type=cg.void
conf[CONF_LAMBDA], [(DisplayRef, "it")], return_type=cg.void
)
page = cg.new_Pvariable(conf[CONF_ID], lambda_)
pages.append(page)
-9
View File
@@ -133,12 +133,10 @@ enum DisplayRotation {
};
class Display;
class DisplayBuffer;
class DisplayPage;
class DisplayOnPageChangeTrigger;
using display_writer_t = std::function<void(Display &)>;
using display_buffer_writer_t = std::function<void(DisplayBuffer &)>;
#define LOG_DISPLAY(prefix, type, obj) \
if ((obj) != nullptr) { \
@@ -411,10 +409,6 @@ class Display {
/// Internal method to set the display writer lambda.
void set_writer(display_writer_t &&writer);
void set_writer(const display_buffer_writer_t &writer) {
// Temporary mapping to be removed once all lambdas are changed to use `display.DisplayRef`
this->set_writer([writer](Display &display) { return writer((display::DisplayBuffer &) display); });
}
void show_page(DisplayPage *page);
void show_next_page();
@@ -499,9 +493,6 @@ class Display {
class DisplayPage {
public:
DisplayPage(display_writer_t writer);
// Temporary mapping to be removed once all lambdas are changed to use `display.DisplayRef`
DisplayPage(const display_buffer_writer_t &writer)
: DisplayPage([writer](Display &display) { return writer((display::DisplayBuffer &) display); }) {}
void show();
void show_next();
void show_prev();