From b0113fc7470bc001659b695e90115f655ea3b4a0 Mon Sep 17 00:00:00 2001 From: Rafael Caricio Date: Fri, 12 Jun 2020 18:54:28 +0200 Subject: [PATCH] Update readme --- README.md | 45 ++++++++-------------------------------- examples/button_click.rs | 13 ++++++++++-- lvgl/build.rs | 11 +++++++--- 3 files changed, 28 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index f089a96..6b1777c 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,14 @@ $ git submodule init $ 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: ```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 [`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] 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 - [ ] Fonts - [ ] Images @@ -90,40 +98,5 @@ List of LVGL features that impacts the library usage in general. ### 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 is missing a feature you want to make use, please send a Pull Request or open an issue. diff --git a/examples/button_click.rs b/examples/button_click.rs index 5575ff1..364ce37 100644 --- a/examples/button_click.rs +++ b/examples/button_click.rs @@ -4,7 +4,7 @@ use embedded_graphics_simulator::{ OutputSettingsBuilder, SimulatorDisplay, SimulatorEvent, Window, }; 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_sys; use std::sync::{mpsc, Arc, Mutex}; @@ -39,9 +39,18 @@ fn main() -> Result<(), LvError> { button.set_size(180, 80)?; let mut btn_lbl = Label::new(&mut button)?; 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 btn_state { + btn_lbl.set_text("Click me!").unwrap(); + } else { + btn_lbl.set_text("Clicked!").unwrap(); + } + btn_state = !btn_state; println!("Clicked!"); + btn.toggle().unwrap(); } })?; diff --git a/lvgl/build.rs b/lvgl/build.rs index 17fa0f3..da14cdb 100644 --- a/lvgl/build.rs +++ b/lvgl/build.rs @@ -5,9 +5,14 @@ use std::process::Command; fn main() { let manifest_dir = Path::new(env!("CARGO_MANIFEST_DIR")); let widgets_rs_path = manifest_dir.join("src/widgets/generated.rs"); - let codegen_bin = manifest_dir.join("../target/debug/lvgl-codegen"); - - println!("rerun-if-changed={}", codegen_bin.to_string_lossy()); + let codegen_bin = manifest_dir + .join("..") + .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() { println!("Generating `src/widgets/generated.rs`");