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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 16 additions and 24 deletions

View File

@ -58,6 +58,6 @@ async def to_code(config):
if CONF_LAMBDA in config:
lambda_ = await cg.process_lambda(
config[CONF_LAMBDA], [(display.DisplayBufferRef, "it")], return_type=cg.void
config[CONF_LAMBDA], [(display.DisplayRef, "it")], return_type=cg.void
)
cg.add(var.set_writer(lambda_))

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)

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();

View File

@ -121,7 +121,7 @@ async def to_code(config):
if CONF_LAMBDA in config:
lambda_ = await cg.process_lambda(
config[CONF_LAMBDA], [(display.DisplayBufferRef, "it")], return_type=cg.void
config[CONF_LAMBDA], [(display.DisplayRef, "it")], return_type=cg.void
)
cg.add(var.set_writer(lambda_))

View File

@ -115,7 +115,7 @@ async def to_code(config):
if CONF_LAMBDA in config:
lambda_ = await cg.process_lambda(
config[CONF_LAMBDA], [(display.DisplayBufferRef, "it")], return_type=cg.void
config[CONF_LAMBDA], [(display.DisplayRef, "it")], return_type=cg.void
)
cg.add(var.set_writer(lambda_))

View File

@ -52,6 +52,6 @@ async def to_code(config):
if CONF_LAMBDA in config:
lambda_ = await cg.process_lambda(
config[CONF_LAMBDA], [(display.DisplayBufferRef, "it")], return_type=cg.void
config[CONF_LAMBDA], [(display.DisplayRef, "it")], return_type=cg.void
)
cg.add(var.set_writer(lambda_))

View File

@ -96,6 +96,6 @@ async def setup_ssd1306(var, config):
cg.add(var.init_invert(config[CONF_INVERT]))
if CONF_LAMBDA in config:
lambda_ = await cg.process_lambda(
config[CONF_LAMBDA], [(display.DisplayBufferRef, "it")], return_type=cg.void
config[CONF_LAMBDA], [(display.DisplayRef, "it")], return_type=cg.void
)
cg.add(var.set_writer(lambda_))

View File

@ -46,6 +46,6 @@ async def setup_ssd1322(var, config):
cg.add(var.set_external_vcc(config[CONF_EXTERNAL_VCC]))
if CONF_LAMBDA in config:
lambda_ = await cg.process_lambda(
config[CONF_LAMBDA], [(display.DisplayBufferRef, "it")], return_type=cg.void
config[CONF_LAMBDA], [(display.DisplayRef, "it")], return_type=cg.void
)
cg.add(var.set_writer(lambda_))

View File

@ -50,6 +50,6 @@ async def setup_ssd1325(var, config):
cg.add(var.set_external_vcc(config[CONF_EXTERNAL_VCC]))
if CONF_LAMBDA in config:
lambda_ = await cg.process_lambda(
config[CONF_LAMBDA], [(display.DisplayBufferRef, "it")], return_type=cg.void
config[CONF_LAMBDA], [(display.DisplayRef, "it")], return_type=cg.void
)
cg.add(var.set_writer(lambda_))

View File

@ -37,6 +37,6 @@ async def setup_ssd1327(var, config):
cg.add(var.init_brightness(config[CONF_BRIGHTNESS]))
if CONF_LAMBDA in config:
lambda_ = await cg.process_lambda(
config[CONF_LAMBDA], [(display.DisplayBufferRef, "it")], return_type=cg.void
config[CONF_LAMBDA], [(display.DisplayRef, "it")], return_type=cg.void
)
cg.add(var.set_writer(lambda_))

View File

@ -28,6 +28,6 @@ async def setup_ssd1331(var, config):
cg.add(var.init_brightness(config[CONF_BRIGHTNESS]))
if CONF_LAMBDA in config:
lambda_ = await cg.process_lambda(
config[CONF_LAMBDA], [(display.DisplayBufferRef, "it")], return_type=cg.void
config[CONF_LAMBDA], [(display.DisplayRef, "it")], return_type=cg.void
)
cg.add(var.set_writer(lambda_))

View File

@ -38,6 +38,6 @@ async def setup_ssd1351(var, config):
cg.add(var.init_brightness(config[CONF_BRIGHTNESS]))
if CONF_LAMBDA in config:
lambda_ = await cg.process_lambda(
config[CONF_LAMBDA], [(display.DisplayBufferRef, "it")], return_type=cg.void
config[CONF_LAMBDA], [(display.DisplayRef, "it")], return_type=cg.void
)
cg.add(var.set_writer(lambda_))

View File

@ -77,7 +77,7 @@ async def setup_st7735(var, config):
cg.add(var.set_reset_pin(reset))
if CONF_LAMBDA in config:
lambda_ = await cg.process_lambda(
config[CONF_LAMBDA], [(display.DisplayBufferRef, "it")], return_type=cg.void
config[CONF_LAMBDA], [(display.DisplayRef, "it")], return_type=cg.void
)
cg.add(var.set_writer(lambda_))

View File

@ -121,7 +121,7 @@ async def to_code(config):
if CONF_LAMBDA in config:
lambda_ = await cg.process_lambda(
config[CONF_LAMBDA], [(display.DisplayBufferRef, "it")], return_type=cg.void
config[CONF_LAMBDA], [(display.DisplayRef, "it")], return_type=cg.void
)
cg.add(var.set_writer(lambda_))

View File

@ -153,7 +153,7 @@ async def to_code(config):
if CONF_LAMBDA in config:
lambda_ = await cg.process_lambda(
config[CONF_LAMBDA], [(display.DisplayBufferRef, "it")], return_type=cg.void
config[CONF_LAMBDA], [(display.DisplayRef, "it")], return_type=cg.void
)
cg.add(var.set_writer(lambda_))
if CONF_RESET_PIN in config: