rust-embedded / not-yet-awesome-embedded-rust

A collection of items that are not yet awesome in Embedded Rust
Creative Commons Attribution Share Alike 4.0 International
117 stars 11 forks source link

[request] Embedded GUI #13

Open puzrin opened 5 years ago

puzrin commented 5 years ago

No GUI, suitable for embedded use on small SOC-s

Currently there are no complete solutions, suitable to create modern interfaces on "small" devices (like 8-16K RAM + 64-128K Flash).

Targeting

I'd suggest to focus on "small" systems like stm32f0-stm32f4 with colour displays up to 320*200.

Reasons:

That's only examples, to explain range of devices, where hardware already CAN run modern GUI, but no appropriate software available. Of cause, you can find lot of exclusions, but reason of GUI request is to fill gap, not to compete with existing libs.

Specifics of hardware restrictions

  1. No memory space for full display buffer (320*240*16bpp). This is solved by multi-pass rendering, when buffer size is 1/20 of screen area.
  2. No resources (primary - RAM) for TTF (vector) fonts. Bitmap fonts used.
    • Related: there are some solutions to convert font from TTF, but those do not support good compression. Appropriate tools required.
  3. No GPU. As a result - no need to have abstraction layer for appropriate draw commands. It's enough for driver to support region copy only.

UX/look

Most of existing GUI-s try to invent own look instead of following one of existing guideline. Result is very poor. IMHO something like Material Design is "minimal possible quality requirement".

PC emulator

When you do simple device, it's not difficult to code "meat". The most time-consuming task become interface polishing. It's not convenient to do such things on bare metal. Having PC emulator of display/touch will speed up development significantly.

Success criteria

Ideally, it would be nice to have GUI, able to create Material Design interfaces on SOCs with 8-16K RAM and 64-128K flash.

  1. GUI core. To not fall into technical details - something like LittlevGL.
  2. Tool to convert TTF fonts to bitmap fonts, with subsetting and RLE-like compression.
  3. Demo with "Settings menu". A lot of small devices can be described as "Main screen + settings". Having demo with good design will help a lot to quick-start.
  4. PC emulator (driver), easy to install on major platforms.

References

This chapter replaces "Work in Progress" because referred things are not for rust. But those have a lot of reusable things, and should save a lot of time.

rafaelcaricio commented 4 years ago

Hi,

I just found this issue and I find it very interesting. A couple of weeks ago I started creating LittlevGL (LVGL) bindings for Rust.

https://github.com/rafaelcaricio/lvgl-rs

The project is still in very early stages. A lot of polishing is still necessary as I'm figuring out the best design for the API.

lvgl-rs highlights:

I've shared the lvgl-rs project with the folks that created and maintain LVGL and we are exchanging some ideas on how to speed up the process of creating the bindings. I don't have a timeline for when it will be completed as this is a project I develop in my free time. However, I'm open to accepting pull requests and feedback about the project in general.

lvgl-rs seems to be exactly what you are looking for. Let me know what you think.

puzrin commented 4 years ago

@rafaelcaricio

lvgl-rs seems to be exactly what you are looking for. Let me know what you think.

At current moment i use lvgl directly, and don't like use it via bindings. While still the best of available in current moment, lvgl has some controversial architecture decisions, no tests, no benchmarks and so on. IMO, for awesome result, it would be more simple to write native GUI in rust from scratch.

xgroleau commented 1 year ago

Just FYI, there is slint-ui which can run on embedded. It also comes with an emulator using webassembly and respects most of the criteria. They already have examples using embedded-graphics and can render by line instead of the full frame buffer so it can easily fit in ram. Note that the project is GPL and not MIT/Apache though so it may be incompatible with some projects.

puzrin commented 1 year ago

@xgroleau from readme: "Slint apps can run on MCUs with less than 300K of RAM."

That's out of expected for small MCU-s.

xgroleau commented 1 year ago

@puzrin You definitely don't need the full 300kb of RAM to use it. I've used it successfully with an nrf52840(192kb of ram with the softdevice)while allocating only 24kb of heap for slint (I haven't checked usage). Now obviously consumption vary on the number of components. It's ram usage seems similar but a little higher than lvgl for a similar UI. It does seem to use more flash space though.

ryankurte commented 1 year ago

i think this is subsequently also fairly well covered by embedded-graphics ^_^

puzrin commented 1 year ago

That's not GUI at all, just a shapes drawer.