Crates.io | embedded-ui |
lib.rs | embedded-ui |
version | 0.0.0 |
source | src |
created_at | 2024-06-02 14:05:51.037524 |
updated_at | 2024-06-02 14:05:51.037524 |
description | Simple UI framework created for embedded systems |
homepage | |
repository | |
max_upload_size | |
id | 1259219 |
size | 231,182 |
This library is created for personal use, and needs some rework to make it universally-usable. But I want to share it with everyone who is interested in creating complex UI (maybe not so complex) for embedded systems.
One important thing to note, is that mostly all core functionality is a copy of iced-rs as developing UI framework in Rust was a hard thing for me. But don't compare embedded-ui to iced in any way, it's just better to study this library independently
The main disadvantages of this library come from that in fact it isn't embedded-ready because of:
core::any
usage for widget states eats performanceBox
is used, so you must have global heap allocatorVec
- again, global heap allocator is required.I am planning to make an attempt on rewriting the code to use heapless
or even fixed-sized arrays, still keeping Any
but using references instead of the Box
es. I didn't start with it because it would be kinda painful, and I bet I'd never go to any with such requirements.
Pros:
embedded_graphics::DrawTarget
Cons:
To design icons I used free online app called Piskel for pixel-art. It supports exporting as C header file which you can put into repo as icons-input.c
and run node make-icons.js
Node.JS script to convert this header file into src/icons
directory. All you need is to give a name to each icon and its corresponding method.
For convenience, I've added a painting of each icon on top of it in generated file, so you can see what it looks like.
My icon packs are not consistent as catalogs because with such small sizes it is impossible to depict some figures. So bigger the size of the icons wider the catalog. It also means that when picking an icon and don't know the exact limits, it is possible to use a generic icon name and the best size will be chosen automatically.
There's a special trait InternalIconSet
which is implemented for all icon packs (and you can implement for yours) which contains icons used in system widgets, such as arrows for Select
or check sign in Checkbox
.
Length is a universal single-dimension size type, used both for width and height.
There are four options in Length
enum:
Fixed
- fixed length in pixelsShrink
- occupies as least free space as possible giving more space for other elementsFill
- occupies as much free space as possibleDiv(N)
- takes free / N
space. For example, in 100px container in width, element with width of Div(4)
will take 25px.There's a single container using flex layout -- Linear
. It is a generic element for both row and column.
Flex
Checkbox
FocusInput
Graph
Icon
Image
Knob
TODO:
- Add child element to the center of the knob. For value as text and anything
Linear
ProgressBar
TODO
Radio
Postponed. Use
Select
As I thinkSelect
covers radio button logic soRadio
postponed.
Scroll
Select
Slider
TODO:
- Slider text, to display real value. It should follow the knob not go out of viewport.
- Add min/max if it makes sense
Table
Postponed. Use
Linear
withrow
andcol
macros.
Toggle
Postponed. Use
Checkbox
.
Knob
Graph
ProgressBar
Slider
FocusInput
Scroll