Update readme

This commit is contained in:
Rafael Caricio 2020-06-12 18:54:28 +02:00 committed by Rafael Carício
parent de9b6512a7
commit b0113fc747
3 changed files with 28 additions and 41 deletions

View file

@ -62,6 +62,14 @@ $ git submodule init
$ git submodule update $ git submodule update
``` ```
Some parts of `lvgl-rs` are auto-generated. The package `lvgl-codegen` is responsible for the generated code.
When building from source, we need to first compile the `lvgl-codegen` tool. The `lvgl-codegen` tool is used
automatically in the [`lvgl` package build](./lvgl/build.rs).
```bash
$ DEP_LV_CONFIG_PATH=`pwd`/examples/include cargo build --package lvgl-codegen
```
Then run the `demo` example: Then run the `demo` example:
```shell ```shell
@ -80,7 +88,7 @@ List of LVGL features that impacts the library usage in general.
draw to the display. You can use `lvgl-rs` with any of the draw to the display. You can use `lvgl-rs` with any of the
[`embedded_graphics` supported displays](https://docs.rs/embedded-graphics/0.6.2/embedded_graphics/#supported-displays). [`embedded_graphics` supported displays](https://docs.rs/embedded-graphics/0.6.2/embedded_graphics/#supported-displays).
- [x] Events: You can listen and trigger events in widget objects. - [x] Events: You can listen and trigger events in widget objects.
- [x] Styles: You can set styles in any exposed object. We are still missing the possibility of defining base styles. - [x] Styles: You can set styles in any exposed object. We are still missing the possibility of defining global base styles.
- [ ] Input Devices - [ ] Input Devices
- [ ] Fonts - [ ] Fonts
- [ ] Images - [ ] Images
@ -90,40 +98,5 @@ List of LVGL features that impacts the library usage in general.
### Widgets ### Widgets
- [x] Base object (lv_obj)
- [ ] Arc (lv_arc)
- [x] Bar (lv_bar)
- [x] Button (lv_btn)
- [ ] Button matrix (lv_btnmatrix)
- [ ] Calendar (lv_calendar)
- [ ] Canvas (lv_canvas)
- [ ] Checkbox (lv_cb)
- [ ] Chart (lv_chart)
- [ ] Container (lv_cont)
- [ ] Color picker (lv_cpicker)
- [ ] Drop-down list (lv_dropdown)
- [x] Gauge (lv_gauge)
- [ ] Image (lv_img)
- [ ] Image button (lv_imgbtn)
- [ ] Keyboard (lv_keyboard)
- [x] Label (lv_label)
- [ ] LED (lv_led)
- [ ] Line (lv_line)
- [ ] List (lv_list)
- [ ] Line meter (lv_lmeter)
- [ ] Message box (lv_msdbox)
- [ ] Object mask (lv_objmask)
- [ ] Page (lv_page)
- [ ] Roller (lv_roller)
- [ ] Slider (lv_slider)
- [ ] Spinbox (lv_spinbox)
- [ ] Spinner (lv_spinner)
- [ ] Switch (lv_switch)
- [ ] Table (lv_table)
- [ ] Tabview (lv_tabview)
- [ ] Text area (lv_textarea)
- [ ] Tile view (lv_tileview)
- [ ] Window (lv_win)
Widgets currently implemented might have some missing features. If the widget you want to use is not exposed or Widgets currently implemented might have some missing features. If the widget you want to use is not exposed or
is missing a feature you want to make use, please send a Pull Request or open an issue. is missing a feature you want to make use, please send a Pull Request or open an issue.

View file

@ -4,7 +4,7 @@ use embedded_graphics_simulator::{
OutputSettingsBuilder, SimulatorDisplay, SimulatorEvent, Window, OutputSettingsBuilder, SimulatorDisplay, SimulatorEvent, Window,
}; };
use lvgl::style::Style; use lvgl::style::Style;
use lvgl::widgets::{Btn, Label, Msgbox, Spinbox}; use lvgl::widgets::{Btn, Label};
use lvgl::{self, Align, Color, DisplayDriver, Event, LvError, Part, State, Widget, UI}; use lvgl::{self, Align, Color, DisplayDriver, Event, LvError, Part, State, Widget, UI};
use lvgl_sys; use lvgl_sys;
use std::sync::{mpsc, Arc, Mutex}; use std::sync::{mpsc, Arc, Mutex};
@ -39,9 +39,18 @@ fn main() -> Result<(), LvError> {
button.set_size(180, 80)?; button.set_size(180, 80)?;
let mut btn_lbl = Label::new(&mut button)?; let mut btn_lbl = Label::new(&mut button)?;
btn_lbl.set_text("Click me!")?; btn_lbl.set_text("Click me!")?;
button.on_event(|_, event| {
let mut btn_state = false;
button.on_event(|mut btn, event| {
if let lvgl::Event::Clicked = event { if let lvgl::Event::Clicked = event {
if btn_state {
btn_lbl.set_text("Click me!").unwrap();
} else {
btn_lbl.set_text("Clicked!").unwrap();
}
btn_state = !btn_state;
println!("Clicked!"); println!("Clicked!");
btn.toggle().unwrap();
} }
})?; })?;

View file

@ -5,9 +5,14 @@ use std::process::Command;
fn main() { fn main() {
let manifest_dir = Path::new(env!("CARGO_MANIFEST_DIR")); let manifest_dir = Path::new(env!("CARGO_MANIFEST_DIR"));
let widgets_rs_path = manifest_dir.join("src/widgets/generated.rs"); let widgets_rs_path = manifest_dir.join("src/widgets/generated.rs");
let codegen_bin = manifest_dir.join("../target/debug/lvgl-codegen"); let codegen_bin = manifest_dir
.join("..")
println!("rerun-if-changed={}", codegen_bin.to_string_lossy()); .join("target")
.join("debug")
.join("lvgl-codegen")
.canonicalize()
.unwrap();
println!("cargo:rerun-if-changed={}", codegen_bin.to_string_lossy());
if env::var("LVGL_FORCE_CODEGEN").is_ok() || !widgets_rs_path.exists() { if env::var("LVGL_FORCE_CODEGEN").is_ok() || !widgets_rs_path.exists() {
println!("Generating `src/widgets/generated.rs`"); println!("Generating `src/widgets/generated.rs`");