esphome / esphome/feature-requests

Allow pages and lambda for rendering something on every page

Open
#2,094 4 comments 0 reactions 0 assignees View on GitHub
component: display
Dominant language
No language data
Stars
450
Forks
29
PR merge metrics
No merged PRs in 30d

Description

**Describe the problem you have/What new integration you would like**

Currently when setting up a display you can only either have a lambda function to render the display or pages with their own lambda. I would like to have both. This way I can have something that renders on every page without duplicating the code (such as page selectors/next & prev buttons).

**Please describe your use case for this integration and alternatives you've tried:**

Only alternative I see currently is to duplicate this logic across all pages in the YAML. It can get very annoying when you need to make changes (lots of copy pasting if you have many pages).

**Additional context**

An example of what I am proposing that is currently invalid:
```
display:
- platform: ili9341
id: my_display
model: TFT 2.4
cs_pin: GPIO15
dc_pin: GPIO2
led_pin: GPIO32
reset_pin: GPIO4
lambda: |-
// render footer page selectors on every page
it.filled_rectangle(0, 300, 120, 20, my_red);
it.print(0, 300, id(font_roboto), Color::BLACK, TextAlign::TOP_LEFT, "Page1");
it.filled_rectangle(120, 300, 120, 20, my_blue);
it.print(120, 300, id(font_roboto), Color::BLACK, TextAlign::TOP_LEFT, "Page2");
pages:
- id: page1
lambda: |-
it.fill(Color::BLACK);
it.print(0, 0, id(font_roboto), id(my_red), TextAlign::TOP_LEFT, "This is page 1!");
- id: page2
lambda: |-
it.print(0, 10, id(font_roboto), "This is page 2!");
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Use the YAML example as the starting specification and trace how display lambdas and page lambdas are configured and invoked. Determine the rendering order and lifecycle needed for shared and per-page content, then validate that common content appears on every page without duplicated YAML.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, yaml
Domain
embedded-iot
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.