Comments (6)
@clydebarrow I've create a proof of concept for the lambda assignment of pages:
https://github.com/segfly/esphome-lvgl
Basically, when the lambda:
property is present, it takes the return value and assigns to {page.obj}
struct instead of the generated lv_obj_create
call. This allows a great deal of flexibility for page creation outside of yaml, while still allowing for other parts of the LVGL ESPHome component to interact with the "injected" page.
The only (minor) issues I ran into were with the EEZ Studio generated code, I had to change the default generation templates to specify the right "lvgl.h" path and add a fake method for getFlowState
call, which I think is generated as a bug in their code for LVGL-only projects.
Once that was done, I can now design pages in the EEZ Studio, and then use with the LVGL ESPHome component.
Here is a snippet of what the yaml looks like:
sensor:
- platform: uptime
id: sys_uptime
update_interval: 1s
on_value:
then:
- lambda: lv_label_set_text(objects.label_uptime, std::to_string(static_cast<int>(id(sys_uptime).get_state())).c_str());
button:
- platform:
name: Show Uptime
on_press:
- lvgl.page.show: uptime_page
lvgl:
pages:
- id: welcome_page
widgets:
- label:
align: CENTER
text: "Welcome!"
- id: uptime_page
lambda: |-
create_screen_uptime_page();
return objects.uptime_page;
Thoughts?
from esphome.
Let's tun things around: how about discussing with EEZ project (after this is merged) so they could directly output ESPHome yaml?
from esphome.
A similar thought crossed my mind, but that seems like a huge amount of work. It would be wonderful though, I don't disagree.
I was thinking as a short-term solution, this simple lambda approach provides a lot of flexibility - plus, it theoretically can be used with any other LVGL designer, like SquareLine Studio.
from esphome.
yaml->compile->upload->test
You could use ESPHome host + vnc to speed things up considerably.
from esphome.
Ah interesting. I did not know this existed, probably because it's not documented:
esphome/feature-requests#2388 (comment)
It won't make UI design as fast or easy as using a UI designer, but will certainly streamline integration testing, before testing on device. Thanks.
from esphome.
The sdl display driver is even simpler to use than VNC now, and it's merged into ESPHome release.
from esphome.
Related Issues (20)
- Font kerning HOT 1
- Formatted text for widget updates HOT 1
- QR code
- Graph as image HOT 2
- VNC: host binary crashes on client disconnect
- VNC and `graphical_display_menu` don't play nicely together HOT 3
- Lvgl on e-paper crash (TTGO T5_V2.3_2.13) HOT 2
- Compile error in LVGL after last commit. HOT 6
- FR: `udp` sensor from multiple providers
- FR: `udp` text sensor
- FR: `udp` arbitrary data with actions and triggers HOT 1
- FR: `udp` repeat messages
- Page's `skip` option to be set at runtime
- FR: `udp` multiple instances HOT 2
- disp_bg_image error HOT 1
- Additional ST7701s initialization request HOT 6
- Import of SVG files not working correctly with LVGL HOT 4
- Arc is clickable outside of range HOT 1
- Raised issues in ESPHome issues HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from esphome.