mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 07:03:55 +00:00 
			
		
		
		
	display: rename DisplayBufferRef to DisplayRef (#5002)
				
					
				
			This commit is contained in:
		| @@ -58,6 +58,6 @@ async def to_code(config): | |||||||
|  |  | ||||||
|     if CONF_LAMBDA in config: |     if CONF_LAMBDA in config: | ||||||
|         lambda_ = await cg.process_lambda( |         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_)) |         cg.add(var.set_writer(lambda_)) | ||||||
|   | |||||||
| @@ -18,10 +18,11 @@ from esphome.core import coroutine_with_priority | |||||||
| IS_PLATFORM_COMPONENT = True | IS_PLATFORM_COMPONENT = True | ||||||
|  |  | ||||||
| display_ns = cg.esphome_ns.namespace("display") | display_ns = cg.esphome_ns.namespace("display") | ||||||
|  | Display = display_ns.class_("Display") | ||||||
| DisplayBuffer = display_ns.class_("DisplayBuffer") | DisplayBuffer = display_ns.class_("DisplayBuffer") | ||||||
| DisplayPage = display_ns.class_("DisplayPage") | DisplayPage = display_ns.class_("DisplayPage") | ||||||
| DisplayPagePtr = DisplayPage.operator("ptr") | DisplayPagePtr = DisplayPage.operator("ptr") | ||||||
| DisplayBufferRef = DisplayBuffer.operator("ref") | DisplayRef = Display.operator("ref") | ||||||
| DisplayPageShowAction = display_ns.class_("DisplayPageShowAction", automation.Action) | DisplayPageShowAction = display_ns.class_("DisplayPageShowAction", automation.Action) | ||||||
| DisplayPageShowNextAction = display_ns.class_( | DisplayPageShowNextAction = display_ns.class_( | ||||||
|     "DisplayPageShowNextAction", automation.Action |     "DisplayPageShowNextAction", automation.Action | ||||||
| @@ -96,7 +97,7 @@ async def setup_display_core_(var, config): | |||||||
|         pages = [] |         pages = [] | ||||||
|         for conf in config[CONF_PAGES]: |         for conf in config[CONF_PAGES]: | ||||||
|             lambda_ = await cg.process_lambda( |             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_) |             page = cg.new_Pvariable(conf[CONF_ID], lambda_) | ||||||
|             pages.append(page) |             pages.append(page) | ||||||
|   | |||||||
| @@ -133,12 +133,10 @@ enum DisplayRotation { | |||||||
| }; | }; | ||||||
|  |  | ||||||
| class Display; | class Display; | ||||||
| class DisplayBuffer; |  | ||||||
| class DisplayPage; | class DisplayPage; | ||||||
| class DisplayOnPageChangeTrigger; | class DisplayOnPageChangeTrigger; | ||||||
|  |  | ||||||
| using display_writer_t = std::function<void(Display &)>; | using display_writer_t = std::function<void(Display &)>; | ||||||
| using display_buffer_writer_t = std::function<void(DisplayBuffer &)>; |  | ||||||
|  |  | ||||||
| #define LOG_DISPLAY(prefix, type, obj) \ | #define LOG_DISPLAY(prefix, type, obj) \ | ||||||
|   if ((obj) != nullptr) { \ |   if ((obj) != nullptr) { \ | ||||||
| @@ -411,10 +409,6 @@ class Display { | |||||||
|  |  | ||||||
|   /// Internal method to set the display writer lambda. |   /// Internal method to set the display writer lambda. | ||||||
|   void set_writer(display_writer_t &&writer); |   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_page(DisplayPage *page); | ||||||
|   void show_next_page(); |   void show_next_page(); | ||||||
| @@ -499,9 +493,6 @@ class Display { | |||||||
| class DisplayPage { | class DisplayPage { | ||||||
|  public: |  public: | ||||||
|   DisplayPage(display_writer_t writer); |   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(); | ||||||
|   void show_next(); |   void show_next(); | ||||||
|   void show_prev(); |   void show_prev(); | ||||||
|   | |||||||
| @@ -121,7 +121,7 @@ async def to_code(config): | |||||||
|  |  | ||||||
|     if CONF_LAMBDA in config: |     if CONF_LAMBDA in config: | ||||||
|         lambda_ = await cg.process_lambda( |         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_)) |         cg.add(var.set_writer(lambda_)) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -115,7 +115,7 @@ async def to_code(config): | |||||||
|  |  | ||||||
|     if CONF_LAMBDA in config: |     if CONF_LAMBDA in config: | ||||||
|         lambda_ = await cg.process_lambda( |         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_)) |         cg.add(var.set_writer(lambda_)) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -52,6 +52,6 @@ async def to_code(config): | |||||||
|  |  | ||||||
|     if CONF_LAMBDA in config: |     if CONF_LAMBDA in config: | ||||||
|         lambda_ = await cg.process_lambda( |         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_)) |         cg.add(var.set_writer(lambda_)) | ||||||
|   | |||||||
| @@ -96,6 +96,6 @@ async def setup_ssd1306(var, config): | |||||||
|         cg.add(var.init_invert(config[CONF_INVERT])) |         cg.add(var.init_invert(config[CONF_INVERT])) | ||||||
|     if CONF_LAMBDA in config: |     if CONF_LAMBDA in config: | ||||||
|         lambda_ = await cg.process_lambda( |         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_)) |         cg.add(var.set_writer(lambda_)) | ||||||
|   | |||||||
| @@ -46,6 +46,6 @@ async def setup_ssd1322(var, config): | |||||||
|         cg.add(var.set_external_vcc(config[CONF_EXTERNAL_VCC])) |         cg.add(var.set_external_vcc(config[CONF_EXTERNAL_VCC])) | ||||||
|     if CONF_LAMBDA in config: |     if CONF_LAMBDA in config: | ||||||
|         lambda_ = await cg.process_lambda( |         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_)) |         cg.add(var.set_writer(lambda_)) | ||||||
|   | |||||||
| @@ -50,6 +50,6 @@ async def setup_ssd1325(var, config): | |||||||
|         cg.add(var.set_external_vcc(config[CONF_EXTERNAL_VCC])) |         cg.add(var.set_external_vcc(config[CONF_EXTERNAL_VCC])) | ||||||
|     if CONF_LAMBDA in config: |     if CONF_LAMBDA in config: | ||||||
|         lambda_ = await cg.process_lambda( |         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_)) |         cg.add(var.set_writer(lambda_)) | ||||||
|   | |||||||
| @@ -37,6 +37,6 @@ async def setup_ssd1327(var, config): | |||||||
|         cg.add(var.init_brightness(config[CONF_BRIGHTNESS])) |         cg.add(var.init_brightness(config[CONF_BRIGHTNESS])) | ||||||
|     if CONF_LAMBDA in config: |     if CONF_LAMBDA in config: | ||||||
|         lambda_ = await cg.process_lambda( |         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_)) |         cg.add(var.set_writer(lambda_)) | ||||||
|   | |||||||
| @@ -28,6 +28,6 @@ async def setup_ssd1331(var, config): | |||||||
|         cg.add(var.init_brightness(config[CONF_BRIGHTNESS])) |         cg.add(var.init_brightness(config[CONF_BRIGHTNESS])) | ||||||
|     if CONF_LAMBDA in config: |     if CONF_LAMBDA in config: | ||||||
|         lambda_ = await cg.process_lambda( |         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_)) |         cg.add(var.set_writer(lambda_)) | ||||||
|   | |||||||
| @@ -38,6 +38,6 @@ async def setup_ssd1351(var, config): | |||||||
|         cg.add(var.init_brightness(config[CONF_BRIGHTNESS])) |         cg.add(var.init_brightness(config[CONF_BRIGHTNESS])) | ||||||
|     if CONF_LAMBDA in config: |     if CONF_LAMBDA in config: | ||||||
|         lambda_ = await cg.process_lambda( |         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_)) |         cg.add(var.set_writer(lambda_)) | ||||||
|   | |||||||
| @@ -77,7 +77,7 @@ async def setup_st7735(var, config): | |||||||
|         cg.add(var.set_reset_pin(reset)) |         cg.add(var.set_reset_pin(reset)) | ||||||
|     if CONF_LAMBDA in config: |     if CONF_LAMBDA in config: | ||||||
|         lambda_ = await cg.process_lambda( |         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_)) |         cg.add(var.set_writer(lambda_)) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -121,7 +121,7 @@ async def to_code(config): | |||||||
|  |  | ||||||
|     if CONF_LAMBDA in config: |     if CONF_LAMBDA in config: | ||||||
|         lambda_ = await cg.process_lambda( |         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_)) |         cg.add(var.set_writer(lambda_)) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -153,7 +153,7 @@ async def to_code(config): | |||||||
|  |  | ||||||
|     if CONF_LAMBDA in config: |     if CONF_LAMBDA in config: | ||||||
|         lambda_ = await cg.process_lambda( |         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_)) |         cg.add(var.set_writer(lambda_)) | ||||||
|     if CONF_RESET_PIN in config: |     if CONF_RESET_PIN in config: | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user