From 86dd9ae9b93685558681c6d61ea4670a275aae46 Mon Sep 17 00:00:00 2001 From: Nia Espera Date: Fri, 3 Mar 2023 00:27:20 +0100 Subject: [PATCH] Update LVGL version to 8.3.5 and rework API bump lvgl to 8.3.5 begin fixing for 8.x simplify style generation rework display buffer make lvgl_alloc build fix tests fix input devices --- .gitignore | 1 + examples/app.rs | 14 +- examples/arc.rs | 63 +- examples/bar.rs | 39 +- examples/button_click.rs | 38 +- examples/demo.rs | 59 +- examples/include/lv_conf.h | 1172 ++++++++++++------------ examples/{gauge.rs => meter.rs} | 68 +- lvgl-codegen/src/lib.rs | 47 +- lvgl-sys/build.rs | 11 +- lvgl-sys/shims/lvgl_sys.c | 2 +- lvgl-sys/src/lib.rs | 4 +- lvgl-sys/vendor/include/lv_conf.h | 1123 ++++++++++++----------- lvgl-sys/vendor/lvgl | 2 +- lvgl/Cargo.toml | 5 +- lvgl/src/allocator.rs | 2 +- lvgl/src/display.rs | 53 +- lvgl/src/functions.rs | 15 +- lvgl/src/input_device/generic.rs | 2 +- lvgl/src/input_device/pointer.rs | 115 +-- lvgl/src/lib.rs | 7 +- lvgl/src/lv_core/obj.rs | 75 +- lvgl/src/lv_core/style.rs | 1386 +++++------------------------ lvgl/src/mem.rs | 8 +- lvgl/src/support.rs | 125 ++- lvgl/src/widgets/arc.rs | 3 +- lvgl/src/widgets/bar.rs | 17 +- lvgl/src/widgets/gauge.rs | 15 - lvgl/src/widgets/label.rs | 23 +- lvgl/src/widgets/meter.rs | 17 + lvgl/src/widgets/mod.rs | 4 +- 31 files changed, 1823 insertions(+), 2692 deletions(-) rename examples/{gauge.rs => meter.rs} (51%) delete mode 100644 lvgl/src/widgets/gauge.rs create mode 100644 lvgl/src/widgets/meter.rs diff --git a/.gitignore b/.gitignore index 803b70ed..52dae606 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ Cargo.lock # These are backup files generated by rustfmt **/*.rs.bk +.vscode/ .idea/ examples/demo/target/ lvgl-sys/target/ diff --git a/examples/app.rs b/examples/app.rs index 84ab7e95..3bac0fdf 100644 --- a/examples/app.rs +++ b/examples/app.rs @@ -3,7 +3,7 @@ use embedded_graphics::prelude::*; use embedded_graphics_simulator::{OutputSettingsBuilder, SimulatorDisplay, Window}; use lvgl; use lvgl::widgets::Label; -use lvgl::{Display, DrawBuffer, HOR_RES_MAX, VER_RES_MAX}; +use lvgl::{Display, DrawBuffer}; use std::cell::RefCell; type ColorSpace = Rgb565; @@ -11,8 +11,11 @@ type ColorSpace = Rgb565; #[allow(unused_mut)] #[allow(unused_variables)] fn main() { + const HOR_RES: u32 = 240; + const VER_RES: u32 = 240; + let embedded_graphics_display: SimulatorDisplay = - SimulatorDisplay::new(Size::new(HOR_RES_MAX as u32, VER_RES_MAX as u32)); + SimulatorDisplay::new(Size::new(HOR_RES, VER_RES)); let output_settings = OutputSettingsBuilder::new().scale(2).build(); let mut window = Window::new("App Example", &output_settings); @@ -22,12 +25,13 @@ fn main() { // LVGL usage lvgl::init(); - let buffer = DrawBuffer::<{ (HOR_RES_MAX * VER_RES_MAX) as usize }>::new(); + let buffer = DrawBuffer::<{ (HOR_RES * VER_RES) as usize }>::new(); - let display = Display::register(&buffer, |refresh| { + let display = Display::register(buffer, HOR_RES, VER_RES, |refresh| { shared_native_display .borrow_mut() - .draw_iter(refresh.as_pixels()).unwrap(); + .draw_iter(refresh.as_pixels()) + .unwrap(); }) .unwrap(); diff --git a/examples/arc.rs b/examples/arc.rs index 162a58f4..01937059 100644 --- a/examples/arc.rs +++ b/examples/arc.rs @@ -6,14 +6,9 @@ use embedded_graphics_simulator::{ }; use lvgl; use lvgl::style::Style; -use lvgl::widgets::{Arc, Label, LabelAlign}; -use lvgl::{ - Align, Color, Display, DrawBuffer, LvError, Part, State, Widget, HOR_RES_MAX, - VER_RES_MAX, -}; +use lvgl::widgets::{Arc, Label}; +use lvgl::{Align, Color, Display, DrawBuffer, LvError, Part, Widget}; use lvgl_sys; -use std::cell::RefCell; -use std::thread; use std::time::Duration; fn mem_info() -> lvgl_sys::lv_mem_monitor_t { @@ -34,67 +29,50 @@ fn mem_info() -> lvgl_sys::lv_mem_monitor_t { } fn main() -> Result<(), LvError> { - println!("meminfo init: {:?}", mem_info()); - run_arc_demo()?; - println!("meminfo end: {:?}", mem_info()); - Ok(()) -} + const HOR_RES: u32 = 240; + const VER_RES: u32 = 240; -fn run_arc_demo() -> Result<(), LvError> { lvgl::init(); - let sim_display: SimulatorDisplay = - SimulatorDisplay::new(Size::new(HOR_RES_MAX, VER_RES_MAX)); + println!("meminfo init: {:?}", mem_info()); + let mut sim_display: SimulatorDisplay = + SimulatorDisplay::new(Size::new(HOR_RES, VER_RES)); - let output_settings = OutputSettingsBuilder::new().scale(2).build(); + let output_settings = OutputSettingsBuilder::new().scale(1).build(); let mut window = Window::new("Arc Example", &output_settings); - let shared_native_display = RefCell::new(sim_display); - - let buffer = DrawBuffer::<{ (HOR_RES_MAX * VER_RES_MAX) as usize }>::new(); + let buffer = DrawBuffer::<{ (HOR_RES * VER_RES) as usize }>::new(); - let display = Display::register(&buffer, |refresh| { - shared_native_display - .borrow_mut() - .draw_iter(refresh.as_pixels()) - .unwrap(); + let display = Display::register(buffer, HOR_RES, VER_RES, |refresh| { + sim_display.draw_iter(refresh.as_pixels()).unwrap(); })?; let mut screen = display.get_scr_act()?; let mut screen_style = Style::default(); - screen_style.set_bg_color(State::DEFAULT, Color::from_rgb((255, 255, 255))); - screen_style.set_radius(State::DEFAULT, 0); + screen_style.set_bg_color(Color::from_rgb((255, 255, 255))); + screen_style.set_radius(0); screen.add_style(Part::Main, &mut screen_style)?; // Create the arc object - let mut arc = Arc::create(&mut screen, None)?; + let mut arc = Arc::create(&mut screen)?; arc.set_size(150, 150)?; - arc.set_align(&mut screen, Align::Center, 0, 10)?; + arc.set_align(Align::Center, 0, 10)?; arc.set_start_angle(135)?; arc.set_end_angle(135)?; - let mut loading_lbl = Label::create(&mut screen, None)?; + let mut loading_lbl = Label::create(&mut screen)?; loading_lbl.set_text(CString::new("Loading...").unwrap().as_c_str())?; - loading_lbl.set_align(&mut arc, Align::OutTopMid, 0, -10)?; - loading_lbl.set_label_align(LabelAlign::Center)?; + loading_lbl.set_align(Align::OutTopMid, 0, 0)?; + //loading_lbl.set_label_align(LabelAlign::Center)?; let mut loading_style = Style::default(); - loading_style.set_text_color(State::DEFAULT, Color::from_rgb((0, 0, 0))); + loading_style.set_text_color(Color::from_rgb((0, 0, 0))); loading_lbl.add_style(Part::Main, &mut loading_style)?; let mut angle = 0; let mut forward = true; let mut i = 0; - // LVGL timer thread - thread::spawn(|| { - let interval = Duration::from_millis(5); - loop { - thread::sleep(interval); - lvgl::tick_inc(interval); - } - }); - 'running: loop { if i > 270 { forward = if forward { false } else { true }; @@ -106,7 +84,7 @@ fn run_arc_demo() -> Result<(), LvError> { i += 1; lvgl::task_handler(); - window.update(&shared_native_display.borrow()); + window.update(&sim_display); for event in window.events() { match event { @@ -116,6 +94,7 @@ fn run_arc_demo() -> Result<(), LvError> { } lvgl::tick_inc(Duration::from_millis(15)); } + println!("meminfo end: {:?}", mem_info()); Ok(()) } diff --git a/examples/bar.rs b/examples/bar.rs index 0a3df17b..b8e120e8 100644 --- a/examples/bar.rs +++ b/examples/bar.rs @@ -6,27 +6,26 @@ use embedded_graphics_simulator::{ }; use lvgl; use lvgl::style::Style; -use lvgl::widgets::{Bar, Label, LabelAlign}; -use lvgl::{ - Align, Animation, Color, Display, DrawBuffer, Event, LvError, Part, State, Widget, HOR_RES_MAX, - VER_RES_MAX, -}; +use lvgl::widgets::{Bar, Label}; +use lvgl::{Align, Animation, Color, Display, DrawBuffer, Event, LvError, Part, Widget}; use std::cell::RefCell; use std::time::Duration; fn main() -> Result<(), LvError> { + const HOR_RES: u32 = 240; + const VER_RES: u32 = 240; + lvgl::init(); - let sim_display: SimulatorDisplay = - SimulatorDisplay::new(Size::new(HOR_RES_MAX, VER_RES_MAX)); + let sim_display: SimulatorDisplay = SimulatorDisplay::new(Size::new(HOR_RES, VER_RES)); let output_settings = OutputSettingsBuilder::new().scale(2).build(); let mut window = Window::new("Bar Example", &output_settings); let shared_native_display = RefCell::new(sim_display); - let buffer = DrawBuffer::<{ (HOR_RES_MAX * VER_RES_MAX) as usize }>::new(); + let buffer = DrawBuffer::<{ (HOR_RES * VER_RES) as usize }>::new(); - let display = Display::register(&buffer, |refresh| { + let display = Display::register(buffer, HOR_RES, VER_RES, |refresh| { shared_native_display .borrow_mut() .draw_iter(refresh.as_pixels()) @@ -36,31 +35,31 @@ fn main() -> Result<(), LvError> { let mut screen = display.get_scr_act()?; let mut screen_style = Style::default(); - screen_style.set_bg_color(State::DEFAULT, Color::from_rgb((255, 255, 255))); - screen_style.set_radius(State::DEFAULT, 0); + screen_style.set_bg_color(Color::from_rgb((255, 255, 255))); + screen_style.set_radius(0); screen.add_style(Part::Main, &mut screen_style)?; // Create the bar object - let mut bar = Bar::create(&mut screen, None)?; + let mut bar = Bar::create(&mut screen)?; bar.set_size(175, 20)?; - bar.set_align(&mut screen, Align::Center, 0, 10)?; + bar.set_align(Align::Center, 0, 10)?; bar.set_range(0, 100)?; bar.on_event(|_b, _e| { println!("Completed!"); })?; - // // Set the indicator style for the bar object + // Set the indicator style for the bar object let mut ind_style = Style::default(); - ind_style.set_bg_color(State::DEFAULT, Color::from_rgb((100, 245, 100))); - bar.add_style(Part::All, &mut ind_style)?; + ind_style.set_bg_color(Color::from_rgb((100, 245, 100))); + bar.add_style(Part::Any, &mut ind_style)?; - let mut loading_lbl = Label::create(&mut screen, None)?; + let mut loading_lbl = Label::create(&mut screen)?; loading_lbl.set_text(CString::new("Loading...").unwrap().as_c_str())?; - loading_lbl.set_align(&mut bar, Align::OutTopMid, 0, -10)?; - loading_lbl.set_label_align(LabelAlign::Center)?; + loading_lbl.set_align(Align::OutTopMid, 0, 0)?; + //loading_lbl.set_label_align(LabelAlign::Center)?; let mut loading_style = Style::default(); - loading_style.set_text_color(State::DEFAULT, Color::from_rgb((0, 0, 0))); + loading_style.set_text_color(Color::from_rgb((0, 0, 0))); loading_lbl.add_style(Part::Main, &mut loading_style)?; let mut i = 0; diff --git a/examples/button_click.rs b/examples/button_click.rs index 7d809ba6..ea4926f1 100644 --- a/examples/button_click.rs +++ b/examples/button_click.rs @@ -12,30 +12,25 @@ use lvgl::input_device::{ }; use lvgl::style::Style; use lvgl::widgets::{Btn, Label}; -use lvgl::{ - Align, Color, Display, DrawBuffer, LvError, Part, State, Widget, HOR_RES_MAX, VER_RES_MAX, -}; -use std::cell::RefCell; +use lvgl::{Align, Color, Display, DrawBuffer, LvError, Part, Widget}; use std::time::Duration; #[allow(unused_assignments)] fn main() -> Result<(), LvError> { + const HOR_RES: u32 = 240; + const VER_RES: u32 = 240; + lvgl::init(); - let sim_display: SimulatorDisplay = - SimulatorDisplay::new(Size::new(HOR_RES_MAX, VER_RES_MAX)); + let mut sim_display: SimulatorDisplay = + SimulatorDisplay::new(Size::new(HOR_RES, VER_RES)); let output_settings = OutputSettingsBuilder::new().scale(2).build(); let mut window = Window::new("Button Example", &output_settings); - let shared_native_display = RefCell::new(sim_display); + let buffer = DrawBuffer::<{ (HOR_RES * VER_RES) as usize }>::new(); - let buffer = DrawBuffer::<{ (HOR_RES_MAX * VER_RES_MAX) as usize }>::new(); - - let display = Display::register(&buffer, |refresh| { - shared_native_display - .borrow_mut() - .draw_iter(refresh.as_pixels()) - .unwrap(); + let display = Display::register(buffer, HOR_RES, VER_RES, |refresh| { + sim_display.draw_iter(refresh.as_pixels()).unwrap(); })?; // Define the initial state of your input @@ -49,17 +44,17 @@ fn main() -> Result<(), LvError> { let mut screen = display.get_scr_act()?; let mut screen_style = Style::default(); - screen_style.set_bg_color(State::DEFAULT, Color::from_rgb((0, 0, 0))); + screen_style.set_bg_color(Color::from_rgb((0, 0, 0))); screen.add_style(Part::Main, &mut screen_style)?; // Create the button - let mut button = Btn::create(&mut screen, None)?; - button.set_align(&mut screen, Align::InLeftMid, 30, 0)?; + let mut button = Btn::create(&mut screen)?; + button.set_align(Align::LeftMid, 30, 0)?; button.set_size(180, 80)?; - let mut btn_lbl = Label::create(&mut button, None)?; + let mut btn_lbl = Label::create(&mut button)?; btn_lbl.set_text(CString::new("Click me!").unwrap().as_c_str())?; let mut btn_state = false; - button.on_event(|mut btn, event| { + button.on_event(|_btn, event| { println!("Button received event: {:?}", event); if let lvgl::Event::Clicked = event { if btn_state { @@ -70,14 +65,14 @@ fn main() -> Result<(), LvError> { btn_lbl.set_text(nt.as_c_str()).unwrap(); } btn_state = !btn_state; - btn.toggle().unwrap(); + //btn.toggle().unwrap(); } })?; let mut latest_touch_point = Point::new(0, 0); 'running: loop { lvgl::task_handler(); - window.update(&shared_native_display.borrow()); + window.update(&sim_display); let mut events = window.events().peekable(); @@ -102,7 +97,6 @@ fn main() -> Result<(), LvError> { _ => {} } } - lvgl::tick_inc(Duration::from_millis(15)); } diff --git a/examples/demo.rs b/examples/demo.rs index bc776177..dcb602cf 100644 --- a/examples/demo.rs +++ b/examples/demo.rs @@ -6,29 +6,25 @@ use embedded_graphics_simulator::{ }; use lvgl; use lvgl::style::Style; -use lvgl::widgets::{Label, LabelAlign}; -use lvgl::{ - Align, Color, Display, DrawBuffer, LvError, Part, State, Widget, HOR_RES_MAX, - VER_RES_MAX, -}; +use lvgl::widgets::Label; +use lvgl::{Align, Color, Display, DrawBuffer, LvError, Part, TextAlign, Widget}; use lvgl_sys; -use std::cell::RefCell; -use std::thread; use std::thread::sleep; use std::time::Duration; fn main() -> Result<(), LvError> { - lvgl::init(); - let sim_display: SimulatorDisplay = - SimulatorDisplay::new(Size::new(HOR_RES_MAX, VER_RES_MAX)); + const HOR_RES: u32 = 240; + const VER_RES: u32 = 240; + lvgl::init(); + let mut sim_display: SimulatorDisplay = + SimulatorDisplay::new(Size::new(HOR_RES, VER_RES)); let output_settings = OutputSettingsBuilder::new().scale(1).build(); let mut window = Window::new("PineTime", &output_settings); - let shared_native_display = RefCell::new(sim_display); // LVGL will render the graphics here first, and seed the rendered image to the // display. The buffer size can be set freely. - let buffer = DrawBuffer::<{ (HOR_RES_MAX * VER_RES_MAX) as usize }>::new(); + let buffer = DrawBuffer::<{ (HOR_RES * VER_RES / 10) as usize }>::new(); // // const NUMBER_OF_DISPLAYS: usize = 1; // static DISPLAY_REGISTRY: DisplayRegistry = DisplayRegistry::empty(); @@ -37,10 +33,8 @@ fn main() -> Result<(), LvError> { // Register your display update callback with LVGL. The closure you pass here will be called // whenever LVGL has updates to be painted to the display. - let display = Display::register(&buffer, |refresh| { - shared_native_display - .borrow_mut() - .draw_iter(refresh.as_pixels()).unwrap(); + let display = Display::register(buffer, HOR_RES, VER_RES, |refresh| { + sim_display.draw_iter(refresh.as_pixels()).unwrap(); })?; // Create screen and widgets @@ -49,16 +43,17 @@ fn main() -> Result<(), LvError> { println!("Before all widgets: {:?}", mem_info()); let mut screen_style = Style::default(); - screen_style.set_bg_color(State::DEFAULT, Color::from_rgb((0, 0, 0))); - screen_style.set_radius(State::DEFAULT, 0); + screen_style.set_bg_color(Color::from_rgb((0, 0, 0))); + screen_style.set_radius(0); screen.add_style(Part::Main, &mut screen_style)?; let mut time = Label::from("20:46"); let mut style_time = Style::default(); - // style_time.set_text_font(font_noto_sans_numeric_28); - style_time.set_text_color(State::DEFAULT, Color::from_rgb((255, 255, 255))); + style_time.set_text_color(Color::from_rgb((255, 255, 255))); + style_time.set_text_align(TextAlign::Center); + // Need to set font too time.add_style(Part::Main, &mut style_time)?; - time.set_align(&mut screen, Align::Center, 0, 0)?; + time.set_align(Align::Center, 0, 0)?; time.set_width(240)?; time.set_height(240)?; @@ -66,24 +61,13 @@ fn main() -> Result<(), LvError> { bt.set_width(50)?; bt.set_height(80)?; bt.set_recolor(true)?; - bt.set_label_align(LabelAlign::Left)?; - bt.set_align(&mut screen, Align::InTopLeft, 0, 0)?; + bt.set_align(Align::TopLeft, 0, 0)?; let mut power: Label = "#fade2a 20%#".into(); power.set_recolor(true)?; power.set_width(80)?; power.set_height(20)?; - power.set_label_align(LabelAlign::Right)?; - power.set_align(&mut screen, Align::InTopRight, 0, 0)?; - - // LVGL timer thread - thread::spawn(|| { - let interval = Duration::from_millis(5); - loop { - thread::sleep(interval); - lvgl::tick_inc(interval); - } - }); + power.set_align(Align::TopRight, 40, 0)?; let mut i = 0; 'running: loop { @@ -95,7 +79,7 @@ fn main() -> Result<(), LvError> { i = 1 + i; lvgl::task_handler(); - window.update(&shared_native_display.borrow()); + window.update(&sim_display); for event in window.events() { match event { @@ -103,11 +87,12 @@ fn main() -> Result<(), LvError> { _ => {} } } - println!("During run: {:?}", mem_info()); + //println!("During run: {:?}", mem_info()); sleep(Duration::from_secs(1)); + lvgl::tick_inc(Duration::from_secs(1)); } - println!("Final part of demo app: {:?}", mem_info()); + //println!("Final part of demo app: {:?}", mem_info()); Ok(()) } diff --git a/examples/include/lv_conf.h b/examples/include/lv_conf.h index cc5f026d..06455cc1 100644 --- a/examples/include/lv_conf.h +++ b/examples/include/lv_conf.h @@ -1,762 +1,762 @@ /** * @file lv_conf.h - * Configuration file for v7.10.1 + * Configuration file for v8.3.5 */ /* - * COPY THIS FILE AS `lv_conf.h` NEXT TO the `lvgl` FOLDER + * Copy this file as `lv_conf.h` + * 1. simply next to the `lvgl` folder + * 2. or any other places and + * - define `LV_CONF_INCLUDE_SIMPLE` + * - add the path as include path */ +/* clang-format off */ #if 1 /*Set it to "1" to enable content*/ #ifndef LV_CONF_H #define LV_CONF_H -/* clang-format off */ #include /*==================== - Graphical settings + COLOR SETTINGS *====================*/ -/* Maximal horizontal and vertical resolution to support by the library.*/ -#define LV_HOR_RES_MAX (240) -#define LV_VER_RES_MAX (240) +/*Color depth: 1 (1 byte per pixel), 8 (RGB332), 16 (RGB565), 32 (ARGB8888)*/ +#define LV_COLOR_DEPTH 16 -/* Color depth: - * - 1: 1 byte per pixel - * - 8: RGB332 - * - 16: RGB565 - * - 32: ARGB8888 - */ -#define LV_COLOR_DEPTH 16 - -/* Swap the 2 bytes of RGB565 color. - * Useful if the display has a 8 bit interface (e.g. SPI)*/ -#define LV_COLOR_16_SWAP 0 - -/* 1: Enable screen transparency. - * Useful for OSD or other overlapping GUIs. - * Requires `LV_COLOR_DEPTH = 32` colors and the screen's style should be modified: `style.body.opa = ...`*/ -#define LV_COLOR_SCREEN_TRANSP 0 - -/*Images pixels with this color will not be drawn (with chroma keying)*/ -#define LV_COLOR_TRANSP LV_COLOR_LIME /*LV_COLOR_LIME: pure green*/ - -/* Enable anti-aliasing (lines, and radiuses will be smoothed) */ -#define LV_ANTIALIAS 1 - -/* Default display refresh period. - * Can be changed in the display driver (`lv_disp_drv_t`).*/ -#define LV_DISP_DEF_REFR_PERIOD 30 /*[ms]*/ - -/* Dot Per Inch: used to initialize default sizes. - * E.g. a button with width = LV_DPI / 2 -> half inch wide - * (Not so important, you can adjust it to modify default sizes and spaces)*/ -#define LV_DPI 130 /*[px]*/ - -/* The the real width of the display changes some default values: - * default object sizes, layout of examples, etc. - * According to the width of the display (hor. res. / dpi) - * the displays fall in 4 categories. - * The 4th is extra large which has no upper limit so not listed here - * The upper limit of the categories are set below in 0.1 inch unit. - */ -#define LV_DISP_SMALL_LIMIT 30 -#define LV_DISP_MEDIUM_LIMIT 50 -#define LV_DISP_LARGE_LIMIT 70 +/*Swap the 2 bytes of RGB565 color. Useful if the display has an 8-bit interface (e.g. SPI)*/ +#define LV_COLOR_16_SWAP 0 + +/*Enable features to draw on transparent background. + *It's required if opa, and transform_* style properties are used. + *Can be also used if the UI is above another layer, e.g. an OSD menu or video player.*/ +#define LV_COLOR_SCREEN_TRANSP 0 -/* Type of coordinates. Should be `int16_t` (or `int32_t` for extreme cases) */ -typedef int16_t lv_coord_t; +/* Adjust color mix functions rounding. GPUs might calculate color mix (blending) differently. + * 0: round down, 64: round up from x.75, 128: round up from half, 192: round up from x.25, 254: round up */ +#define LV_COLOR_MIX_ROUND_OFS 0 + +/*Images pixels with this color will not be drawn if they are chroma keyed)*/ +#define LV_COLOR_CHROMA_KEY lv_color_hex(0x00ff00) /*pure green*/ /*========================= - Memory manager settings + MEMORY SETTINGS *=========================*/ -/* LittelvGL's internal memory manager's settings. - * The graphical objects and other related data are stored here. */ - -/* 1: use custom malloc/free, 0: use the built-in `lv_mem_alloc` and `lv_mem_free` */ -#define LV_MEM_CUSTOM 0 +/*1: use custom malloc/free, 0: use the built-in `lv_mem_alloc()` and `lv_mem_free()`*/ +#define LV_MEM_CUSTOM 0 #if LV_MEM_CUSTOM == 0 -/* Size of the memory used by `lv_mem_alloc` in bytes (>= 2kB)*/ -# define LV_MEM_SIZE (14U * 1024U) + /*Size of the memory available for `lv_mem_alloc()` in bytes (>= 2kB)*/ + #define LV_MEM_SIZE (1024U * 1024U) /*[bytes]*/ -/* Compiler prefix for a big array declaration */ -# define LV_MEM_ATTR + /*Set an address for the memory pool instead of allocating it as a normal array. Can be in external SRAM too.*/ + #define LV_MEM_ADR 0 /*0: unused*/ + /*Instead of an address give a memory allocator that will be called to get a memory pool for LVGL. E.g. my_malloc*/ + #if LV_MEM_ADR == 0 + #undef LV_MEM_POOL_INCLUDE + #undef LV_MEM_POOL_ALLOC + #endif -/* Set an address for the memory pool instead of allocating it as an array. - * Can be in external SRAM too. */ -# define LV_MEM_ADR 0 - -/* Automatically defrag. on free. Defrag. means joining the adjacent free cells. */ -# define LV_MEM_AUTO_DEFRAG 1 #else /*LV_MEM_CUSTOM*/ -# define LV_MEM_CUSTOM_INCLUDE /*Header for the dynamic memory function*/ -# define LV_MEM_CUSTOM_ALLOC malloc /*Wrapper to malloc*/ -# define LV_MEM_CUSTOM_FREE free /*Wrapper to free*/ + #define LV_MEM_CUSTOM_INCLUDE /*Header for the dynamic memory function*/ + #define LV_MEM_CUSTOM_ALLOC malloc + #define LV_MEM_CUSTOM_FREE free + #define LV_MEM_CUSTOM_REALLOC realloc #endif /*LV_MEM_CUSTOM*/ -/* Use the standard memcpy and memset instead of LVGL's own functions. - * The standard functions might or might not be faster depending on their implementation. */ -#define LV_MEMCPY_MEMSET_STD 0 +/*Number of the intermediate memory buffer used during rendering and other internal processing mechanisms. + *You will see an error log message if there wasn't enough buffers. */ +#define LV_MEM_BUF_MAX_NUM 16 -/* Garbage Collector settings - * Used if lvgl is binded to higher level language and the memory is managed by that language */ -#define LV_ENABLE_GC 0 -#if LV_ENABLE_GC != 0 -# define LV_GC_INCLUDE "gc.h" /*Include Garbage Collector related things*/ -# define LV_MEM_CUSTOM_REALLOC your_realloc /*Wrapper to realloc*/ -# define LV_MEM_CUSTOM_GET_SIZE your_mem_get_size /*Wrapper to lv_mem_get_size*/ -#endif /* LV_ENABLE_GC */ +/*Use the standard `memcpy` and `memset` instead of LVGL's own functions. (Might or might not be faster).*/ +#define LV_MEMCPY_MEMSET_STD 0 -/*======================= - Input device settings - *=======================*/ +/*==================== + HAL SETTINGS + *====================*/ -/* Input device default settings. - * Can be changed in the Input device driver (`lv_indev_drv_t`)*/ +/*Default display refresh period. LVG will redraw changed areas with this period time*/ +#define LV_DISP_DEF_REFR_PERIOD 30 /*[ms]*/ + +/*Input device read period in milliseconds*/ +#define LV_INDEV_DEF_READ_PERIOD 30 /*[ms]*/ + +/*Use a custom tick source that tells the elapsed time in milliseconds. + *It removes the need to manually update the tick with `lv_tick_inc()`)*/ +#define LV_TICK_CUSTOM 0 +#if LV_TICK_CUSTOM + #define LV_TICK_CUSTOM_INCLUDE "Arduino.h" /*Header for the system time function*/ + #define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current system time in ms*/ + /*If using lvgl as ESP32 component*/ + // #define LV_TICK_CUSTOM_INCLUDE "esp_timer.h" + // #define LV_TICK_CUSTOM_SYS_TIME_EXPR ((esp_timer_get_time() / 1000LL)) +#endif /*LV_TICK_CUSTOM*/ -/* Input device read period in milliseconds */ -#define LV_INDEV_DEF_READ_PERIOD 30 +/*Default Dot Per Inch. Used to initialize default sizes such as widgets sized, style paddings. + *(Not so important, you can adjust it to modify default sizes and spaces)*/ +#define LV_DPI_DEF 130 /*[px/inch]*/ -/* Drag threshold in pixels */ -#define LV_INDEV_DEF_DRAG_LIMIT 10 +/*======================= + * FEATURE CONFIGURATION + *=======================*/ -/* Drag throw slow-down in [%]. Greater value -> faster slow-down */ -#define LV_INDEV_DEF_DRAG_THROW 10 +/*------------- + * Drawing + *-----------*/ -/* Long press time in milliseconds. - * Time to send `LV_EVENT_LONG_PRESSED`) */ -#define LV_INDEV_DEF_LONG_PRESS_TIME 400 +/*Enable complex draw engine. + *Required to draw shadow, gradient, rounded corners, circles, arc, skew lines, image transformations or any masks*/ +#define LV_DRAW_COMPLEX 1 +#if LV_DRAW_COMPLEX != 0 -/* Repeated trigger period in long press [ms] - * Time between `LV_EVENT_LONG_PRESSED_REPEAT */ -#define LV_INDEV_DEF_LONG_PRESS_REP_TIME 100 + /*Allow buffering some shadow calculation. + *LV_SHADOW_CACHE_SIZE is the max. shadow size to buffer, where shadow size is `shadow_width + radius` + *Caching has LV_SHADOW_CACHE_SIZE^2 RAM cost*/ + #define LV_SHADOW_CACHE_SIZE 0 -/* Gesture threshold in pixels */ -#define LV_INDEV_DEF_GESTURE_LIMIT 50 + /* Set number of maximally cached circle data. + * The circumference of 1/4 circle are saved for anti-aliasing + * radius * 4 bytes are used per circle (the most often used radiuses are saved) + * 0: to disable caching */ + #define LV_CIRCLE_CACHE_SIZE 4 +#endif /*LV_DRAW_COMPLEX*/ -/* Gesture min velocity at release before swipe (pixels)*/ -#define LV_INDEV_DEF_GESTURE_MIN_VELOCITY 3 +/** + * "Simple layers" are used when a widget has `style_opa < 255` to buffer the widget into a layer + * and blend it as an image with the given opacity. + * Note that `bg_opa`, `text_opa` etc don't require buffering into layer) + * The widget can be buffered in smaller chunks to avoid using large buffers. + * + * - LV_LAYER_SIMPLE_BUF_SIZE: [bytes] the optimal target buffer size. LVGL will try to allocate it + * - LV_LAYER_SIMPLE_FALLBACK_BUF_SIZE: [bytes] used if `LV_LAYER_SIMPLE_BUF_SIZE` couldn't be allocated. + * + * Both buffer sizes are in bytes. + * "Transformed layers" (where transform_angle/zoom properties are used) use larger buffers + * and can't be drawn in chunks. So these settings affects only widgets with opacity. + */ +#define LV_LAYER_SIMPLE_BUF_SIZE (24 * 1024) +#define LV_LAYER_SIMPLE_FALLBACK_BUF_SIZE (3 * 1024) + +/*Default image cache size. Image caching keeps the images opened. + *If only the built-in image formats are used there is no real advantage of caching. (I.e. if no new image decoder is added) + *With complex image decoders (e.g. PNG or JPG) caching can save the continuous open/decode of images. + *However the opened images might consume additional RAM. + *0: to disable caching*/ +#define LV_IMG_CACHE_DEF_SIZE 0 + +/*Number of stops allowed per gradient. Increase this to allow more stops. + *This adds (sizeof(lv_color_t) + 1) bytes per additional stop*/ +#define LV_GRADIENT_MAX_STOPS 2 + +/*Default gradient buffer size. + *When LVGL calculates the gradient "maps" it can save them into a cache to avoid calculating them again. + *LV_GRAD_CACHE_DEF_SIZE sets the size of this cache in bytes. + *If the cache is too small the map will be allocated only while it's required for the drawing. + *0 mean no caching.*/ +#define LV_GRAD_CACHE_DEF_SIZE 0 + +/*Allow dithering the gradients (to achieve visual smooth color gradients on limited color depth display) + *LV_DITHER_GRADIENT implies allocating one or two more lines of the object's rendering surface + *The increase in memory consumption is (32 bits * object width) plus 24 bits * object width if using error diffusion */ +#define LV_DITHER_GRADIENT 0 +#if LV_DITHER_GRADIENT + /*Add support for error diffusion dithering. + *Error diffusion dithering gets a much better visual result, but implies more CPU consumption and memory when drawing. + *The increase in memory consumption is (24 bits * object's width)*/ + #define LV_DITHER_ERROR_DIFFUSION 0 +#endif -/*================== - * Feature usage - *==================*/ +/*Maximum buffer size to allocate for rotation. + *Only used if software rotation is enabled in the display driver.*/ +#define LV_DISP_ROT_MAX_BUF (10*1024) -/*1: Enable the Animations */ -#define LV_USE_ANIMATION 1 -#if LV_USE_ANIMATION +/*------------- + * GPU + *-----------*/ -/*Declare the type of the user data of animations (can be e.g. `void *`, `int`, `struct`)*/ -typedef void * lv_anim_user_data_t; +/*Use Arm's 2D acceleration library Arm-2D */ +#define LV_USE_GPU_ARM2D 0 +/*Use STM32's DMA2D (aka Chrom Art) GPU*/ +#define LV_USE_GPU_STM32_DMA2D 0 +#if LV_USE_GPU_STM32_DMA2D + /*Must be defined to include path of CMSIS header of target processor + e.g. "stm32f769xx.h" or "stm32f429xx.h"*/ + #define LV_GPU_DMA2D_CMSIS_INCLUDE #endif -/* 1: Enable shadow drawing on rectangles*/ -#define LV_USE_SHADOW 1 -#if LV_USE_SHADOW -/* Allow buffering some shadow calculation - * LV_SHADOW_CACHE_SIZE is the max. shadow size to buffer, - * where shadow size is `shadow_width + radius` - * Caching has LV_SHADOW_CACHE_SIZE^2 RAM cost*/ -#define LV_SHADOW_CACHE_SIZE 0 +/*Use SWM341's DMA2D GPU*/ +#define LV_USE_GPU_SWM341_DMA2D 0 +#if LV_USE_GPU_SWM341_DMA2D + #define LV_GPU_SWM341_DMA2D_INCLUDE "SWM341.h" #endif -/*1: enable outline drawing on rectangles*/ -#define LV_USE_OUTLINE 1 - -/*1: enable pattern drawing on rectangles*/ -#define LV_USE_PATTERN 1 - -/*1: enable value string drawing on rectangles*/ -#define LV_USE_VALUE_STR 1 - -/* 1: Use other blend modes than normal (`LV_BLEND_MODE_...`)*/ -#define LV_USE_BLEND_MODES 1 - -/* 1: Use the `opa_scale` style property to set the opacity of an object and its children at once*/ -#define LV_USE_OPA_SCALE 1 - -/* 1: Use image zoom and rotation*/ -#define LV_USE_IMG_TRANSFORM 1 +/*Use NXP's PXP GPU iMX RTxxx platforms*/ +#define LV_USE_GPU_NXP_PXP 0 +#if LV_USE_GPU_NXP_PXP + /*1: Add default bare metal and FreeRTOS interrupt handling routines for PXP (lv_gpu_nxp_pxp_osa.c) + * and call lv_gpu_nxp_pxp_init() automatically during lv_init(). Note that symbol SDK_OS_FREE_RTOS + * has to be defined in order to use FreeRTOS OSA, otherwise bare-metal implementation is selected. + *0: lv_gpu_nxp_pxp_init() has to be called manually before lv_init() + */ + #define LV_USE_GPU_NXP_PXP_AUTO_INIT 0 +#endif -/* 1: Enable object groups (for keyboard/encoder navigation) */ -#define LV_USE_GROUP 1 -#if LV_USE_GROUP -typedef void * lv_group_user_data_t; -#endif /*LV_USE_GROUP*/ +/*Use NXP's VG-Lite GPU iMX RTxxx platforms*/ +#define LV_USE_GPU_NXP_VG_LITE 0 + +/*Use SDL renderer API*/ +#define LV_USE_GPU_SDL 0 +#if LV_USE_GPU_SDL + #define LV_GPU_SDL_INCLUDE_PATH + /*Texture cache size, 8MB by default*/ + #define LV_GPU_SDL_LRU_SIZE (1024 * 1024 * 8) + /*Custom blend mode for mask drawing, disable if you need to link with older SDL2 lib*/ + #define LV_GPU_SDL_CUSTOM_BLEND_MODE (SDL_VERSION_ATLEAST(2, 0, 6)) +#endif -/* 1: Enable GPU interface*/ -#define LV_USE_GPU 1 /*Only enables `gpu_fill_cb` and `gpu_blend_cb` in the disp. drv- */ -#define LV_USE_GPU_STM32_DMA2D 0 -/*If enabling LV_USE_GPU_STM32_DMA2D, LV_GPU_DMA2D_CMSIS_INCLUDE must be defined to include path of CMSIS header of target processor -e.g. "stm32f769xx.h" or "stm32f429xx.h" */ -#define LV_GPU_DMA2D_CMSIS_INCLUDE +/*------------- + * Logging + *-----------*/ -/*1: Use PXP for CPU off-load on NXP RTxxx platforms */ -#define LV_USE_GPU_NXP_PXP 0 +/*Enable the log module*/ +#define LV_USE_LOG 0 +#if LV_USE_LOG -/*1: Add default bare metal and FreeRTOS interrupt handling routines for PXP (lv_gpu_nxp_pxp_osa.c) - * and call lv_gpu_nxp_pxp_init() automatically during lv_init(). Note that symbol FSL_RTOS_FREE_RTOS - * has to be defined in order to use FreeRTOS OSA, otherwise bare-metal implementation is selected. - *0: lv_gpu_nxp_pxp_init() has to be called manually before lv_init() - * */ -#define LV_USE_GPU_NXP_PXP_AUTO_INIT 0 + /*How important log should be added: + *LV_LOG_LEVEL_TRACE A lot of logs to give detailed information + *LV_LOG_LEVEL_INFO Log important events + *LV_LOG_LEVEL_WARN Log if something unwanted happened but didn't cause a problem + *LV_LOG_LEVEL_ERROR Only critical issue, when the system may fail + *LV_LOG_LEVEL_USER Only logs added by the user + *LV_LOG_LEVEL_NONE Do not log anything*/ + #define LV_LOG_LEVEL LV_LOG_LEVEL_WARN + + /*1: Print the log with 'printf'; + *0: User need to register a callback with `lv_log_register_print_cb()`*/ + #define LV_LOG_PRINTF 1 + + /*Enable/disable LV_LOG_TRACE in modules that produces a huge number of logs*/ + #define LV_LOG_TRACE_MEM 1 + #define LV_LOG_TRACE_TIMER 1 + #define LV_LOG_TRACE_INDEV 1 + #define LV_LOG_TRACE_DISP_REFR 1 + #define LV_LOG_TRACE_EVENT 1 + #define LV_LOG_TRACE_OBJ_CREATE 1 + #define LV_LOG_TRACE_LAYOUT 1 + #define LV_LOG_TRACE_ANIM 1 -/*1: Use VG-Lite for CPU offload on NXP RTxxx platforms */ -#define LV_USE_GPU_NXP_VG_LITE 0 +#endif /*LV_USE_LOG*/ -/* 1: Enable file system (might be required for images */ -#define LV_USE_FILESYSTEM 1 -#if LV_USE_FILESYSTEM -/*Declare the type of the user data of file system drivers (can be e.g. `void *`, `int`, `struct`)*/ -typedef void * lv_fs_drv_user_data_t; +/*------------- + * Asserts + *-----------*/ + +/*Enable asserts if an operation is failed or an invalid data is found. + *If LV_USE_LOG is enabled an error message will be printed on failure*/ +#define LV_USE_ASSERT_NULL 1 /*Check if the parameter is NULL. (Very fast, recommended)*/ +#define LV_USE_ASSERT_MALLOC 1 /*Checks is the memory is successfully allocated or no. (Very fast, recommended)*/ +#define LV_USE_ASSERT_STYLE 0 /*Check if the styles are properly initialized. (Very fast, recommended)*/ +#define LV_USE_ASSERT_MEM_INTEGRITY 0 /*Check the integrity of `lv_mem` after critical operations. (Slow)*/ +#define LV_USE_ASSERT_OBJ 0 /*Check the object's type and existence (e.g. not deleted). (Slow)*/ + +/*Add a custom handler when assert happens e.g. to restart the MCU*/ +#define LV_ASSERT_HANDLER_INCLUDE +#define LV_ASSERT_HANDLER while(1); /*Halt by default*/ + +/*------------- + * Others + *-----------*/ + +/*1: Show CPU usage and FPS count*/ +#define LV_USE_PERF_MONITOR 0 +#if LV_USE_PERF_MONITOR + #define LV_USE_PERF_MONITOR_POS LV_ALIGN_BOTTOM_RIGHT #endif -/*1: Add a `user_data` to drivers and objects*/ -#define LV_USE_USER_DATA 1 - -/*1: Show CPU usage and FPS count in the right bottom corner*/ -#define LV_USE_PERF_MONITOR 0 - -/*1: Use the functions and types from the older API if possible */ -#define LV_USE_API_EXTENSION_V6 1 -#define LV_USE_API_EXTENSION_V7 1 - -/*======================== - * Image decoder and cache - *========================*/ +/*1: Show the used memory and the memory fragmentation + * Requires LV_MEM_CUSTOM = 0*/ +#define LV_USE_MEM_MONITOR 1 +#if LV_USE_MEM_MONITOR + #define LV_USE_MEM_MONITOR_POS LV_ALIGN_BOTTOM_LEFT +#endif -/* 1: Enable indexed (palette) images */ -#define LV_IMG_CF_INDEXED 1 +/*1: Draw random colored rectangles over the redrawn areas*/ +#define LV_USE_REFR_DEBUG 0 -/* 1: Enable alpha indexed images */ -#define LV_IMG_CF_ALPHA 1 +/*Change the built in (v)snprintf functions*/ +#define LV_SPRINTF_CUSTOM 0 +#if LV_SPRINTF_CUSTOM + #define LV_SPRINTF_INCLUDE + #define lv_snprintf snprintf + #define lv_vsnprintf vsnprintf +#else /*LV_SPRINTF_CUSTOM*/ + #define LV_SPRINTF_USE_FLOAT 0 +#endif /*LV_SPRINTF_CUSTOM*/ -/* Default image cache size. Image caching keeps the images opened. - * If only the built-in image formats are used there is no real advantage of caching. - * (I.e. no new image decoder is added) - * With complex image decoders (e.g. PNG or JPG) caching can save the continuous open/decode of images. - * However the opened images might consume additional RAM. - * Set it to 0 to disable caching */ -#define LV_IMG_CACHE_DEF_SIZE 1 +#define LV_USE_USER_DATA 1 -/*Declare the type of the user data of image decoder (can be e.g. `void *`, `int`, `struct`)*/ -typedef void * lv_img_decoder_user_data_t; +/*Garbage Collector settings + *Used if lvgl is bound to higher level language and the memory is managed by that language*/ +#define LV_ENABLE_GC 0 +#if LV_ENABLE_GC != 0 + #define LV_GC_INCLUDE "gc.h" /*Include Garbage Collector related things*/ +#endif /*LV_ENABLE_GC*/ /*===================== - * Compiler settings + * COMPILER SETTINGS *====================*/ -/* For big endian systems set to 1 */ -#define LV_BIG_ENDIAN_SYSTEM 0 +/*For big endian systems set to 1*/ +#define LV_BIG_ENDIAN_SYSTEM 0 -/* Define a custom attribute to `lv_tick_inc` function */ +/*Define a custom attribute to `lv_tick_inc` function*/ #define LV_ATTRIBUTE_TICK_INC -/* Define a custom attribute to `lv_task_handler` function */ -#define LV_ATTRIBUTE_TASK_HANDLER +/*Define a custom attribute to `lv_timer_handler` function*/ +#define LV_ATTRIBUTE_TIMER_HANDLER -/* Define a custom attribute to `lv_disp_flush_ready` function */ +/*Define a custom attribute to `lv_disp_flush_ready` function*/ #define LV_ATTRIBUTE_FLUSH_READY -/* Required alignment size for buffers */ -#define LV_ATTRIBUTE_MEM_ALIGN_SIZE +/*Required alignment size for buffers*/ +#define LV_ATTRIBUTE_MEM_ALIGN_SIZE 1 -/* With size optimization (-Os) the compiler might not align data to - * 4 or 8 byte boundary. Some HW may need even 32 or 64 bytes. - * This alignment will be explicitly applied where needed. - * LV_ATTRIBUTE_MEM_ALIGN_SIZE should be used to specify required align size. - * E.g. __attribute__((aligned(LV_ATTRIBUTE_MEM_ALIGN_SIZE))) */ +/*Will be added where memories needs to be aligned (with -Os data might not be aligned to boundary by default). + * E.g. __attribute__((aligned(4)))*/ #define LV_ATTRIBUTE_MEM_ALIGN -/* Attribute to mark large constant arrays for example - * font's bitmaps */ +/*Attribute to mark large constant arrays for example font's bitmaps*/ #define LV_ATTRIBUTE_LARGE_CONST -/* Prefix performance critical functions to place them into a faster memory (e.g RAM) - * Uses 15-20 kB extra memory */ -#define LV_ATTRIBUTE_FAST_MEM +/*Compiler prefix for a big array declaration in RAM*/ +#define LV_ATTRIBUTE_LARGE_RAM_ARRAY -/* Export integer constant to binding. - * This macro is used with constants in the form of LV_ that - * should also appear on lvgl binding API such as Micropython - * - * The default value just prevents a GCC warning. - */ -#define LV_EXPORT_CONST_INT(int_value) struct _silence_gcc_warning +/*Place performance critical functions into a faster memory (e.g RAM)*/ +#define LV_ATTRIBUTE_FAST_MEM -/* Prefix variables that are used in GPU accelerated operations, often these need to be - * placed in RAM sections that are DMA accessible */ +/*Prefix variables that are used in GPU accelerated operations, often these need to be placed in RAM sections that are DMA accessible*/ #define LV_ATTRIBUTE_DMA -/*=================== - * HAL settings - *==================*/ - -/* 1: use a custom tick source. - * It removes the need to manually update the tick with `lv_tick_inc`) */ -#define LV_TICK_CUSTOM 0 -#if LV_TICK_CUSTOM == 1 -#define LV_TICK_CUSTOM_INCLUDE "Arduino.h" /*Header for the system time function*/ -#define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current system time in ms*/ -#endif /*LV_TICK_CUSTOM*/ +/*Export integer constant to binding. This macro is used with constants in the form of LV_ that + *should also appear on LVGL binding API such as Micropython.*/ +#define LV_EXPORT_CONST_INT(int_value) struct _silence_gcc_warning /*The default value just prevents GCC warning*/ -typedef void * lv_disp_drv_user_data_t; /*Type of user data in the display driver*/ -typedef void * lv_indev_drv_user_data_t; /*Type of user data in the input device driver*/ - -/*================ - * Log settings - *===============*/ - -/*1: Enable the log module*/ -#define LV_USE_LOG 0 -#if LV_USE_LOG -/* How important log should be added: - * LV_LOG_LEVEL_TRACE A lot of logs to give detailed information - * LV_LOG_LEVEL_INFO Log important events - * LV_LOG_LEVEL_WARN Log if something unwanted happened but didn't cause a problem - * LV_LOG_LEVEL_ERROR Only critical issue, when the system may fail - * LV_LOG_LEVEL_NONE Do not log anything - */ -# define LV_LOG_LEVEL LV_LOG_LEVEL_WARN - -/* 1: Print the log with 'printf'; - * 0: user need to register a callback with `lv_log_register_print_cb`*/ -# define LV_LOG_PRINTF 0 -#endif /*LV_USE_LOG*/ - -/*================= - * Debug settings - *================*/ - -/* If Debug is enabled LittelvGL validates the parameters of the functions. - * If an invalid parameter is found an error log message is printed and - * the MCU halts at the error. (`LV_USE_LOG` should be enabled) - * If you are debugging the MCU you can pause - * the debugger to see exactly where the issue is. - * - * The behavior of asserts can be overwritten by redefining them here. - * E.g. #define LV_ASSERT_MEM(p) - */ -#define LV_USE_DEBUG 1 -#if LV_USE_DEBUG - -/*Check if the parameter is NULL. (Quite fast) */ -#define LV_USE_ASSERT_NULL 1 - -/*Checks is the memory is successfully allocated or no. (Quite fast)*/ -#define LV_USE_ASSERT_MEM 1 - -/*Check the integrity of `lv_mem` after critical operations. (Slow)*/ -#define LV_USE_ASSERT_MEM_INTEGRITY 0 - -/* Check the strings. - * Search for NULL, very long strings, invalid characters, and unnatural repetitions. (Slow) - * If disabled `LV_USE_ASSERT_NULL` will be performed instead (if it's enabled) */ -#define LV_USE_ASSERT_STR 0 - -/* Check NULL, the object's type and existence (e.g. not deleted). (Quite slow) - * If disabled `LV_USE_ASSERT_NULL` will be performed instead (if it's enabled) */ -#define LV_USE_ASSERT_OBJ 0 - -/*Check if the styles are properly initialized. (Fast)*/ -#define LV_USE_ASSERT_STYLE 0 - -#endif /*LV_USE_DEBUG*/ +/*Extend the default -32k..32k coordinate range to -4M..4M by using int32_t for coordinates instead of int16_t*/ +#define LV_USE_LARGE_COORD 0 /*================== - * FONT USAGE + * FONT USAGE *===================*/ -/* The built-in fonts contains the ASCII range and some Symbols with 4 bit-per-pixel. - * The symbols are available via `LV_SYMBOL_...` defines - * More info about fonts: https://docs.lvgl.io/v7/en/html/overview/font.html - * To create a new font go to: https://lvgl.com/ttf-font-to-c-array - */ - -/* Montserrat fonts with bpp = 4 - * https://fonts.google.com/specimen/Montserrat */ -#define LV_FONT_MONTSERRAT_8 0 -#define LV_FONT_MONTSERRAT_10 0 -#define LV_FONT_MONTSERRAT_12 0 -#define LV_FONT_MONTSERRAT_14 1 -#define LV_FONT_MONTSERRAT_16 0 -#define LV_FONT_MONTSERRAT_18 0 -#define LV_FONT_MONTSERRAT_20 0 -#define LV_FONT_MONTSERRAT_22 0 -#define LV_FONT_MONTSERRAT_24 0 -#define LV_FONT_MONTSERRAT_26 0 -#define LV_FONT_MONTSERRAT_28 0 -#define LV_FONT_MONTSERRAT_30 0 -#define LV_FONT_MONTSERRAT_32 0 -#define LV_FONT_MONTSERRAT_34 0 -#define LV_FONT_MONTSERRAT_36 0 -#define LV_FONT_MONTSERRAT_38 0 -#define LV_FONT_MONTSERRAT_40 0 -#define LV_FONT_MONTSERRAT_42 0 -#define LV_FONT_MONTSERRAT_44 0 -#define LV_FONT_MONTSERRAT_46 0 -#define LV_FONT_MONTSERRAT_48 0 - -/* Demonstrate special features */ +/*Montserrat fonts with ASCII range and some symbols using bpp = 4 + *https://fonts.google.com/specimen/Montserrat*/ +#define LV_FONT_MONTSERRAT_8 0 +#define LV_FONT_MONTSERRAT_10 0 +#define LV_FONT_MONTSERRAT_12 0 +#define LV_FONT_MONTSERRAT_14 1 +#define LV_FONT_MONTSERRAT_16 0 +#define LV_FONT_MONTSERRAT_18 0 +#define LV_FONT_MONTSERRAT_20 0 +#define LV_FONT_MONTSERRAT_22 0 +#define LV_FONT_MONTSERRAT_24 0 +#define LV_FONT_MONTSERRAT_26 0 +#define LV_FONT_MONTSERRAT_28 0 +#define LV_FONT_MONTSERRAT_30 0 +#define LV_FONT_MONTSERRAT_32 0 +#define LV_FONT_MONTSERRAT_34 0 +#define LV_FONT_MONTSERRAT_36 0 +#define LV_FONT_MONTSERRAT_38 0 +#define LV_FONT_MONTSERRAT_40 0 +#define LV_FONT_MONTSERRAT_42 0 +#define LV_FONT_MONTSERRAT_44 0 +#define LV_FONT_MONTSERRAT_46 0 +#define LV_FONT_MONTSERRAT_48 0 + +/*Demonstrate special features*/ #define LV_FONT_MONTSERRAT_12_SUBPX 0 #define LV_FONT_MONTSERRAT_28_COMPRESSED 0 /*bpp = 3*/ -#define LV_FONT_DEJAVU_16_PERSIAN_HEBREW 0 /*Hebrew, Arabic, PErisan letters and all their forms*/ +#define LV_FONT_DEJAVU_16_PERSIAN_HEBREW 0 /*Hebrew, Arabic, Persian letters and all their forms*/ #define LV_FONT_SIMSUN_16_CJK 0 /*1000 most common CJK radicals*/ -/*Pixel perfect monospace font - * http://pelulamu.net/unscii/ */ -#define LV_FONT_UNSCII_8 0 -#define LV_FONT_UNSCII_16 0 +/*Pixel perfect monospace fonts*/ +#define LV_FONT_UNSCII_8 0 +#define LV_FONT_UNSCII_16 0 -/* Optionally declare your custom fonts here. - * You can use these fonts as default font too - * and they will be available globally. E.g. - * #define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(my_font_1) \ - * LV_FONT_DECLARE(my_font_2) - */ +/*Optionally declare custom fonts here. + *You can use these fonts as default font too and they will be available globally. + *E.g. #define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(my_font_1) LV_FONT_DECLARE(my_font_2)*/ #define LV_FONT_CUSTOM_DECLARE -/* Enable it if you have fonts with a lot of characters. - * The limit depends on the font size, font face and bpp - * but with > 10,000 characters if you see issues probably you need to enable it.*/ -#define LV_FONT_FMT_TXT_LARGE 0 +/*Always set a default font*/ +#define LV_FONT_DEFAULT &lv_font_montserrat_14 -/* Enables/disables support for compressed fonts. If it's disabled, compressed - * glyphs cannot be processed by the library and won't be rendered. - */ -#define LV_USE_FONT_COMPRESSED 1 +/*Enable handling large font and/or fonts with a lot of characters. + *The limit depends on the font size, font face and bpp. + *Compiler error will be triggered if a font needs it.*/ +#define LV_FONT_FMT_TXT_LARGE 0 + +/*Enables/disables support for compressed fonts.*/ +#define LV_USE_FONT_COMPRESSED 0 -/* Enable subpixel rendering */ -#define LV_USE_FONT_SUBPX 1 +/*Enable subpixel rendering*/ +#define LV_USE_FONT_SUBPX 0 #if LV_USE_FONT_SUBPX -/* Set the pixel order of the display. - * Important only if "subpx fonts" are used. - * With "normal" font it doesn't matter. - */ -#define LV_FONT_SUBPX_BGR 0 + /*Set the pixel order of the display. Physical order of RGB channels. Doesn't matter with "normal" fonts.*/ + #define LV_FONT_SUBPX_BGR 0 /*0: RGB; 1:BGR order*/ #endif -/*Declare the type of the user data of fonts (can be e.g. `void *`, `int`, `struct`)*/ -typedef void * lv_font_user_data_t; - -/*================ - * THEME USAGE - *================*/ - -/*Always enable at least on theme*/ - -/* No theme, you can apply your styles as you need - * No flags. Set LV_THEME_DEFAULT_FLAG 0 */ -#define LV_USE_THEME_EMPTY 1 - -/*Simple to the create your theme based on it - * No flags. Set LV_THEME_DEFAULT_FLAG 0 */ -#define LV_USE_THEME_TEMPLATE 1 - -/* A fast and impressive theme. - * Flags: - * LV_THEME_MATERIAL_FLAG_LIGHT: light theme - * LV_THEME_MATERIAL_FLAG_DARK: dark theme - * LV_THEME_MATERIAL_FLAG_NO_TRANSITION: disable transitions (state change animations) - * LV_THEME_MATERIAL_FLAG_NO_FOCUS: disable indication of focused state) - * */ -#define LV_USE_THEME_MATERIAL 1 - -/* Mono-color theme for monochrome displays. - * If LV_THEME_DEFAULT_COLOR_PRIMARY is LV_COLOR_BLACK the - * texts and borders will be black and the background will be - * white. Else the colors are inverted. - * No flags. Set LV_THEME_DEFAULT_FLAG 0 */ -#define LV_USE_THEME_MONO 1 - -#define LV_THEME_DEFAULT_INCLUDE /*Include a header for the init. function*/ -#define LV_THEME_DEFAULT_INIT lv_theme_material_init -#define LV_THEME_DEFAULT_COLOR_PRIMARY lv_color_hex(0x01a2b1) -#define LV_THEME_DEFAULT_COLOR_SECONDARY lv_color_hex(0x44d1b6) -#define LV_THEME_DEFAULT_FLAG LV_THEME_MATERIAL_FLAG_LIGHT -#define LV_THEME_DEFAULT_FONT_SMALL &lv_font_montserrat_14 -#define LV_THEME_DEFAULT_FONT_NORMAL &lv_font_montserrat_14 -#define LV_THEME_DEFAULT_FONT_SUBTITLE &lv_font_montserrat_14 -#define LV_THEME_DEFAULT_FONT_TITLE &lv_font_montserrat_14 +/*Enable drawing placeholders when glyph dsc is not found*/ +#define LV_USE_FONT_PLACEHOLDER 1 /*================= - * Text settings + * TEXT SETTINGS *=================*/ -/* Select a character encoding for strings. +/** + * Select a character encoding for strings. * Your IDE or editor should have the same character encoding * - LV_TXT_ENC_UTF8 * - LV_TXT_ENC_ASCII - * */ + */ #define LV_TXT_ENC LV_TXT_ENC_UTF8 - /*Can break (wrap) texts on these chars*/ -#define LV_TXT_BREAK_CHARS " ,.;:-_" +/*Can break (wrap) texts on these chars*/ +#define LV_TXT_BREAK_CHARS " ,.;:-_" -/* If a word is at least this long, will break wherever "prettiest" - * To disable, set to a value <= 0 */ -#define LV_TXT_LINE_BREAK_LONG_LEN 0 +/*If a word is at least this long, will break wherever "prettiest" + *To disable, set to a value <= 0*/ +#define LV_TXT_LINE_BREAK_LONG_LEN 0 -/* Minimum number of characters in a long word to put on a line before a break. - * Depends on LV_TXT_LINE_BREAK_LONG_LEN. */ -#define LV_TXT_LINE_BREAK_LONG_PRE_MIN_LEN 3 +/*Minimum number of characters in a long word to put on a line before a break. + *Depends on LV_TXT_LINE_BREAK_LONG_LEN.*/ +#define LV_TXT_LINE_BREAK_LONG_PRE_MIN_LEN 3 -/* Minimum number of characters in a long word to put on a line after a break. - * Depends on LV_TXT_LINE_BREAK_LONG_LEN. */ +/*Minimum number of characters in a long word to put on a line after a break. + *Depends on LV_TXT_LINE_BREAK_LONG_LEN.*/ #define LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN 3 -/* The control character to use for signalling text recoloring. */ +/*The control character to use for signalling text recoloring.*/ #define LV_TXT_COLOR_CMD "#" -/* Support bidirectional texts. - * Allows mixing Left-to-Right and Right-to-Left texts. - * The direction will be processed according to the Unicode Bidirectional Algorithm: - * https://www.w3.org/International/articles/inline-bidi-markup/uba-basics*/ -#define LV_USE_BIDI 0 +/*Support bidirectional texts. Allows mixing Left-to-Right and Right-to-Left texts. + *The direction will be processed according to the Unicode Bidirectional Algorithm: + *https://www.w3.org/International/articles/inline-bidi-markup/uba-basics*/ +#define LV_USE_BIDI 0 #if LV_USE_BIDI -/* Set the default direction. Supported values: - * `LV_BIDI_DIR_LTR` Left-to-Right - * `LV_BIDI_DIR_RTL` Right-to-Left - * `LV_BIDI_DIR_AUTO` detect texts base direction */ -#define LV_BIDI_BASE_DIR_DEF LV_BIDI_DIR_AUTO + /*Set the default direction. Supported values: + *`LV_BASE_DIR_LTR` Left-to-Right + *`LV_BASE_DIR_RTL` Right-to-Left + *`LV_BASE_DIR_AUTO` detect texts base direction*/ + #define LV_BIDI_BASE_DIR_DEF LV_BASE_DIR_AUTO #endif -/* Enable Arabic/Persian processing - * In these languages characters should be replaced with - * an other form based on their position in the text */ +/*Enable Arabic/Persian processing + *In these languages characters should be replaced with an other form based on their position in the text*/ #define LV_USE_ARABIC_PERSIAN_CHARS 0 -/*Change the built in (v)snprintf functions*/ -#define LV_SPRINTF_CUSTOM 0 -#if LV_SPRINTF_CUSTOM -# define LV_SPRINTF_INCLUDE -# define lv_snprintf snprintf -# define lv_vsnprintf vsnprintf -#else /*!LV_SPRINTF_CUSTOM*/ -# define LV_SPRINTF_DISABLE_FLOAT 1 -#endif /*LV_SPRINTF_CUSTOM*/ +/*================== + * WIDGET USAGE + *================*/ -/*=================== - * LV_OBJ SETTINGS - *==================*/ +/*Documentation of the widgets: https://docs.lvgl.io/latest/en/html/widgets/index.html*/ + +#define LV_USE_ARC 1 + +#define LV_USE_BAR 1 -#if LV_USE_USER_DATA -/*Declare the type of the user data of object (can be e.g. `void *`, `int`, `struct`)*/ -typedef void * lv_obj_user_data_t; -/*Provide a function to free user data*/ -#define LV_USE_USER_DATA_FREE 0 -#if LV_USE_USER_DATA_FREE -# define LV_USER_DATA_FREE_INCLUDE "something.h" /*Header for user data free function*/ -/* Function prototype : void user_data_free(lv_obj_t * obj); */ -# define LV_USER_DATA_FREE (user_data_free) /*Invoking for user data free function*/ +#define LV_USE_BTN 1 + +#define LV_USE_BTNMATRIX 1 + +#define LV_USE_CANVAS 1 + +#define LV_USE_CHECKBOX 1 + +#define LV_USE_DROPDOWN 1 /*Requires: lv_label*/ + +#define LV_USE_IMG 1 /*Requires: lv_label*/ + +#define LV_USE_LABEL 1 +#if LV_USE_LABEL + #define LV_LABEL_TEXT_SELECTION 1 /*Enable selecting text of the label*/ + #define LV_LABEL_LONG_TXT_HINT 1 /*Store some extra info in labels to speed up drawing of very long texts*/ #endif + +#define LV_USE_LINE 1 + +#define LV_USE_ROLLER 1 /*Requires: lv_label*/ +#if LV_USE_ROLLER + #define LV_ROLLER_INF_PAGES 7 /*Number of extra "pages" when the roller is infinite*/ #endif -/*1: enable `lv_obj_realign()` based on `lv_obj_align()` parameters*/ -#define LV_USE_OBJ_REALIGN 1 +#define LV_USE_SLIDER 1 /*Requires: lv_bar*/ -/* Enable to make the object clickable on a larger area. - * LV_EXT_CLICK_AREA_OFF or 0: Disable this feature - * LV_EXT_CLICK_AREA_TINY: The extra area can be adjusted horizontally and vertically (0..255 px) - * LV_EXT_CLICK_AREA_FULL: The extra area can be adjusted in all 4 directions (-32k..+32k px) - */ -#define LV_USE_EXT_CLICK_AREA LV_EXT_CLICK_AREA_TINY +#define LV_USE_SWITCH 1 + +#define LV_USE_TEXTAREA 1 /*Requires: lv_label*/ +#if LV_USE_TEXTAREA != 0 + #define LV_TEXTAREA_DEF_PWD_SHOW_TIME 1500 /*ms*/ +#endif + +#define LV_USE_TABLE 1 /*================== - * LV OBJ X USAGE - *================*/ -/* - * Documentation of the object types: https://docs.lvgl.com/#Object-types - */ + * EXTRA COMPONENTS + *==================*/ -/*Arc (dependencies: -)*/ -#define LV_USE_ARC 1 +/*----------- + * Widgets + *----------*/ +#define LV_USE_ANIMIMG 1 -/*Bar (dependencies: -)*/ -#define LV_USE_BAR 1 +#define LV_USE_CALENDAR 1 +#if LV_USE_CALENDAR + #define LV_CALENDAR_WEEK_STARTS_MONDAY 0 + #if LV_CALENDAR_WEEK_STARTS_MONDAY + #define LV_CALENDAR_DEFAULT_DAY_NAMES {"Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"} + #else + #define LV_CALENDAR_DEFAULT_DAY_NAMES {"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"} + #endif -/*Button (dependencies: lv_cont*/ -#define LV_USE_BTN 1 + #define LV_CALENDAR_DEFAULT_MONTH_NAMES {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"} + #define LV_USE_CALENDAR_HEADER_ARROW 1 + #define LV_USE_CALENDAR_HEADER_DROPDOWN 1 +#endif /*LV_USE_CALENDAR*/ -/*Button matrix (dependencies: -)*/ -#define LV_USE_BTNMATRIX 1 +#define LV_USE_CHART 1 -/*Calendar (dependencies: -)*/ -#define LV_USE_CALENDAR 1 -#if LV_USE_CALENDAR -# define LV_CALENDAR_WEEK_STARTS_MONDAY 0 -#endif +#define LV_USE_COLORWHEEL 1 -/*Canvas (dependencies: lv_img)*/ -#define LV_USE_CANVAS 1 +#define LV_USE_IMGBTN 1 -/*Check box (dependencies: lv_btn, lv_label)*/ -#define LV_USE_CHECKBOX 1 +#define LV_USE_KEYBOARD 1 -/*Chart (dependencies: -)*/ -#define LV_USE_CHART 1 -#if LV_USE_CHART -# define LV_CHART_AXIS_TICK_LABEL_MAX_LEN 256 -#endif +#define LV_USE_LED 1 + +#define LV_USE_LIST 1 -/*Container (dependencies: -*/ -#define LV_USE_CONT 1 +#define LV_USE_MENU 1 -/*Color picker (dependencies: -*/ -#define LV_USE_CPICKER 1 +#define LV_USE_METER 1 -/*Drop down list (dependencies: lv_page, lv_label, lv_symbol_def.h)*/ -#define LV_USE_DROPDOWN 1 -#if LV_USE_DROPDOWN != 0 -/*Open and close default animation time [ms] (0: no animation)*/ -# define LV_DROPDOWN_DEF_ANIM_TIME 200 +#define LV_USE_MSGBOX 1 + +#define LV_USE_SPAN 1 +#if LV_USE_SPAN + /*A line text can contain maximum num of span descriptor */ + #define LV_SPAN_SNIPPET_STACK_SIZE 64 #endif -/*Gauge (dependencies:lv_bar, lv_linemeter)*/ -#define LV_USE_GAUGE 1 +#define LV_USE_SPINBOX 1 -/*Image (dependencies: lv_label*/ -#define LV_USE_IMG 1 +#define LV_USE_SPINNER 1 -/*Image Button (dependencies: lv_btn*/ -#define LV_USE_IMGBTN 1 -#if LV_USE_IMGBTN -/*1: The imgbtn requires left, mid and right parts and the width can be set freely*/ -# define LV_IMGBTN_TILED 0 -#endif +#define LV_USE_TABVIEW 1 -/*Keyboard (dependencies: lv_btnm)*/ -#define LV_USE_KEYBOARD 1 +#define LV_USE_TILEVIEW 1 -/*Label (dependencies: -*/ -#define LV_USE_LABEL 1 -#if LV_USE_LABEL != 0 -/*Hor, or ver. scroll speed [px/sec] in 'LV_LABEL_LONG_ROLL/ROLL_CIRC' mode*/ -# define LV_LABEL_DEF_SCROLL_SPEED 25 +#define LV_USE_WIN 1 -/* Waiting period at beginning/end of animation cycle */ -# define LV_LABEL_WAIT_CHAR_COUNT 3 +/*----------- + * Themes + *----------*/ -/*Enable selecting text of the label */ -# define LV_LABEL_TEXT_SEL 0 +/*A simple, impressive and very complete theme*/ +#define LV_USE_THEME_DEFAULT 1 +#if LV_USE_THEME_DEFAULT -/*Store extra some info in labels (12 bytes) to speed up drawing of very long texts*/ -# define LV_LABEL_LONG_TXT_HINT 0 -#endif + /*0: Light mode; 1: Dark mode*/ + #define LV_THEME_DEFAULT_DARK 0 -/*LED (dependencies: -)*/ -#define LV_USE_LED 1 -#if LV_USE_LED -# define LV_LED_BRIGHT_MIN 120 /*Minimal brightness*/ -# define LV_LED_BRIGHT_MAX 255 /*Maximal brightness*/ -#endif + /*1: Enable grow on press*/ + #define LV_THEME_DEFAULT_GROW 1 -/*Line (dependencies: -*/ -#define LV_USE_LINE 1 + /*Default transition time in [ms]*/ + #define LV_THEME_DEFAULT_TRANSITION_TIME 80 +#endif /*LV_USE_THEME_DEFAULT*/ -/*List (dependencies: lv_page, lv_btn, lv_label, (lv_img optionally for icons ))*/ -#define LV_USE_LIST 1 -#if LV_USE_LIST != 0 -/*Default animation time of focusing to a list element [ms] (0: no animation) */ -# define LV_LIST_DEF_ANIM_TIME 100 -#endif +/*A very simple theme that is a good starting point for a custom theme*/ +#define LV_USE_THEME_BASIC 1 -/*Line meter (dependencies: *;)*/ -#define LV_USE_LINEMETER 1 -#if LV_USE_LINEMETER -/* Draw line more precisely at cost of performance. - * Useful if there are lot of lines any minor are visible - * 0: No extra precision - * 1: Some extra precision - * 2: Best precision - */ -# define LV_LINEMETER_PRECISE 1 +/*A theme designed for monochrome displays*/ +#define LV_USE_THEME_MONO 1 + +/*----------- + * Layouts + *----------*/ + +/*A layout similar to Flexbox in CSS.*/ +#define LV_USE_FLEX 1 + +/*A layout similar to Grid in CSS.*/ +#define LV_USE_GRID 1 + +/*--------------------- + * 3rd party libraries + *--------------------*/ + +/*File system interfaces for common APIs */ + +/*API for fopen, fread, etc*/ +#define LV_USE_FS_STDIO 0 +#if LV_USE_FS_STDIO + #define LV_FS_STDIO_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/ + #define LV_FS_STDIO_PATH "" /*Set the working directory. File/directory paths will be appended to it.*/ + #define LV_FS_STDIO_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/ #endif -/*Mask (dependencies: -)*/ -#define LV_USE_OBJMASK 1 +/*API for open, read, etc*/ +#define LV_USE_FS_POSIX 0 +#if LV_USE_FS_POSIX + #define LV_FS_POSIX_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/ + #define LV_FS_POSIX_PATH "" /*Set the working directory. File/directory paths will be appended to it.*/ + #define LV_FS_POSIX_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/ +#endif -/*Message box (dependencies: lv_rect, lv_btnm, lv_label)*/ -#define LV_USE_MSGBOX 1 +/*API for CreateFile, ReadFile, etc*/ +#define LV_USE_FS_WIN32 0 +#if LV_USE_FS_WIN32 + #define LV_FS_WIN32_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/ + #define LV_FS_WIN32_PATH "" /*Set the working directory. File/directory paths will be appended to it.*/ + #define LV_FS_WIN32_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/ +#endif -/*Page (dependencies: lv_cont)*/ -#define LV_USE_PAGE 1 -#if LV_USE_PAGE != 0 -/*Focus default animation time [ms] (0: no animation)*/ -# define LV_PAGE_DEF_ANIM_TIME 400 +/*API for FATFS (needs to be added separately). Uses f_open, f_read, etc*/ +#define LV_USE_FS_FATFS 0 +#if LV_USE_FS_FATFS + #define LV_FS_FATFS_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/ + #define LV_FS_FATFS_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/ #endif -/*Preload (dependencies: lv_arc, lv_anim)*/ -#define LV_USE_SPINNER 1 -#if LV_USE_SPINNER != 0 -# define LV_SPINNER_DEF_ARC_LENGTH 60 /*[deg]*/ -# define LV_SPINNER_DEF_SPIN_TIME 1000 /*[ms]*/ -# define LV_SPINNER_DEF_ANIM LV_SPINNER_TYPE_SPINNING_ARC +/*PNG decoder library*/ +#define LV_USE_PNG 0 + +/*BMP decoder library*/ +#define LV_USE_BMP 0 + +/* JPG + split JPG decoder library. + * Split JPG is a custom format optimized for embedded systems. */ +#define LV_USE_SJPG 0 + +/*GIF decoder library*/ +#define LV_USE_GIF 0 + +/*QR code library*/ +#define LV_USE_QRCODE 0 + +/*FreeType library*/ +#define LV_USE_FREETYPE 0 +#if LV_USE_FREETYPE + /*Memory used by FreeType to cache characters [bytes] (-1: no caching)*/ + #define LV_FREETYPE_CACHE_SIZE (16 * 1024) + #if LV_FREETYPE_CACHE_SIZE >= 0 + /* 1: bitmap cache use the sbit cache, 0:bitmap cache use the image cache. */ + /* sbit cache:it is much more memory efficient for small bitmaps(font size < 256) */ + /* if font size >= 256, must be configured as image cache */ + #define LV_FREETYPE_SBIT_CACHE 0 + /* Maximum number of opened FT_Face/FT_Size objects managed by this cache instance. */ + /* (0:use system defaults) */ + #define LV_FREETYPE_CACHE_FT_FACES 0 + #define LV_FREETYPE_CACHE_FT_SIZES 0 + #endif #endif -/*Roller (dependencies: lv_ddlist)*/ -#define LV_USE_ROLLER 1 -#if LV_USE_ROLLER != 0 -/*Focus animation time [ms] (0: no animation)*/ -# define LV_ROLLER_DEF_ANIM_TIME 200 +/*Rlottie library*/ +#define LV_USE_RLOTTIE 0 -/*Number of extra "pages" when the roller is infinite*/ -# define LV_ROLLER_INF_PAGES 7 +/*FFmpeg library for image decoding and playing videos + *Supports all major image formats so do not enable other image decoder with it*/ +#define LV_USE_FFMPEG 0 +#if LV_USE_FFMPEG + /*Dump input information to stderr*/ + #define LV_FFMPEG_DUMP_FORMAT 0 #endif -/*Slider (dependencies: lv_bar)*/ -#define LV_USE_SLIDER 1 +/*----------- + * Others + *----------*/ -/*Spinbox (dependencies: lv_ta)*/ -#define LV_USE_SPINBOX 1 +/*1: Enable API to take snapshot for object*/ +#define LV_USE_SNAPSHOT 0 -/*Switch (dependencies: lv_slider)*/ -#define LV_USE_SWITCH 1 +/*1: Enable Monkey test*/ +#define LV_USE_MONKEY 0 -/*Text area (dependencies: lv_label, lv_page)*/ -#define LV_USE_TEXTAREA 1 -#if LV_USE_TEXTAREA != 0 -# define LV_TEXTAREA_DEF_CURSOR_BLINK_TIME 400 /*ms*/ -# define LV_TEXTAREA_DEF_PWD_SHOW_TIME 1500 /*ms*/ -#endif +/*1: Enable grid navigation*/ +#define LV_USE_GRIDNAV 0 -/*Table (dependencies: lv_label)*/ -#define LV_USE_TABLE 1 -#if LV_USE_TABLE -# define LV_TABLE_COL_MAX 12 -# define LV_TABLE_CELL_STYLE_CNT 4 -#endif +/*1: Enable lv_obj fragment*/ +#define LV_USE_FRAGMENT 0 + +/*1: Support using images as font in label or span widgets */ +#define LV_USE_IMGFONT 0 + +/*1: Enable a published subscriber based messaging system */ +#define LV_USE_MSG 0 + +/*1: Enable Pinyin input method*/ +/*Requires: lv_keyboard*/ +#define LV_USE_IME_PINYIN 0 +#if LV_USE_IME_PINYIN + /*1: Use default thesaurus*/ + /*If you do not use the default thesaurus, be sure to use `lv_ime_pinyin` after setting the thesauruss*/ + #define LV_IME_PINYIN_USE_DEFAULT_DICT 1 + /*Set the maximum number of candidate panels that can be displayed*/ + /*This needs to be adjusted according to the size of the screen*/ + #define LV_IME_PINYIN_CAND_TEXT_NUM 6 -/*Tab (dependencies: lv_page, lv_btnm)*/ -#define LV_USE_TABVIEW 1 -# if LV_USE_TABVIEW != 0 -/*Time of slide animation [ms] (0: no animation)*/ -# define LV_TABVIEW_DEF_ANIM_TIME 300 + /*Use 9 key input(k9)*/ + #define LV_IME_PINYIN_USE_K9_MODE 1 + #if LV_IME_PINYIN_USE_K9_MODE == 1 + #define LV_IME_PINYIN_K9_CAND_TEXT_NUM 3 + #endif // LV_IME_PINYIN_USE_K9_MODE #endif -/*Tileview (dependencies: lv_page) */ -#define LV_USE_TILEVIEW 1 -#if LV_USE_TILEVIEW -/*Time of slide animation [ms] (0: no animation)*/ -# define LV_TILEVIEW_DEF_ANIM_TIME 300 +/*================== +* EXAMPLES +*==================*/ + +/*Enable the examples to be built with the library*/ +#define LV_BUILD_EXAMPLES 1 + +/*=================== + * DEMO USAGE + ====================*/ + +/*Show some widget. It might be required to increase `LV_MEM_SIZE` */ +#define LV_USE_DEMO_WIDGETS 0 +#if LV_USE_DEMO_WIDGETS +#define LV_DEMO_WIDGETS_SLIDESHOW 0 #endif -/*Window (dependencies: lv_cont, lv_btn, lv_label, lv_img, lv_page)*/ -#define LV_USE_WIN 1 +/*Demonstrate the usage of encoder and keyboard*/ +#define LV_USE_DEMO_KEYPAD_AND_ENCODER 0 -/*================== - * Non-user section - *==================*/ +/*Benchmark your system*/ +#define LV_USE_DEMO_BENCHMARK 0 +#if LV_USE_DEMO_BENCHMARK +/*Use RGB565A8 images with 16 bit color depth instead of ARGB8565*/ +#define LV_DEMO_BENCHMARK_RGB565A8 0 +#endif -#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) /* Disable warnings for Visual Studio*/ -# define _CRT_SECURE_NO_WARNINGS +/*Stress test for LVGL*/ +#define LV_USE_DEMO_STRESS 0 + +/*Music player demo*/ +#define LV_USE_DEMO_MUSIC 0 +#if LV_USE_DEMO_MUSIC + #define LV_DEMO_MUSIC_SQUARE 0 + #define LV_DEMO_MUSIC_LANDSCAPE 0 + #define LV_DEMO_MUSIC_ROUND 0 + #define LV_DEMO_MUSIC_LARGE 0 + #define LV_DEMO_MUSIC_AUTO_PLAY 0 #endif /*--END OF LV_CONF_H--*/ #endif /*LV_CONF_H*/ -#endif /*End of "Content enable"*/ +#endif /*End of "Content enable"*/ \ No newline at end of file diff --git a/examples/gauge.rs b/examples/meter.rs similarity index 51% rename from examples/gauge.rs rename to examples/meter.rs index 4352dcc2..a94d40c3 100644 --- a/examples/gauge.rs +++ b/examples/meter.rs @@ -1,3 +1,6 @@ +// TODO: Redo this example. + +/* use embedded_graphics::pixelcolor::Rgb565; use embedded_graphics::prelude::*; use embedded_graphics_simulator::{ @@ -5,28 +8,27 @@ use embedded_graphics_simulator::{ }; use lvgl; use lvgl::style::{Opacity, Style}; -use lvgl::widgets::Gauge; +use lvgl::widgets::Meter; use lvgl::{ - Align, Color, Display, DrawBuffer, LvError, Part, State, Widget, HOR_RES_MAX, VER_RES_MAX, + Align, Color, Display, DrawBuffer, LvError, Part, State, Widget, }; -use std::cell::RefCell; -use std::time::Instant; +use std::time::Duration; fn main() -> Result<(), LvError> { + const HOR_RES: u32 = 240; + const VER_RES: u32 = 240; + lvgl::init(); - let sim_display: SimulatorDisplay = - SimulatorDisplay::new(Size::new(HOR_RES_MAX, VER_RES_MAX)); + let mut sim_display: SimulatorDisplay = + SimulatorDisplay::new(Size::new(HOR_RES, VER_RES)); let output_settings = OutputSettingsBuilder::new().scale(2).build(); - let mut window = Window::new("Gauge Example", &output_settings); - - let shared_native_display = RefCell::new(sim_display); + let mut window = Window::new("Meter Example", &output_settings); - let buffer = DrawBuffer::<{ (HOR_RES_MAX * VER_RES_MAX) as usize }>::new(); + let buffer = DrawBuffer::<{ (HOR_RES * VER_RES) as usize }>::new(); - let display = Display::register(&buffer, |refresh| { - shared_native_display - .borrow_mut() + let display = Display::register(buffer, HOR_RES, VER_RES, |refresh| { + sim_display .draw_iter(refresh.as_pixels()) .unwrap(); })?; @@ -34,27 +36,27 @@ fn main() -> Result<(), LvError> { let mut screen = display.get_scr_act()?; let mut screen_style = Style::default(); - screen_style.set_bg_color(State::DEFAULT, Color::from_rgb((0, 0, 0))); + screen_style.set_bg_color(Color::from_rgb((0, 0, 0))); screen.add_style(Part::Main, &mut screen_style)?; // Create the gauge let mut gauge_style = Style::default(); // Set a background color and a radius - gauge_style.set_radius(State::DEFAULT, 5); - gauge_style.set_bg_opa(State::DEFAULT, Opacity::OPA_COVER); - gauge_style.set_bg_color(State::DEFAULT, Color::from_rgb((192, 192, 192))); + gauge_style.set_radius(5); + gauge_style.set_bg_opa(Opacity::OPA_COVER); + gauge_style.set_bg_color(Color::from_rgb((192, 192, 192))); // Set some padding's - gauge_style.set_pad_inner(State::DEFAULT, 20); - gauge_style.set_pad_top(State::DEFAULT, 20); - gauge_style.set_pad_left(State::DEFAULT, 5); - gauge_style.set_pad_right(State::DEFAULT, 5); - - gauge_style.set_scale_end_color(State::DEFAULT, Color::from_rgb((255, 0, 0))); - gauge_style.set_line_color(State::DEFAULT, Color::from_rgb((255, 255, 255))); - gauge_style.set_scale_grad_color(State::DEFAULT, Color::from_rgb((0, 0, 255))); - gauge_style.set_line_width(State::DEFAULT, 2); - gauge_style.set_scale_end_line_width(State::DEFAULT, 4); - gauge_style.set_scale_end_border_width(State::DEFAULT, 4); + //gauge_style.set_pad_inner(20); + gauge_style.set_pad_top(20); + gauge_style.set_pad_left(5); + gauge_style.set_pad_right(5); + + //gauge_style.set_scale_end_color(Color::from_rgb((255, 0, 0))); + gauge_style.set_line_color(Color::from_rgb((255, 255, 255))); + //gauge_style.set_scale_grad_color(Color::from_rgb((0, 0, 255))); + gauge_style.set_line_width(2); + //gauge_style.set_scale_end_line_width(4); + //gauge_style.set_scale_end_border_width(4); let mut gauge = Gauge::create(&mut screen, None)?; gauge.add_style(Part::Main, &mut gauge_style)?; @@ -67,7 +69,7 @@ fn main() -> Result<(), LvError> { gauge.set_value(0, i)?; lvgl::task_handler(); - window.update(&shared_native_display.borrow()); + window.update(&sim_display); for event in window.events() { match event { @@ -88,9 +90,13 @@ fn main() -> Result<(), LvError> { i = i + 1; } - lvgl::tick_inc(loop_started.elapsed()); - loop_started = Instant::now(); + lvgl::tick_inc(Duration::from_millis(16)); } Ok(()) } +*/ + +fn main() { + println!("Currently broken :c") +} diff --git a/lvgl-codegen/src/lib.rs b/lvgl-codegen/src/lib.rs index fe2a8ad8..ee72ff76 100644 --- a/lvgl-codegen/src/lib.rs +++ b/lvgl-codegen/src/lib.rs @@ -98,7 +98,6 @@ impl Rusty for LvFunc { type Parent = LvWidget; fn code(&self, parent: &Self::Parent) -> WrapperResult { - let widget_name = format_ident!("{}", parent.pascal_name()); let templ = format!("{}{}_", LIB_PREFIX, parent.name.as_str()); let new_name = self.name.replace(templ.as_str(), ""); let func_name = format_ident!("{}", new_name); @@ -108,11 +107,10 @@ impl Rusty for LvFunc { if new_name.as_str().eq("create") { return Ok(quote! { - pub fn create(parent: &mut impl crate::NativeObject, copy: Option<&#widget_name>) -> crate::LvResult { + pub fn create(parent: &mut impl crate::NativeObject) -> crate::LvResult { unsafe { let ptr = lvgl_sys::#original_func_name( parent.raw()?.as_mut(), - copy.map(|c| c.raw().unwrap().as_mut() as *mut lvgl_sys::lv_obj_t).unwrap_or(core::ptr::null_mut() as *mut lvgl_sys::lv_obj_t), ); if let Some(raw) = core::ptr::NonNull::new(ptr) { let core = ::from_raw(raw); @@ -124,7 +122,7 @@ impl Rusty for LvFunc { } pub fn create_at(parent: &mut impl crate::NativeObject) -> crate::LvResult { - Ok(Self::create(parent, None)?) + Ok(Self::create(parent)?) } pub fn new() -> crate::LvResult { @@ -424,7 +422,7 @@ impl CodeGen { functions .iter() - .filter(|e| create_func.is_match(e.name.as_str()) && e.args.len() == 2) + .filter(|e| create_func.is_match(e.name.as_str()) && e.args.len() == 1) .map(|f| { String::from( create_func @@ -498,30 +496,22 @@ mod test { let funcs = vec![ LvFunc::new( "lv_obj_create".to_string(), - vec![ - LvArg::new("parent".to_string(), LvType::new("abc".to_string())), - LvArg::new("copy_from".to_string(), LvType::new("bcf".to_string())), - ], + vec![LvArg::new( + "parent".to_string(), + LvType::new("abc".to_string()), + )], None, ), LvFunc::new( "lv_btn_create".to_string(), - vec![ - LvArg::new("parent".to_string(), LvType::new("abc".to_string())), - LvArg::new("copy_from".to_string(), LvType::new("bcf".to_string())), - ], + vec![LvArg::new( + "parent".to_string(), + LvType::new("abc".to_string()), + )], None, ), LvFunc::new( "lv_do_something".to_string(), - vec![ - LvArg::new("parent".to_string(), LvType::new("abc".to_string())), - LvArg::new("copy_from".to_string(), LvType::new("bcf".to_string())), - ], - None, - ), - LvFunc::new( - "lv_invalid_create".to_string(), vec![LvArg::new( "parent".to_string(), LvType::new("abc".to_string()), @@ -529,13 +519,21 @@ mod test { None, ), LvFunc::new( - "lv_cb_create".to_string(), + "lv_invalid_create".to_string(), vec![ LvArg::new("parent".to_string(), LvType::new("abc".to_string())), LvArg::new("copy_from".to_string(), LvType::new("bcf".to_string())), ], None, ), + LvFunc::new( + "lv_cb_create".to_string(), + vec![LvArg::new( + "parent".to_string(), + LvType::new("abc".to_string()), + )], + None, + ), ]; let widget_names = CodeGen::get_widget_names(&funcs); @@ -652,11 +650,10 @@ mod test { define_object!(Arc); impl Arc { - pub fn create(parent: &mut impl crate::NativeObject, copy: Option<&Arc>) -> crate::LvResult { + pub fn create(parent: &mut impl crate::NativeObject) -> crate::LvResult { unsafe { let ptr = lvgl_sys::lv_arc_create( parent.raw()?.as_mut(), - copy.map(|c| c.raw().unwrap().as_mut() as *mut lvgl_sys::lv_obj_t).unwrap_or(core::ptr::null_mut() as *mut lvgl_sys::lv_obj_t), ); if let Some(raw) = core::ptr::NonNull::new(ptr) { let core = ::from_raw(raw); @@ -668,7 +665,7 @@ mod test { } pub fn create_at(parent: &mut impl crate::NativeObject) -> crate::LvResult { - Ok(Self::create(parent, None)?) + Ok(Self::create(parent)?) } pub fn new() -> crate::LvResult { diff --git a/lvgl-sys/build.rs b/lvgl-sys/build.rs index 71452852..aefe5bf1 100644 --- a/lvgl-sys/build.rs +++ b/lvgl-sys/build.rs @@ -58,14 +58,7 @@ fn main() { }; let mut cfg = Build::new(); - add_c_files(&mut cfg, vendor_src.join("lv_core")); - add_c_files(&mut cfg, vendor_src.join("lv_draw")); - add_c_files(&mut cfg, vendor_src.join("lv_font")); - add_c_files(&mut cfg, vendor_src.join("lv_gpu")); - add_c_files(&mut cfg, vendor_src.join("lv_hal")); - add_c_files(&mut cfg, vendor_src.join("lv_misc")); - add_c_files(&mut cfg, vendor_src.join("lv_themes")); - add_c_files(&mut cfg, vendor_src.join("lv_widgets")); + add_c_files(&mut cfg, &vendor_src); add_c_files(&mut cfg, &lv_config_dir); add_c_files(&mut cfg, &shims_dir); @@ -138,7 +131,7 @@ fn add_c_files(build: &mut cc::Build, path: impl AsRef) { let e = e.unwrap(); let path = e.path(); if e.file_type().unwrap().is_dir() { - // skip dirs for now + add_c_files(build, e.path()); } else if path.extension().and_then(|s| s.to_str()) == Some("c") { build.file(&path); } diff --git a/lvgl-sys/shims/lvgl_sys.c b/lvgl-sys/shims/lvgl_sys.c index d04e5a80..368aaa47 100644 --- a/lvgl-sys/shims/lvgl_sys.c +++ b/lvgl-sys/shims/lvgl_sys.c @@ -2,7 +2,7 @@ lv_color_t _LV_COLOR_MAKE(uint8_t r, uint8_t g, uint8_t b) { - return LV_COLOR_MAKE(r, g, b); + return lv_color_make(r, g, b); } uint16_t _LV_COLOR_GET_R(lv_color_t color) diff --git a/lvgl-sys/src/lib.rs b/lvgl-sys/src/lib.rs index 9e525f8c..ca2fadf9 100644 --- a/lvgl-sys/src/lib.rs +++ b/lvgl-sys/src/lib.rs @@ -23,10 +23,10 @@ mod tests { lv_init(); let horizontal_resolution = lv_disp_get_hor_res(core::ptr::null_mut()); - assert_eq!(horizontal_resolution, LV_HOR_RES_MAX as i16); + assert_eq!(horizontal_resolution, 0 as i16); let vertical_resolution = lv_disp_get_ver_res(core::ptr::null_mut()); - assert_eq!(vertical_resolution, LV_VER_RES_MAX as i16); + assert_eq!(vertical_resolution, 0 as i16); } } } diff --git a/lvgl-sys/vendor/include/lv_conf.h b/lvgl-sys/vendor/include/lv_conf.h index 6fe446c1..47aaccb8 100644 --- a/lvgl-sys/vendor/include/lv_conf.h +++ b/lvgl-sys/vendor/include/lv_conf.h @@ -1,701 +1,762 @@ /** * @file lv_conf.h - * + * Configuration file for v8.3.5 */ /* - * COPY THIS FILE AS `lv_conf.h` NEXT TO the `lvgl` FOLDER + * Copy this file as `lv_conf.h` + * 1. simply next to the `lvgl` folder + * 2. or any other places and + * - define `LV_CONF_INCLUDE_SIMPLE` + * - add the path as include path */ +/* clang-format off */ #if 1 /*Set it to "1" to enable content*/ #ifndef LV_CONF_H #define LV_CONF_H -/* clang-format off */ #include /*==================== - Graphical settings + COLOR SETTINGS *====================*/ -/* Maximal horizontal and vertical resolution to support by the library.*/ -#define LV_HOR_RES_MAX (240) -#define LV_VER_RES_MAX (240) +/*Color depth: 1 (1 byte per pixel), 8 (RGB332), 16 (RGB565), 32 (ARGB8888)*/ +#define LV_COLOR_DEPTH 16 -/* Color depth: - * - 1: 1 byte per pixel - * - 8: RGB332 - * - 16: RGB565 - * - 32: ARGB8888 - */ -#define LV_COLOR_DEPTH 16 - -/* Swap the 2 bytes of RGB565 color. - * Useful if the display has a 8 bit interface (e.g. SPI)*/ -#define LV_COLOR_16_SWAP 0 - -/* 1: Enable screen transparency. - * Useful for OSD or other overlapping GUIs. - * Requires `LV_COLOR_DEPTH = 32` colors and the screen's style should be modified: `style.body.opa = ...`*/ -#define LV_COLOR_SCREEN_TRANSP 0 - -/*Images pixels with this color will not be drawn (with chroma keying)*/ -#define LV_COLOR_TRANSP LV_COLOR_LIME /*LV_COLOR_LIME: pure green*/ - -/* Enable anti-aliasing (lines, and radiuses will be smoothed) */ -#define LV_ANTIALIAS 1 - -/* Default display refresh period. - * Can be changed in the display driver (`lv_disp_drv_t`).*/ -#define LV_DISP_DEF_REFR_PERIOD 30 /*[ms]*/ - -/* Dot Per Inch: used to initialize default sizes. - * E.g. a button with width = LV_DPI / 2 -> half inch wide - * (Not so important, you can adjust it to modify default sizes and spaces)*/ -#define LV_DPI 130 /*[px]*/ - -/* The the real width of the display changes some default values: - * default object sizes, layout of examples, etc. - * According to the width of the display (hor. res. / dpi) - * the displays fall in 4 categories. - * The 4th is extra large which has no upper limit so not listed here - * The upper limit of the categories are set below in 0.1 inch unit. - */ -#define LV_DISP_SMALL_LIMIT 30 -#define LV_DISP_MEDIUM_LIMIT 50 -#define LV_DISP_LARGE_LIMIT 70 +/*Swap the 2 bytes of RGB565 color. Useful if the display has an 8-bit interface (e.g. SPI)*/ +#define LV_COLOR_16_SWAP 0 -/* Type of coordinates. Should be `int16_t` (or `int32_t` for extreme cases) */ -typedef int16_t lv_coord_t; +/*Enable features to draw on transparent background. + *It's required if opa, and transform_* style properties are used. + *Can be also used if the UI is above another layer, e.g. an OSD menu or video player.*/ +#define LV_COLOR_SCREEN_TRANSP 0 + +/* Adjust color mix functions rounding. GPUs might calculate color mix (blending) differently. + * 0: round down, 64: round up from x.75, 128: round up from half, 192: round up from x.25, 254: round up */ +#define LV_COLOR_MIX_ROUND_OFS 0 + +/*Images pixels with this color will not be drawn if they are chroma keyed)*/ +#define LV_COLOR_CHROMA_KEY lv_color_hex(0x00ff00) /*pure green*/ /*========================= - Memory manager settings + MEMORY SETTINGS *=========================*/ -/* LittelvGL's internal memory manager's settings. - * The graphical objects and other related data are stored here. */ - -/* 1: use custom malloc/free, 0: use the built-in `lv_mem_alloc` and `lv_mem_free` */ -#define LV_MEM_CUSTOM 0 +/*1: use custom malloc/free, 0: use the built-in `lv_mem_alloc()` and `lv_mem_free()`*/ +#define LV_MEM_CUSTOM 0 #if LV_MEM_CUSTOM == 0 -/* Size of the memory used by `lv_mem_alloc` in bytes (>= 2kB)*/ -# define LV_MEM_SIZE (32U * 1024U) - -/* Complier prefix for a big array declaration */ -# define LV_MEM_ATTR + /*Size of the memory available for `lv_mem_alloc()` in bytes (>= 2kB)*/ + #define LV_MEM_SIZE (48U * 1024U) /*[bytes]*/ -/* Set an address for the memory pool instead of allocating it as an array. - * Can be in external SRAM too. */ -# define LV_MEM_ADR 0 + /*Set an address for the memory pool instead of allocating it as a normal array. Can be in external SRAM too.*/ + #define LV_MEM_ADR 0 /*0: unused*/ + /*Instead of an address give a memory allocator that will be called to get a memory pool for LVGL. E.g. my_malloc*/ + #if LV_MEM_ADR == 0 + #undef LV_MEM_POOL_INCLUDE + #undef LV_MEM_POOL_ALLOC + #endif -/* Automatically defrag. on free. Defrag. means joining the adjacent free cells. */ -# define LV_MEM_AUTO_DEFRAG 1 #else /*LV_MEM_CUSTOM*/ -# define LV_MEM_CUSTOM_INCLUDE /*Header for the dynamic memory function*/ -# define LV_MEM_CUSTOM_ALLOC malloc /*Wrapper to malloc*/ -# define LV_MEM_CUSTOM_FREE free /*Wrapper to free*/ + #define LV_MEM_CUSTOM_INCLUDE /*Header for the dynamic memory function*/ + #define LV_MEM_CUSTOM_ALLOC malloc + #define LV_MEM_CUSTOM_FREE free + #define LV_MEM_CUSTOM_REALLOC realloc #endif /*LV_MEM_CUSTOM*/ -/* Garbage Collector settings - * Used if lvgl is binded to higher level language and the memory is managed by that language */ -#define LV_ENABLE_GC 0 -#if LV_ENABLE_GC != 0 -# define LV_GC_INCLUDE "gc.h" /*Include Garbage Collector related things*/ -# define LV_MEM_CUSTOM_REALLOC your_realloc /*Wrapper to realloc*/ -# define LV_MEM_CUSTOM_GET_SIZE your_mem_get_size /*Wrapper to lv_mem_get_size*/ -#endif /* LV_ENABLE_GC */ +/*Number of the intermediate memory buffer used during rendering and other internal processing mechanisms. + *You will see an error log message if there wasn't enough buffers. */ +#define LV_MEM_BUF_MAX_NUM 16 -/*======================= - Input device settings - *=======================*/ +/*Use the standard `memcpy` and `memset` instead of LVGL's own functions. (Might or might not be faster).*/ +#define LV_MEMCPY_MEMSET_STD 0 -/* Input device default settings. - * Can be changed in the Input device driver (`lv_indev_drv_t`)*/ +/*==================== + HAL SETTINGS + *====================*/ + +/*Default display refresh period. LVG will redraw changed areas with this period time*/ +#define LV_DISP_DEF_REFR_PERIOD 30 /*[ms]*/ + +/*Input device read period in milliseconds*/ +#define LV_INDEV_DEF_READ_PERIOD 30 /*[ms]*/ + +/*Use a custom tick source that tells the elapsed time in milliseconds. + *It removes the need to manually update the tick with `lv_tick_inc()`)*/ +#define LV_TICK_CUSTOM 0 +#if LV_TICK_CUSTOM + #define LV_TICK_CUSTOM_INCLUDE "Arduino.h" /*Header for the system time function*/ + #define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current system time in ms*/ + /*If using lvgl as ESP32 component*/ + // #define LV_TICK_CUSTOM_INCLUDE "esp_timer.h" + // #define LV_TICK_CUSTOM_SYS_TIME_EXPR ((esp_timer_get_time() / 1000LL)) +#endif /*LV_TICK_CUSTOM*/ -/* Input device read period in milliseconds */ -#define LV_INDEV_DEF_READ_PERIOD 30 +/*Default Dot Per Inch. Used to initialize default sizes such as widgets sized, style paddings. + *(Not so important, you can adjust it to modify default sizes and spaces)*/ +#define LV_DPI_DEF 130 /*[px/inch]*/ -/* Drag threshold in pixels */ -#define LV_INDEV_DEF_DRAG_LIMIT 10 +/*======================= + * FEATURE CONFIGURATION + *=======================*/ -/* Drag throw slow-down in [%]. Greater value -> faster slow-down */ -#define LV_INDEV_DEF_DRAG_THROW 10 +/*------------- + * Drawing + *-----------*/ -/* Long press time in milliseconds. - * Time to send `LV_EVENT_LONG_PRESSSED`) */ -#define LV_INDEV_DEF_LONG_PRESS_TIME 400 +/*Enable complex draw engine. + *Required to draw shadow, gradient, rounded corners, circles, arc, skew lines, image transformations or any masks*/ +#define LV_DRAW_COMPLEX 1 +#if LV_DRAW_COMPLEX != 0 -/* Repeated trigger period in long press [ms] - * Time between `LV_EVENT_LONG_PRESSED_REPEAT */ -#define LV_INDEV_DEF_LONG_PRESS_REP_TIME 100 + /*Allow buffering some shadow calculation. + *LV_SHADOW_CACHE_SIZE is the max. shadow size to buffer, where shadow size is `shadow_width + radius` + *Caching has LV_SHADOW_CACHE_SIZE^2 RAM cost*/ + #define LV_SHADOW_CACHE_SIZE 0 + /* Set number of maximally cached circle data. + * The circumference of 1/4 circle are saved for anti-aliasing + * radius * 4 bytes are used per circle (the most often used radiuses are saved) + * 0: to disable caching */ + #define LV_CIRCLE_CACHE_SIZE 4 +#endif /*LV_DRAW_COMPLEX*/ -/* Gesture threshold in pixels */ -#define LV_INDEV_DEF_GESTURE_LIMIT 50 +/** + * "Simple layers" are used when a widget has `style_opa < 255` to buffer the widget into a layer + * and blend it as an image with the given opacity. + * Note that `bg_opa`, `text_opa` etc don't require buffering into layer) + * The widget can be buffered in smaller chunks to avoid using large buffers. + * + * - LV_LAYER_SIMPLE_BUF_SIZE: [bytes] the optimal target buffer size. LVGL will try to allocate it + * - LV_LAYER_SIMPLE_FALLBACK_BUF_SIZE: [bytes] used if `LV_LAYER_SIMPLE_BUF_SIZE` couldn't be allocated. + * + * Both buffer sizes are in bytes. + * "Transformed layers" (where transform_angle/zoom properties are used) use larger buffers + * and can't be drawn in chunks. So these settings affects only widgets with opacity. + */ +#define LV_LAYER_SIMPLE_BUF_SIZE (24 * 1024) +#define LV_LAYER_SIMPLE_FALLBACK_BUF_SIZE (3 * 1024) + +/*Default image cache size. Image caching keeps the images opened. + *If only the built-in image formats are used there is no real advantage of caching. (I.e. if no new image decoder is added) + *With complex image decoders (e.g. PNG or JPG) caching can save the continuous open/decode of images. + *However the opened images might consume additional RAM. + *0: to disable caching*/ +#define LV_IMG_CACHE_DEF_SIZE 0 + +/*Number of stops allowed per gradient. Increase this to allow more stops. + *This adds (sizeof(lv_color_t) + 1) bytes per additional stop*/ +#define LV_GRADIENT_MAX_STOPS 2 + +/*Default gradient buffer size. + *When LVGL calculates the gradient "maps" it can save them into a cache to avoid calculating them again. + *LV_GRAD_CACHE_DEF_SIZE sets the size of this cache in bytes. + *If the cache is too small the map will be allocated only while it's required for the drawing. + *0 mean no caching.*/ +#define LV_GRAD_CACHE_DEF_SIZE 0 + +/*Allow dithering the gradients (to achieve visual smooth color gradients on limited color depth display) + *LV_DITHER_GRADIENT implies allocating one or two more lines of the object's rendering surface + *The increase in memory consumption is (32 bits * object width) plus 24 bits * object width if using error diffusion */ +#define LV_DITHER_GRADIENT 0 +#if LV_DITHER_GRADIENT + /*Add support for error diffusion dithering. + *Error diffusion dithering gets a much better visual result, but implies more CPU consumption and memory when drawing. + *The increase in memory consumption is (24 bits * object's width)*/ + #define LV_DITHER_ERROR_DIFFUSION 0 +#endif -/* Gesture min velocity at release before swipe (pixels)*/ -#define LV_INDEV_DEF_GESTURE_MIN_VELOCITY 3 +/*Maximum buffer size to allocate for rotation. + *Only used if software rotation is enabled in the display driver.*/ +#define LV_DISP_ROT_MAX_BUF (10*1024) -/*================== - * Feature usage - *==================*/ +/*------------- + * GPU + *-----------*/ -/*1: Enable the Animations */ -#define LV_USE_ANIMATION 1 -#if LV_USE_ANIMATION +/*Use Arm's 2D acceleration library Arm-2D */ +#define LV_USE_GPU_ARM2D 0 -/*Declare the type of the user data of animations (can be e.g. `void *`, `int`, `struct`)*/ -typedef void * lv_anim_user_data_t; +/*Use STM32's DMA2D (aka Chrom Art) GPU*/ +#define LV_USE_GPU_STM32_DMA2D 0 +#if LV_USE_GPU_STM32_DMA2D + /*Must be defined to include path of CMSIS header of target processor + e.g. "stm32f769xx.h" or "stm32f429xx.h"*/ + #define LV_GPU_DMA2D_CMSIS_INCLUDE +#endif +/*Use SWM341's DMA2D GPU*/ +#define LV_USE_GPU_SWM341_DMA2D 0 +#if LV_USE_GPU_SWM341_DMA2D + #define LV_GPU_SWM341_DMA2D_INCLUDE "SWM341.h" #endif -/* 1: Enable shadow drawing*/ -#define LV_USE_SHADOW 1 -#if LV_USE_SHADOW -/* Allow buffering some shadow calculation - * LV_SHADOW_CACHE_SIZE is the max. shadow size to buffer, - * where shadow size is `shadow_width + radius` - * Caching has LV_SHADOW_CACHE_SIZE^2 RAM cost*/ -#define LV_SHADOW_CACHE_SIZE 0 +/*Use NXP's PXP GPU iMX RTxxx platforms*/ +#define LV_USE_GPU_NXP_PXP 0 +#if LV_USE_GPU_NXP_PXP + /*1: Add default bare metal and FreeRTOS interrupt handling routines for PXP (lv_gpu_nxp_pxp_osa.c) + * and call lv_gpu_nxp_pxp_init() automatically during lv_init(). Note that symbol SDK_OS_FREE_RTOS + * has to be defined in order to use FreeRTOS OSA, otherwise bare-metal implementation is selected. + *0: lv_gpu_nxp_pxp_init() has to be called manually before lv_init() + */ + #define LV_USE_GPU_NXP_PXP_AUTO_INIT 0 #endif -/* 1: Use other blend modes than normal (`LV_BLEND_MODE_...`)*/ -#define LV_USE_BLEND_MODES 1 +/*Use NXP's VG-Lite GPU iMX RTxxx platforms*/ +#define LV_USE_GPU_NXP_VG_LITE 0 + +/*Use SDL renderer API*/ +#define LV_USE_GPU_SDL 0 +#if LV_USE_GPU_SDL + #define LV_GPU_SDL_INCLUDE_PATH + /*Texture cache size, 8MB by default*/ + #define LV_GPU_SDL_LRU_SIZE (1024 * 1024 * 8) + /*Custom blend mode for mask drawing, disable if you need to link with older SDL2 lib*/ + #define LV_GPU_SDL_CUSTOM_BLEND_MODE (SDL_VERSION_ATLEAST(2, 0, 6)) +#endif -/* 1: Use the `opa_scale` style property to set the opacity of an object and its children at once*/ -#define LV_USE_OPA_SCALE 1 +/*------------- + * Logging + *-----------*/ -/* 1: Use image zoom and rotation*/ -#define LV_USE_IMG_TRANSFORM 1 +/*Enable the log module*/ +#define LV_USE_LOG 0 +#if LV_USE_LOG -/* 1: Enable object groups (for keyboard/encoder navigation) */ -#define LV_USE_GROUP 1 -#if LV_USE_GROUP -typedef void * lv_group_user_data_t; -#endif /*LV_USE_GROUP*/ + /*How important log should be added: + *LV_LOG_LEVEL_TRACE A lot of logs to give detailed information + *LV_LOG_LEVEL_INFO Log important events + *LV_LOG_LEVEL_WARN Log if something unwanted happened but didn't cause a problem + *LV_LOG_LEVEL_ERROR Only critical issue, when the system may fail + *LV_LOG_LEVEL_USER Only logs added by the user + *LV_LOG_LEVEL_NONE Do not log anything*/ + #define LV_LOG_LEVEL LV_LOG_LEVEL_WARN + + /*1: Print the log with 'printf'; + *0: User need to register a callback with `lv_log_register_print_cb()`*/ + #define LV_LOG_PRINTF 0 + + /*Enable/disable LV_LOG_TRACE in modules that produces a huge number of logs*/ + #define LV_LOG_TRACE_MEM 1 + #define LV_LOG_TRACE_TIMER 1 + #define LV_LOG_TRACE_INDEV 1 + #define LV_LOG_TRACE_DISP_REFR 1 + #define LV_LOG_TRACE_EVENT 1 + #define LV_LOG_TRACE_OBJ_CREATE 1 + #define LV_LOG_TRACE_LAYOUT 1 + #define LV_LOG_TRACE_ANIM 1 -/* 1: Enable GPU interface*/ -#define LV_USE_GPU 1 /*Only enables `gpu_fill_cb` and `gpu_blend_cb` in the disp. drv- */ -#define LV_USE_GPU_STM32_DMA2D 0 +#endif /*LV_USE_LOG*/ -/* 1: Enable file system (might be required for images */ -#define LV_USE_FILESYSTEM 1 -#if LV_USE_FILESYSTEM -/*Declare the type of the user data of file system drivers (can be e.g. `void *`, `int`, `struct`)*/ -typedef void * lv_fs_drv_user_data_t; +/*------------- + * Asserts + *-----------*/ + +/*Enable asserts if an operation is failed or an invalid data is found. + *If LV_USE_LOG is enabled an error message will be printed on failure*/ +#define LV_USE_ASSERT_NULL 1 /*Check if the parameter is NULL. (Very fast, recommended)*/ +#define LV_USE_ASSERT_MALLOC 1 /*Checks is the memory is successfully allocated or no. (Very fast, recommended)*/ +#define LV_USE_ASSERT_STYLE 0 /*Check if the styles are properly initialized. (Very fast, recommended)*/ +#define LV_USE_ASSERT_MEM_INTEGRITY 0 /*Check the integrity of `lv_mem` after critical operations. (Slow)*/ +#define LV_USE_ASSERT_OBJ 0 /*Check the object's type and existence (e.g. not deleted). (Slow)*/ + +/*Add a custom handler when assert happens e.g. to restart the MCU*/ +#define LV_ASSERT_HANDLER_INCLUDE +#define LV_ASSERT_HANDLER while(1); /*Halt by default*/ + +/*------------- + * Others + *-----------*/ + +/*1: Show CPU usage and FPS count*/ +#define LV_USE_PERF_MONITOR 0 +#if LV_USE_PERF_MONITOR + #define LV_USE_PERF_MONITOR_POS LV_ALIGN_BOTTOM_RIGHT #endif -/*1: Add a `user_data` to drivers and objects*/ -#define LV_USE_USER_DATA 1 - -/*1: Show CPU usage and FPS count in the right bottom corner*/ -#define LV_USE_PERF_MONITOR 0 - -/*1: Use the functions and types from the older API if possible */ -#define LV_USE_API_EXTENSION_V6 1 - -/*======================== - * Image decoder and cache - *========================*/ +/*1: Show the used memory and the memory fragmentation + * Requires LV_MEM_CUSTOM = 0*/ +#define LV_USE_MEM_MONITOR 0 +#if LV_USE_MEM_MONITOR + #define LV_USE_MEM_MONITOR_POS LV_ALIGN_BOTTOM_LEFT +#endif -/* 1: Enable indexed (palette) images */ -#define LV_IMG_CF_INDEXED 1 +/*1: Draw random colored rectangles over the redrawn areas*/ +#define LV_USE_REFR_DEBUG 0 -/* 1: Enable alpha indexed images */ -#define LV_IMG_CF_ALPHA 1 +/*Change the built in (v)snprintf functions*/ +#define LV_SPRINTF_CUSTOM 0 +#if LV_SPRINTF_CUSTOM + #define LV_SPRINTF_INCLUDE + #define lv_snprintf snprintf + #define lv_vsnprintf vsnprintf +#else /*LV_SPRINTF_CUSTOM*/ + #define LV_SPRINTF_USE_FLOAT 0 +#endif /*LV_SPRINTF_CUSTOM*/ -/* Default image cache size. Image caching keeps the images opened. - * If only the built-in image formats are used there is no real advantage of caching. - * (I.e. no new image decoder is added) - * With complex image decoders (e.g. PNG or JPG) caching can save the continuous open/decode of images. - * However the opened images might consume additional RAM. - * LV_IMG_CACHE_DEF_SIZE must be >= 1 */ -#define LV_IMG_CACHE_DEF_SIZE 1 +#define LV_USE_USER_DATA 1 -/*Declare the type of the user data of image decoder (can be e.g. `void *`, `int`, `struct`)*/ -typedef void * lv_img_decoder_user_data_t; +/*Garbage Collector settings + *Used if lvgl is bound to higher level language and the memory is managed by that language*/ +#define LV_ENABLE_GC 0 +#if LV_ENABLE_GC != 0 + #define LV_GC_INCLUDE "gc.h" /*Include Garbage Collector related things*/ +#endif /*LV_ENABLE_GC*/ /*===================== - * Compiler settings + * COMPILER SETTINGS *====================*/ -/* Define a custom attribute to `lv_tick_inc` function */ + +/*For big endian systems set to 1*/ +#define LV_BIG_ENDIAN_SYSTEM 0 + +/*Define a custom attribute to `lv_tick_inc` function*/ #define LV_ATTRIBUTE_TICK_INC -/* Define a custom attribute to `lv_task_handler` function */ -#define LV_ATTRIBUTE_TASK_HANDLER +/*Define a custom attribute to `lv_timer_handler` function*/ +#define LV_ATTRIBUTE_TIMER_HANDLER -/* Define a custom attribute to `lv_disp_flush_ready` function */ +/*Define a custom attribute to `lv_disp_flush_ready` function*/ #define LV_ATTRIBUTE_FLUSH_READY -/* With size optimization (-Os) the compiler might not align data to - * 4 or 8 byte boundary. This alignment will be explicitly applied where needed. - * E.g. __attribute__((aligned(4))) */ +/*Required alignment size for buffers*/ +#define LV_ATTRIBUTE_MEM_ALIGN_SIZE 1 + +/*Will be added where memories needs to be aligned (with -Os data might not be aligned to boundary by default). + * E.g. __attribute__((aligned(4)))*/ #define LV_ATTRIBUTE_MEM_ALIGN -/* Attribute to mark large constant arrays for example - * font's bitmaps */ +/*Attribute to mark large constant arrays for example font's bitmaps*/ #define LV_ATTRIBUTE_LARGE_CONST -/* Prefix performance critical functions to place them into a faster memory (e.g RAM) - * Uses 15-20 kB extra memory */ -#define LV_ATTRIBUTE_FAST_MEM - -/* Export integer constant to binding. - * This macro is used with constants in the form of LV_ that - * should also appear on lvgl binding API such as Micropython - * - * The default value just prevents a GCC warning. - */ -#define LV_EXPORT_CONST_INT(int_value) struct _silence_gcc_warning - -/*=================== - * HAL settings - *==================*/ - -/* 1: use a custom tick source. - * It removes the need to manually update the tick with `lv_tick_inc`) */ -#define LV_TICK_CUSTOM 0 -#if LV_TICK_CUSTOM == 1 -#define LV_TICK_CUSTOM_INCLUDE "something.h" /*Header for the sys time function*/ -#define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current systime in ms*/ -#endif /*LV_TICK_CUSTOM*/ - -typedef void * lv_disp_drv_user_data_t; /*Type of user data in the display driver*/ -typedef void * lv_indev_drv_user_data_t; /*Type of user data in the input device driver*/ - -/*================ - * Log settings - *===============*/ - -/*1: Enable the log module*/ -#define LV_USE_LOG 0 -#if LV_USE_LOG -/* How important log should be added: - * LV_LOG_LEVEL_TRACE A lot of logs to give detailed information - * LV_LOG_LEVEL_INFO Log important events - * LV_LOG_LEVEL_WARN Log if something unwanted happened but didn't cause a problem - * LV_LOG_LEVEL_ERROR Only critical issue, when the system may fail - * LV_LOG_LEVEL_NONE Do not log anything - */ -# define LV_LOG_LEVEL LV_LOG_LEVEL_WARN - -/* 1: Print the log with 'printf'; - * 0: user need to register a callback with `lv_log_register_print_cb`*/ -# define LV_LOG_PRINTF 0 -#endif /*LV_USE_LOG*/ - -/*================= - * Debug settings - *================*/ - -/* If Debug is enabled LittelvGL validates the parameters of the functions. - * If an invalid parameter is found an error log message is printed and - * the MCU halts at the error. (`LV_USE_LOG` should be enabled) - * If you are debugging the MCU you can pause - * the debugger to see exactly where the issue is. - * - * The behavior of asserts can be overwritten by redefining them here. - * E.g. #define LV_ASSERT_MEM(p) - */ -#define LV_USE_DEBUG 1 -#if LV_USE_DEBUG - -/*Check if the parameter is NULL. (Quite fast) */ -#define LV_USE_ASSERT_NULL 1 - -/*Checks is the memory is successfully allocated or no. (Quite fast)*/ -#define LV_USE_ASSERT_MEM 1 - -/*Check the integrity of `lv_mem` after critical operations. (Slow)*/ -#define LV_USE_ASSERT_MEM_INTEGRITY 0 +/*Compiler prefix for a big array declaration in RAM*/ +#define LV_ATTRIBUTE_LARGE_RAM_ARRAY -/* Check the strings. - * Search for NULL, very long strings, invalid characters, and unnatural repetitions. (Slow) - * If disabled `LV_USE_ASSERT_NULL` will be performed instead (if it's enabled) */ -#define LV_USE_ASSERT_STR 0 +/*Place performance critical functions into a faster memory (e.g RAM)*/ +#define LV_ATTRIBUTE_FAST_MEM -/* Check NULL, the object's type and existence (e.g. not deleted). (Quite slow) - * If disabled `LV_USE_ASSERT_NULL` will be performed instead (if it's enabled) */ -#define LV_USE_ASSERT_OBJ 0 +/*Prefix variables that are used in GPU accelerated operations, often these need to be placed in RAM sections that are DMA accessible*/ +#define LV_ATTRIBUTE_DMA -/*Check if the styles are properly initialized. (Fast)*/ -#define LV_USE_ASSERT_STYLE 0 +/*Export integer constant to binding. This macro is used with constants in the form of LV_ that + *should also appear on LVGL binding API such as Micropython.*/ +#define LV_EXPORT_CONST_INT(int_value) struct _silence_gcc_warning /*The default value just prevents GCC warning*/ -#endif /*LV_USE_DEBUG*/ +/*Extend the default -32k..32k coordinate range to -4M..4M by using int32_t for coordinates instead of int16_t*/ +#define LV_USE_LARGE_COORD 0 /*================== - * FONT USAGE + * FONT USAGE *===================*/ -/* The built-in fonts contains the ASCII range and some Symbols with 4 bit-per-pixel. - * The symbols are available via `LV_SYMBOL_...` defines - * More info about fonts: https://docs.lvgl.com/#Fonts - * To create a new font go to: https://lvgl.com/ttf-font-to-c-array - */ - -/* Montserrat fonts with bpp = 4 - * https://fonts.google.com/specimen/Montserrat */ -#define LV_FONT_MONTSERRAT_12 0 -#define LV_FONT_MONTSERRAT_14 0 -#define LV_FONT_MONTSERRAT_16 1 -#define LV_FONT_MONTSERRAT_18 0 -#define LV_FONT_MONTSERRAT_20 0 -#define LV_FONT_MONTSERRAT_22 0 -#define LV_FONT_MONTSERRAT_24 0 -#define LV_FONT_MONTSERRAT_26 0 -#define LV_FONT_MONTSERRAT_28 0 -#define LV_FONT_MONTSERRAT_30 0 -#define LV_FONT_MONTSERRAT_32 0 -#define LV_FONT_MONTSERRAT_34 0 -#define LV_FONT_MONTSERRAT_36 0 -#define LV_FONT_MONTSERRAT_38 0 -#define LV_FONT_MONTSERRAT_40 0 -#define LV_FONT_MONTSERRAT_42 0 -#define LV_FONT_MONTSERRAT_44 0 -#define LV_FONT_MONTSERRAT_46 0 -#define LV_FONT_MONTSERRAT_48 0 - -/* Demonstrate special features */ +/*Montserrat fonts with ASCII range and some symbols using bpp = 4 + *https://fonts.google.com/specimen/Montserrat*/ +#define LV_FONT_MONTSERRAT_8 0 +#define LV_FONT_MONTSERRAT_10 0 +#define LV_FONT_MONTSERRAT_12 0 +#define LV_FONT_MONTSERRAT_14 1 +#define LV_FONT_MONTSERRAT_16 0 +#define LV_FONT_MONTSERRAT_18 0 +#define LV_FONT_MONTSERRAT_20 0 +#define LV_FONT_MONTSERRAT_22 0 +#define LV_FONT_MONTSERRAT_24 0 +#define LV_FONT_MONTSERRAT_26 0 +#define LV_FONT_MONTSERRAT_28 0 +#define LV_FONT_MONTSERRAT_30 0 +#define LV_FONT_MONTSERRAT_32 0 +#define LV_FONT_MONTSERRAT_34 0 +#define LV_FONT_MONTSERRAT_36 0 +#define LV_FONT_MONTSERRAT_38 0 +#define LV_FONT_MONTSERRAT_40 0 +#define LV_FONT_MONTSERRAT_42 0 +#define LV_FONT_MONTSERRAT_44 0 +#define LV_FONT_MONTSERRAT_46 0 +#define LV_FONT_MONTSERRAT_48 0 + +/*Demonstrate special features*/ #define LV_FONT_MONTSERRAT_12_SUBPX 0 #define LV_FONT_MONTSERRAT_28_COMPRESSED 0 /*bpp = 3*/ -#define LV_FONT_DEJAVU_16_PERSIAN_HEBREW 0 /*Hebrew, Arabic, PErisan letters and all their forms*/ +#define LV_FONT_DEJAVU_16_PERSIAN_HEBREW 0 /*Hebrew, Arabic, Persian letters and all their forms*/ #define LV_FONT_SIMSUN_16_CJK 0 /*1000 most common CJK radicals*/ -/*Pixel perfect monospace font - * http://pelulamu.net/unscii/ */ -#define LV_FONT_UNSCII_8 0 +/*Pixel perfect monospace fonts*/ +#define LV_FONT_UNSCII_8 0 +#define LV_FONT_UNSCII_16 0 -/* Optionally declare your custom fonts here. - * You can use these fonts as default font too - * and they will be available globally. E.g. - * #define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(my_font_1) \ - * LV_FONT_DECLARE(my_font_2) - */ +/*Optionally declare custom fonts here. + *You can use these fonts as default font too and they will be available globally. + *E.g. #define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(my_font_1) LV_FONT_DECLARE(my_font_2)*/ #define LV_FONT_CUSTOM_DECLARE -/* Enable it if you have fonts with a lot of characters. - * The limit depends on the font size, font face and bpp - * but with > 10,000 characters if you see issues probably you need to enable it.*/ -#define LV_FONT_FMT_TXT_LARGE 0 +/*Always set a default font*/ +#define LV_FONT_DEFAULT &lv_font_montserrat_14 -/* Set the pixel order of the display. - * Important only if "subpx fonts" are used. - * With "normal" font it doesn't matter. - */ -#define LV_FONT_SUBPX_BGR 0 +/*Enable handling large font and/or fonts with a lot of characters. + *The limit depends on the font size, font face and bpp. + *Compiler error will be triggered if a font needs it.*/ +#define LV_FONT_FMT_TXT_LARGE 0 -/*Declare the type of the user data of fonts (can be e.g. `void *`, `int`, `struct`)*/ -typedef void * lv_font_user_data_t; +/*Enables/disables support for compressed fonts.*/ +#define LV_USE_FONT_COMPRESSED 0 -/*================ - * THEME USAGE - *================*/ +/*Enable subpixel rendering*/ +#define LV_USE_FONT_SUBPX 0 +#if LV_USE_FONT_SUBPX + /*Set the pixel order of the display. Physical order of RGB channels. Doesn't matter with "normal" fonts.*/ + #define LV_FONT_SUBPX_BGR 0 /*0: RGB; 1:BGR order*/ +#endif -/*Always enable at least on theme*/ - -/* No theme, you can apply your styles as you need - * No flags. Set LV_THEME_DEFAULT_FLAG 0 */ - #define LV_USE_THEME_EMPTY 1 - -/*Simple to the create your theme based on it - * No flags. Set LV_THEME_DEFAULT_FLAG 0 */ - #define LV_USE_THEME_TEMPLATE 1 - -/* A fast and impressive theme. - * Flags: - * LV_THEME_MATERIAL_FLAG_LIGHT: light theme - * LV_THEME_MATERIAL_FLAG_DARK: dark theme*/ - #define LV_USE_THEME_MATERIAL 1 - -/* Mono-color theme for monochrome displays. - * If LV_THEME_DEFAULT_COLOR_PRIMARY is LV_COLOR_BLACK the - * texts and borders will be black and the background will be - * white. Else the colors are inverted. - * No flags. Set LV_THEME_DEFAULT_FLAG 0 */ - #define LV_USE_THEME_MONO 1 - -#define LV_THEME_DEFAULT_INCLUDE /*Include a header for the init. function*/ -#define LV_THEME_DEFAULT_INIT lv_theme_material_init -#define LV_THEME_DEFAULT_COLOR_PRIMARY LV_COLOR_RED -#define LV_THEME_DEFAULT_COLOR_SECONDARY LV_COLOR_BLUE -#define LV_THEME_DEFAULT_FLAG LV_THEME_MATERIAL_FLAG_LIGHT -#define LV_THEME_DEFAULT_FONT_SMALL &lv_font_montserrat_16 -#define LV_THEME_DEFAULT_FONT_NORMAL &lv_font_montserrat_16 -#define LV_THEME_DEFAULT_FONT_SUBTITLE &lv_font_montserrat_16 -#define LV_THEME_DEFAULT_FONT_TITLE &lv_font_montserrat_16 +/*Enable drawing placeholders when glyph dsc is not found*/ +#define LV_USE_FONT_PLACEHOLDER 1 /*================= - * Text settings + * TEXT SETTINGS *=================*/ -/* Select a character encoding for strings. +/** + * Select a character encoding for strings. * Your IDE or editor should have the same character encoding * - LV_TXT_ENC_UTF8 * - LV_TXT_ENC_ASCII - * */ + */ #define LV_TXT_ENC LV_TXT_ENC_UTF8 - /*Can break (wrap) texts on these chars*/ -#define LV_TXT_BREAK_CHARS " ,.;:-_" +/*Can break (wrap) texts on these chars*/ +#define LV_TXT_BREAK_CHARS " ,.;:-_" -/* If a word is at least this long, will break wherever "prettiest" - * To disable, set to a value <= 0 */ -#define LV_TXT_LINE_BREAK_LONG_LEN 0 +/*If a word is at least this long, will break wherever "prettiest" + *To disable, set to a value <= 0*/ +#define LV_TXT_LINE_BREAK_LONG_LEN 0 -/* Minimum number of characters in a long word to put on a line before a break. - * Depends on LV_TXT_LINE_BREAK_LONG_LEN. */ -#define LV_TXT_LINE_BREAK_LONG_PRE_MIN_LEN 3 +/*Minimum number of characters in a long word to put on a line before a break. + *Depends on LV_TXT_LINE_BREAK_LONG_LEN.*/ +#define LV_TXT_LINE_BREAK_LONG_PRE_MIN_LEN 3 -/* Minimum number of characters in a long word to put on a line after a break. - * Depends on LV_TXT_LINE_BREAK_LONG_LEN. */ +/*Minimum number of characters in a long word to put on a line after a break. + *Depends on LV_TXT_LINE_BREAK_LONG_LEN.*/ #define LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN 3 -/* The control character to use for signalling text recoloring. */ +/*The control character to use for signalling text recoloring.*/ #define LV_TXT_COLOR_CMD "#" -/* Support bidirectional texts. - * Allows mixing Left-to-Right and Right-to-Left texts. - * The direction will be processed according to the Unicode Bidirectioanl Algorithm: - * https://www.w3.org/International/articles/inline-bidi-markup/uba-basics*/ -#define LV_USE_BIDI 0 +/*Support bidirectional texts. Allows mixing Left-to-Right and Right-to-Left texts. + *The direction will be processed according to the Unicode Bidirectional Algorithm: + *https://www.w3.org/International/articles/inline-bidi-markup/uba-basics*/ +#define LV_USE_BIDI 0 #if LV_USE_BIDI -/* Set the default direction. Supported values: - * `LV_BIDI_DIR_LTR` Left-to-Right - * `LV_BIDI_DIR_RTL` Right-to-Left - * `LV_BIDI_DIR_AUTO` detect texts base direction */ -#define LV_BIDI_BASE_DIR_DEF LV_BIDI_DIR_AUTO + /*Set the default direction. Supported values: + *`LV_BASE_DIR_LTR` Left-to-Right + *`LV_BASE_DIR_RTL` Right-to-Left + *`LV_BASE_DIR_AUTO` detect texts base direction*/ + #define LV_BIDI_BASE_DIR_DEF LV_BASE_DIR_AUTO #endif -/* Enable Arabic/Persian processing - * In these languages characters should be replaced with - * an other form based on their position in the text */ +/*Enable Arabic/Persian processing + *In these languages characters should be replaced with an other form based on their position in the text*/ #define LV_USE_ARABIC_PERSIAN_CHARS 0 -/*Change the built in (v)snprintf functions*/ -#define LV_SPRINTF_CUSTOM 0 -#if LV_SPRINTF_CUSTOM -# define LV_SPRINTF_INCLUDE -# define lv_snprintf snprintf -# define lv_vsnprintf vsnprintf -#else /*!LV_SPRINTF_CUSTOM*/ -# define LV_SPRINTF_DISABLE_FLOAT 1 -#endif /*LV_SPRINTF_CUSTOM*/ +/*================== + * WIDGET USAGE + *================*/ -/*=================== - * LV_OBJ SETTINGS - *==================*/ +/*Documentation of the widgets: https://docs.lvgl.io/latest/en/html/widgets/index.html*/ + +#define LV_USE_ARC 1 -#if LV_USE_USER_DATA -/*Declare the type of the user data of object (can be e.g. `void *`, `int`, `struct`)*/ -typedef void * lv_obj_user_data_t; -/*Provide a function to free user data*/ -#define LV_USE_USER_DATA_FREE 0 -#if LV_USE_USER_DATA_FREE -# define LV_USER_DATA_FREE_INCLUDE "something.h" /*Header for user data free function*/ -/* Function prototype : void user_data_free(lv_obj_t * obj); */ -# define LV_USER_DATA_FREE (user_data_free) /*Invoking for user data free function*/ +#define LV_USE_BAR 1 + +#define LV_USE_BTN 1 + +#define LV_USE_BTNMATRIX 1 + +#define LV_USE_CANVAS 1 + +#define LV_USE_CHECKBOX 1 + +#define LV_USE_DROPDOWN 1 /*Requires: lv_label*/ + +#define LV_USE_IMG 1 /*Requires: lv_label*/ + +#define LV_USE_LABEL 1 +#if LV_USE_LABEL + #define LV_LABEL_TEXT_SELECTION 1 /*Enable selecting text of the label*/ + #define LV_LABEL_LONG_TXT_HINT 1 /*Store some extra info in labels to speed up drawing of very long texts*/ #endif + +#define LV_USE_LINE 1 + +#define LV_USE_ROLLER 1 /*Requires: lv_label*/ +#if LV_USE_ROLLER + #define LV_ROLLER_INF_PAGES 7 /*Number of extra "pages" when the roller is infinite*/ #endif -/*1: enable `lv_obj_realaign()` based on `lv_obj_align()` parameters*/ -#define LV_USE_OBJ_REALIGN 1 +#define LV_USE_SLIDER 1 /*Requires: lv_bar*/ -/* Enable to make the object clickable on a larger area. - * LV_EXT_CLICK_AREA_OFF or 0: Disable this feature - * LV_EXT_CLICK_AREA_TINY: The extra area can be adjusted horizontally and vertically (0..255 px) - * LV_EXT_CLICK_AREA_FULL: The extra area can be adjusted in all 4 directions (-32k..+32k px) - */ -#define LV_USE_EXT_CLICK_AREA LV_EXT_CLICK_AREA_TINY +#define LV_USE_SWITCH 1 + +#define LV_USE_TEXTAREA 1 /*Requires: lv_label*/ +#if LV_USE_TEXTAREA != 0 + #define LV_TEXTAREA_DEF_PWD_SHOW_TIME 1500 /*ms*/ +#endif + +#define LV_USE_TABLE 1 /*================== - * LV OBJ X USAGE - *================*/ -/* - * Documentation of the object types: https://docs.lvgl.com/#Object-types - */ + * EXTRA COMPONENTS + *==================*/ -/*Arc (dependencies: -)*/ -#define LV_USE_ARC 1 +/*----------- + * Widgets + *----------*/ +#define LV_USE_ANIMIMG 1 -/*Bar (dependencies: -)*/ -#define LV_USE_BAR 1 +#define LV_USE_CALENDAR 1 +#if LV_USE_CALENDAR + #define LV_CALENDAR_WEEK_STARTS_MONDAY 0 + #if LV_CALENDAR_WEEK_STARTS_MONDAY + #define LV_CALENDAR_DEFAULT_DAY_NAMES {"Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"} + #else + #define LV_CALENDAR_DEFAULT_DAY_NAMES {"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"} + #endif -/*Button (dependencies: lv_cont*/ -#define LV_USE_BTN 1 + #define LV_CALENDAR_DEFAULT_MONTH_NAMES {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"} + #define LV_USE_CALENDAR_HEADER_ARROW 1 + #define LV_USE_CALENDAR_HEADER_DROPDOWN 1 +#endif /*LV_USE_CALENDAR*/ -/*Button matrix (dependencies: -)*/ -#define LV_USE_BTNMATRIX 1 +#define LV_USE_CHART 1 -/*Calendar (dependencies: -)*/ -#define LV_USE_CALENDAR 1 +#define LV_USE_COLORWHEEL 1 -/*Canvas (dependencies: lv_img)*/ -#define LV_USE_CANVAS 1 +#define LV_USE_IMGBTN 1 -/*Check box (dependencies: lv_btn, lv_label)*/ -#define LV_USE_CHECKBOX 1 +#define LV_USE_KEYBOARD 1 -/*Chart (dependencies: -)*/ -#define LV_USE_CHART 1 -#if LV_USE_CHART -# define LV_CHART_AXIS_TICK_LABEL_MAX_LEN 256 -#endif +#define LV_USE_LED 1 + +#define LV_USE_LIST 1 -/*Container (dependencies: -*/ -#define LV_USE_CONT 1 +#define LV_USE_MENU 1 -/*Color picker (dependencies: -*/ -#define LV_USE_CPICKER 1 +#define LV_USE_METER 1 + +#define LV_USE_MSGBOX 1 -/*Drop down list (dependencies: lv_page, lv_label, lv_symbol_def.h)*/ -#define LV_USE_DROPDOWN 1 -#if LV_USE_DROPDOWN != 0 -/*Open and close default animation time [ms] (0: no animation)*/ -# define LV_DROPDOWN_DEF_ANIM_TIME 200 +#define LV_USE_SPAN 1 +#if LV_USE_SPAN + /*A line text can contain maximum num of span descriptor */ + #define LV_SPAN_SNIPPET_STACK_SIZE 64 #endif -/*Gauge (dependencies:lv_bar, lv_linemeter)*/ -#define LV_USE_GAUGE 1 +#define LV_USE_SPINBOX 1 -/*Image (dependencies: lv_label*/ -#define LV_USE_IMG 1 +#define LV_USE_SPINNER 1 -/*Image Button (dependencies: lv_btn*/ -#define LV_USE_IMGBTN 1 -#if LV_USE_IMGBTN -/*1: The imgbtn requires left, mid and right parts and the width can be set freely*/ -# define LV_IMGBTN_TILED 0 -#endif +#define LV_USE_TABVIEW 1 -/*Keyboard (dependencies: lv_btnm)*/ -#define LV_USE_KEYBOARD 1 +#define LV_USE_TILEVIEW 1 -/*Label (dependencies: -*/ -#define LV_USE_LABEL 1 -#if LV_USE_LABEL != 0 -/*Hor, or ver. scroll speed [px/sec] in 'LV_LABEL_LONG_ROLL/ROLL_CIRC' mode*/ -# define LV_LABEL_DEF_SCROLL_SPEED 25 +#define LV_USE_WIN 1 -/* Waiting period at beginning/end of animation cycle */ -# define LV_LABEL_WAIT_CHAR_COUNT 3 +/*----------- + * Themes + *----------*/ -/*Enable selecting text of the label */ -# define LV_LABEL_TEXT_SEL 0 +/*A simple, impressive and very complete theme*/ +#define LV_USE_THEME_DEFAULT 1 +#if LV_USE_THEME_DEFAULT -/*Store extra some info in labels (12 bytes) to speed up drawing of very long texts*/ -# define LV_LABEL_LONG_TXT_HINT 0 -#endif + /*0: Light mode; 1: Dark mode*/ + #define LV_THEME_DEFAULT_DARK 0 -/*LED (dependencies: -)*/ -#define LV_USE_LED 1 -#if LV_USE_LED -# define LV_LED_BRIGHT_MIN 120 /*Minimal brightness*/ -# define LV_LED_BRIGHT_MAX 255 /*Maximal brightness*/ -#endif + /*1: Enable grow on press*/ + #define LV_THEME_DEFAULT_GROW 1 -/*Line (dependencies: -*/ -#define LV_USE_LINE 1 + /*Default transition time in [ms]*/ + #define LV_THEME_DEFAULT_TRANSITION_TIME 80 +#endif /*LV_USE_THEME_DEFAULT*/ -/*List (dependencies: lv_page, lv_btn, lv_label, (lv_img optionally for icons ))*/ -#define LV_USE_LIST 1 -#if LV_USE_LIST != 0 -/*Default animation time of focusing to a list element [ms] (0: no animation) */ -# define LV_LIST_DEF_ANIM_TIME 100 -#endif +/*A very simple theme that is a good starting point for a custom theme*/ +#define LV_USE_THEME_BASIC 1 -/*Line meter (dependencies: *;)*/ -#define LV_USE_LINEMETER 1 -#if LV_USE_LINEMETER -/* Draw line more precisely at cost of performance. - * Useful if there are lot of lines any minor are visible - * 0: No extra precision - * 1: Some extra precision - * 2: Best precision - */ -# define LV_LINEMETER_PRECISE 0 +/*A theme designed for monochrome displays*/ +#define LV_USE_THEME_MONO 1 + +/*----------- + * Layouts + *----------*/ + +/*A layout similar to Flexbox in CSS.*/ +#define LV_USE_FLEX 1 + +/*A layout similar to Grid in CSS.*/ +#define LV_USE_GRID 1 + +/*--------------------- + * 3rd party libraries + *--------------------*/ + +/*File system interfaces for common APIs */ + +/*API for fopen, fread, etc*/ +#define LV_USE_FS_STDIO 0 +#if LV_USE_FS_STDIO + #define LV_FS_STDIO_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/ + #define LV_FS_STDIO_PATH "" /*Set the working directory. File/directory paths will be appended to it.*/ + #define LV_FS_STDIO_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/ #endif -/*Mask (dependencies: -)*/ -#define LV_USE_OBJMASK 1 +/*API for open, read, etc*/ +#define LV_USE_FS_POSIX 0 +#if LV_USE_FS_POSIX + #define LV_FS_POSIX_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/ + #define LV_FS_POSIX_PATH "" /*Set the working directory. File/directory paths will be appended to it.*/ + #define LV_FS_POSIX_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/ +#endif -/*Message box (dependencies: lv_rect, lv_btnm, lv_label)*/ -#define LV_USE_MSGBOX 1 +/*API for CreateFile, ReadFile, etc*/ +#define LV_USE_FS_WIN32 0 +#if LV_USE_FS_WIN32 + #define LV_FS_WIN32_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/ + #define LV_FS_WIN32_PATH "" /*Set the working directory. File/directory paths will be appended to it.*/ + #define LV_FS_WIN32_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/ +#endif -/*Page (dependencies: lv_cont)*/ -#define LV_USE_PAGE 1 -#if LV_USE_PAGE != 0 -/*Focus default animation time [ms] (0: no animation)*/ -# define LV_PAGE_DEF_ANIM_TIME 400 +/*API for FATFS (needs to be added separately). Uses f_open, f_read, etc*/ +#define LV_USE_FS_FATFS 0 +#if LV_USE_FS_FATFS + #define LV_FS_FATFS_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/ + #define LV_FS_FATFS_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/ #endif -/*Preload (dependencies: lv_arc, lv_anim)*/ -#define LV_USE_SPINNER 1 -#if LV_USE_SPINNER != 0 -# define LV_SPINNER_DEF_ARC_LENGTH 60 /*[deg]*/ -# define LV_SPINNER_DEF_SPIN_TIME 1000 /*[ms]*/ -# define LV_SPINNER_DEF_ANIM LV_SPINNER_TYPE_SPINNING_ARC +/*PNG decoder library*/ +#define LV_USE_PNG 0 + +/*BMP decoder library*/ +#define LV_USE_BMP 0 + +/* JPG + split JPG decoder library. + * Split JPG is a custom format optimized for embedded systems. */ +#define LV_USE_SJPG 0 + +/*GIF decoder library*/ +#define LV_USE_GIF 0 + +/*QR code library*/ +#define LV_USE_QRCODE 0 + +/*FreeType library*/ +#define LV_USE_FREETYPE 0 +#if LV_USE_FREETYPE + /*Memory used by FreeType to cache characters [bytes] (-1: no caching)*/ + #define LV_FREETYPE_CACHE_SIZE (16 * 1024) + #if LV_FREETYPE_CACHE_SIZE >= 0 + /* 1: bitmap cache use the sbit cache, 0:bitmap cache use the image cache. */ + /* sbit cache:it is much more memory efficient for small bitmaps(font size < 256) */ + /* if font size >= 256, must be configured as image cache */ + #define LV_FREETYPE_SBIT_CACHE 0 + /* Maximum number of opened FT_Face/FT_Size objects managed by this cache instance. */ + /* (0:use system defaults) */ + #define LV_FREETYPE_CACHE_FT_FACES 0 + #define LV_FREETYPE_CACHE_FT_SIZES 0 + #endif #endif -/*Roller (dependencies: lv_ddlist)*/ -#define LV_USE_ROLLER 1 -#if LV_USE_ROLLER != 0 -/*Focus animation time [ms] (0: no animation)*/ -# define LV_ROLLER_DEF_ANIM_TIME 200 +/*Rlottie library*/ +#define LV_USE_RLOTTIE 0 -/*Number of extra "pages" when the roller is infinite*/ -# define LV_ROLLER_INF_PAGES 7 +/*FFmpeg library for image decoding and playing videos + *Supports all major image formats so do not enable other image decoder with it*/ +#define LV_USE_FFMPEG 0 +#if LV_USE_FFMPEG + /*Dump input information to stderr*/ + #define LV_FFMPEG_DUMP_FORMAT 0 #endif -/*Slider (dependencies: lv_bar)*/ -#define LV_USE_SLIDER 1 +/*----------- + * Others + *----------*/ -/*Spinbox (dependencies: lv_ta)*/ -#define LV_USE_SPINBOX 1 +/*1: Enable API to take snapshot for object*/ +#define LV_USE_SNAPSHOT 0 -/*Switch (dependencies: lv_slider)*/ -#define LV_USE_SWITCH 1 +/*1: Enable Monkey test*/ +#define LV_USE_MONKEY 0 -/*Text area (dependencies: lv_label, lv_page)*/ -#define LV_USE_TEXTAREA 1 -#if LV_USE_TEXTAREA != 0 -# define LV_TEXTAREA_DEF_CURSOR_BLINK_TIME 400 /*ms*/ -# define LV_TEXTAREA_DEF_PWD_SHOW_TIME 1500 /*ms*/ -#endif +/*1: Enable grid navigation*/ +#define LV_USE_GRIDNAV 0 -/*Table (dependencies: lv_label)*/ -#define LV_USE_TABLE 1 -#if LV_USE_TABLE -# define LV_TABLE_COL_MAX 12 -#endif +/*1: Enable lv_obj fragment*/ +#define LV_USE_FRAGMENT 0 + +/*1: Support using images as font in label or span widgets */ +#define LV_USE_IMGFONT 0 + +/*1: Enable a published subscriber based messaging system */ +#define LV_USE_MSG 0 + +/*1: Enable Pinyin input method*/ +/*Requires: lv_keyboard*/ +#define LV_USE_IME_PINYIN 0 +#if LV_USE_IME_PINYIN + /*1: Use default thesaurus*/ + /*If you do not use the default thesaurus, be sure to use `lv_ime_pinyin` after setting the thesauruss*/ + #define LV_IME_PINYIN_USE_DEFAULT_DICT 1 + /*Set the maximum number of candidate panels that can be displayed*/ + /*This needs to be adjusted according to the size of the screen*/ + #define LV_IME_PINYIN_CAND_TEXT_NUM 6 -/*Tab (dependencies: lv_page, lv_btnm)*/ -#define LV_USE_TABVIEW 1 -# if LV_USE_TABVIEW != 0 -/*Time of slide animation [ms] (0: no animation)*/ -# define LV_TABVIEW_DEF_ANIM_TIME 300 + /*Use 9 key input(k9)*/ + #define LV_IME_PINYIN_USE_K9_MODE 1 + #if LV_IME_PINYIN_USE_K9_MODE == 1 + #define LV_IME_PINYIN_K9_CAND_TEXT_NUM 3 + #endif // LV_IME_PINYIN_USE_K9_MODE #endif -/*Tileview (dependencies: lv_page) */ -#define LV_USE_TILEVIEW 1 -#if LV_USE_TILEVIEW -/*Time of slide animation [ms] (0: no animation)*/ -# define LV_TILEVIEW_DEF_ANIM_TIME 300 +/*================== +* EXAMPLES +*==================*/ + +/*Enable the examples to be built with the library*/ +#define LV_BUILD_EXAMPLES 1 + +/*=================== + * DEMO USAGE + ====================*/ + +/*Show some widget. It might be required to increase `LV_MEM_SIZE` */ +#define LV_USE_DEMO_WIDGETS 0 +#if LV_USE_DEMO_WIDGETS +#define LV_DEMO_WIDGETS_SLIDESHOW 0 #endif -/*Window (dependencies: lv_cont, lv_btn, lv_label, lv_img, lv_page)*/ -#define LV_USE_WIN 1 +/*Demonstrate the usage of encoder and keyboard*/ +#define LV_USE_DEMO_KEYPAD_AND_ENCODER 0 -/*================== - * Non-user section - *==================*/ +/*Benchmark your system*/ +#define LV_USE_DEMO_BENCHMARK 0 +#if LV_USE_DEMO_BENCHMARK +/*Use RGB565A8 images with 16 bit color depth instead of ARGB8565*/ +#define LV_DEMO_BENCHMARK_RGB565A8 0 +#endif -#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) /* Disable warnings for Visual Studio*/ -# define _CRT_SECURE_NO_WARNINGS +/*Stress test for LVGL*/ +#define LV_USE_DEMO_STRESS 0 + +/*Music player demo*/ +#define LV_USE_DEMO_MUSIC 0 +#if LV_USE_DEMO_MUSIC + #define LV_DEMO_MUSIC_SQUARE 0 + #define LV_DEMO_MUSIC_LANDSCAPE 0 + #define LV_DEMO_MUSIC_ROUND 0 + #define LV_DEMO_MUSIC_LARGE 0 + #define LV_DEMO_MUSIC_AUTO_PLAY 0 #endif /*--END OF LV_CONF_H--*/ #endif /*LV_CONF_H*/ -#endif /*End of "Content enable"*/ +#endif /*End of "Content enable"*/ \ No newline at end of file diff --git a/lvgl-sys/vendor/lvgl b/lvgl-sys/vendor/lvgl index 52470947..f29514aa 160000 --- a/lvgl-sys/vendor/lvgl +++ b/lvgl-sys/vendor/lvgl @@ -1 +1 @@ -Subproject commit 524709472757405ac0eef8d6d002632526430df3 +Subproject commit f29514aa5c34d84f69a7ed30835bbffc5cbd515c diff --git a/lvgl/Cargo.toml b/lvgl/Cargo.toml index c2289362..2beeeda6 100644 --- a/lvgl/Cargo.toml +++ b/lvgl/Cargo.toml @@ -17,6 +17,7 @@ cty = "0.2.2" embedded-graphics = { version = "0.7.1", optional = true } cstr_core = { version = "0.2.6", default-features = false, features = ["alloc"] } bitflags = "1.3.2" +paste = "1.0.11" [features] default = ["embedded_graphics"] @@ -55,8 +56,8 @@ path = "../examples/button_click.rs" required-features = ["alloc", "embedded_graphics"] [[example]] -name = "gauge" -path = "../examples/gauge.rs" +name = "meter" +path = "../examples/meter.rs" required-features = ["alloc", "embedded_graphics"] [[example]] diff --git a/lvgl/src/allocator.rs b/lvgl/src/allocator.rs index f25ce844..52611fa6 100644 --- a/lvgl/src/allocator.rs +++ b/lvgl/src/allocator.rs @@ -16,6 +16,6 @@ unsafe impl GlobalAlloc for LvglAlloc { unsafe fn dealloc(&self, ptr: *mut u8, _layout: Layout) { crate::init(); - lvgl_sys::lv_mem_free(ptr as *const cty::c_void) + lvgl_sys::lv_mem_free(ptr as *mut cty::c_void) } } diff --git a/lvgl/src/display.rs b/lvgl/src/display.rs index 5175233e..f8c20ae4 100644 --- a/lvgl/src/display.rs +++ b/lvgl/src/display.rs @@ -1,11 +1,13 @@ use crate::functions::CoreError; -use crate::{disp_drv_register, disp_get_default, get_str_act}; -use crate::{Box, RunOnce}; -use crate::{Color, Obj}; +use crate::{disp_drv_register, disp_get_default, get_str_act, RunOnce}; +use crate::{Box, Color, Obj}; use core::cell::RefCell; +use core::convert::TryInto; use core::mem::MaybeUninit; use core::ptr::NonNull; use core::{ptr, result}; +use cty::c_void; +use lvgl_sys::_lv_disp_draw_buf_t; /// Error in interacting with a `Display`. #[derive(Debug, Copy, Clone, Eq, PartialEq)] @@ -30,13 +32,18 @@ impl<'a> Display { /// Registers a given `DrawBuffer` with an associated update function to /// LVGL. `display_update` takes a `&DisplayRefresh`. pub fn register( - draw_buffer: &'a DrawBuffer, + draw_buffer: DrawBuffer, + hor_res: u32, + ver_res: u32, display_update: F, ) -> Result where F: FnMut(&DisplayRefresh) + 'a, { let mut display_diver = DisplayDriver::new(draw_buffer, display_update)?; + let disp_p = &mut display_diver.disp_drv; + disp_p.hor_res = hor_res.try_into().unwrap_or(240); + disp_p.ver_res = ver_res.try_into().unwrap_or(240); Ok(disp_drv_register(&mut display_diver)?) } @@ -65,28 +72,29 @@ impl DefaultDisplay { /// entire number of pixels on the screen, in which case the screen will be /// drawn to multiple times per frame. pub struct DrawBuffer { + //inner: NonNull, initialized: RunOnce, refresh_buffer: RefCell<[MaybeUninit; N]>, } impl DrawBuffer { - /// Constructs an empty `DrawBuffer`. - pub const fn new() -> Self { + /// Initializes an empty `DrawBuffer`. + pub fn new() -> Self { Self { initialized: RunOnce::new(), refresh_buffer: RefCell::new([MaybeUninit::uninit(); N]), } } - fn get_ptr(&self) -> Option> { + fn get_ptr(&self) -> Option> { if self.initialized.swap_and_check() { // TODO: needs to be 'static somehow // Cannot be in the DrawBuffer struct because the type `lv_disp_buf_t` contains a raw // pointer and raw pointers are not Send and consequently cannot be in `static` variables. - let mut inner: MaybeUninit = MaybeUninit::uninit(); + let mut inner: MaybeUninit = MaybeUninit::uninit(); let primary_buffer_guard = &self.refresh_buffer; let draw_buf = unsafe { - lvgl_sys::lv_disp_buf_init( + lvgl_sys::lv_disp_draw_buf_init( inner.as_mut_ptr(), primary_buffer_guard.borrow_mut().as_mut_ptr() as *mut _ as *mut cty::c_void, ptr::null_mut(), @@ -101,15 +109,13 @@ impl DrawBuffer { } } -pub(crate) struct DisplayDriver { +pub(crate) struct DisplayDriver { pub(crate) disp_drv: lvgl_sys::lv_disp_drv_t, + _buffer: DrawBuffer, } -impl<'a> DisplayDriver { - pub fn new( - draw_buffer: &'a DrawBuffer, - display_update_callback: F, - ) -> Result +impl<'a, const N: usize> DisplayDriver { + pub fn new(draw_buffer: DrawBuffer, display_update_callback: F) -> Result where F: FnMut(&DisplayRefresh) + 'a, { @@ -120,20 +126,23 @@ impl<'a> DisplayDriver { }; // Safety: The variable `draw_buffer` is statically allocated, no need to worry about this being dropped. - disp_drv.buffer = draw_buffer - .get_ptr() - .map(|ptr| Box::into_raw(ptr) as *mut _) - .ok_or(DisplayError::FailedToRegister)?; + disp_drv.draw_buf = Box::<_lv_disp_draw_buf_t>::into_raw( + draw_buffer + .get_ptr() + .ok_or(DisplayError::FailedToRegister)?, + ) as *mut _; - disp_drv.user_data = Box::into_raw(Box::new(display_update_callback)) as *mut _ - as lvgl_sys::lv_disp_drv_user_data_t; + disp_drv.user_data = Box::into_raw(Box::new(display_update_callback)) as *mut c_void; // Sets trampoline pointer to the function implementation that uses the `F` type for a // refresh buffer of size N specifically. disp_drv.flush_cb = Some(disp_flush_trampoline::); // We do not store any memory that can be accidentally deallocated by on the Rust side. - Ok(Self { disp_drv }) + Ok(Self { + disp_drv, + _buffer: draw_buffer, + }) } } diff --git a/lvgl/src/functions.rs b/lvgl/src/functions.rs index 3450f735..2fd93123 100644 --- a/lvgl/src/functions.rs +++ b/lvgl/src/functions.rs @@ -1,6 +1,6 @@ use crate::display::{Display, DisplayDriver}; use crate::input_device::generic::InputDriver; -use crate::{Event, LvResult, Obj, Widget}; +use crate::{Event, LvError, LvResult, Obj, Widget}; use core::ptr::NonNull; use core::time::Duration; use core::{ptr, result}; @@ -15,7 +15,9 @@ pub enum CoreError { type Result = result::Result; /// Register own buffer -pub(crate) fn disp_drv_register(disp_drv: &mut DisplayDriver) -> Result { +pub(crate) fn disp_drv_register( + disp_drv: &mut DisplayDriver, +) -> Result { let disp_ptr = unsafe { lvgl_sys::lv_disp_drv_register(&mut disp_drv.disp_drv as *mut _) }; Ok(Display::from_raw( NonNull::new(disp_ptr).ok_or(CoreError::OperationFailed)?, @@ -50,10 +52,10 @@ pub fn tick_inc(tick_period: Duration) { } } -/// Calls the LVGL task handler. This function should be called periodically. +/// Calls the LVGL timer handler. This function should be called periodically. #[inline] pub fn task_handler() { - unsafe { lvgl_sys::lv_task_handler() }; + unsafe { lvgl_sys::lv_timer_handler() }; } /// Directly send an event to a specific widget. @@ -68,7 +70,10 @@ pub fn event_send(obj: &mut W, event: Event) -> LvRe /// Register an input device driver to LVGL. pub fn indev_drv_register(input_device: &mut impl InputDriver) -> LvResult<()> { unsafe { - let descr = lvgl_sys::lv_indev_drv_register(&mut input_device.get_driver() as *mut _); + let descr = lvgl_sys::lv_indev_drv_register(input_device.get_driver() as *mut _); + if descr.is_null() { + return Err(LvError::LvOOMemory); + } input_device.set_descriptor(descr)?; }; Ok(()) diff --git a/lvgl/src/input_device/generic.rs b/lvgl/src/input_device/generic.rs index cf533322..5a707e87 100644 --- a/lvgl/src/input_device/generic.rs +++ b/lvgl/src/input_device/generic.rs @@ -39,6 +39,6 @@ pub trait InputDriver { where F: Fn() -> BufferStatus; - fn get_driver(&self) -> lvgl_sys::lv_indev_drv_t; + fn get_driver(&mut self) -> &mut lvgl_sys::lv_indev_drv_t; unsafe fn set_descriptor(&mut self, descriptor: *mut lvgl_sys::lv_indev_t) -> LvResult<()>; } diff --git a/lvgl/src/input_device/pointer.rs b/lvgl/src/input_device/pointer.rs index 43e75b65..b80cd566 100644 --- a/lvgl/src/input_device/pointer.rs +++ b/lvgl/src/input_device/pointer.rs @@ -1,8 +1,8 @@ +use super::generic::{BufferStatus, Data, InputDriver, InputState}; use crate::Box; use crate::{LvError, LvResult}; use core::mem::MaybeUninit; use embedded_graphics::geometry::Point; -use super::generic::{BufferStatus, Data, InputDriver, InputState}; /// Pointer-specific input data. Contains the point clicked and the key. #[derive(Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)] @@ -23,8 +23,8 @@ impl PointerInputData { /// Represents a pointer-type input driver. pub struct Pointer { - pub(crate) driver: lvgl_sys::lv_indev_drv_t, - pub(crate) descriptor: Option, + pub(crate) driver: Box, + pub(crate) descriptor: Option<*mut lvgl_sys::lv_indev_t>, } impl InputDriver for Pointer { @@ -35,11 +35,11 @@ impl InputDriver for Pointer { let driver = unsafe { let mut indev_drv = MaybeUninit::uninit(); lvgl_sys::lv_indev_drv_init(indev_drv.as_mut_ptr()); - let mut indev_drv = indev_drv.assume_init(); - indev_drv.type_ = lvgl_sys::LV_INDEV_TYPE_POINTER as lvgl_sys::lv_indev_type_t; + let mut indev_drv = Box::new(indev_drv.assume_init()); + indev_drv.type_ = lvgl_sys::lv_indev_type_t_LV_INDEV_TYPE_POINTER; indev_drv.read_cb = Some(read_input::); - indev_drv.user_data = - Box::into_raw(Box::new(handler)) as *mut _ as lvgl_sys::lv_indev_drv_user_data_t; + indev_drv.feedback_cb = Some(feedback); + indev_drv.user_data = Box::into_raw(Box::new(handler)) as *mut _; indev_drv }; Self { @@ -48,13 +48,13 @@ impl InputDriver for Pointer { } } - fn get_driver(&self) -> lvgl_sys::lv_indev_drv_t { - self.driver + fn get_driver(&mut self) -> &mut lvgl_sys::lv_indev_drv_t { + self.driver.as_mut() } unsafe fn set_descriptor(&mut self, descriptor: *mut lvgl_sys::lv_indev_t) -> LvResult<()> { - if descriptor.is_null() || self.descriptor.is_none() { - self.descriptor = Some(*descriptor); + if self.descriptor.is_none() { + self.descriptor = Some(descriptor); } else { return Err(LvError::AlreadyInUse); } @@ -65,54 +65,69 @@ impl InputDriver for Pointer { unsafe extern "C" fn read_input( indev_drv: *mut lvgl_sys::lv_indev_drv_t, data: *mut lvgl_sys::lv_indev_data_t, -) -> bool -where +) where F: Fn() -> BufferStatus, { // convert user data to function let user_closure = &mut *((*indev_drv).user_data as *mut F); // call user data let info: BufferStatus = user_closure(); - match info { - BufferStatus::Once(InputState::Pressed(Data::Pointer(PointerInputData::Touch(point)))) => { - (*data).point.x = point.x as lvgl_sys::lv_coord_t; - (*data).point.y = point.y as lvgl_sys::lv_coord_t; - (*data).state = lvgl_sys::LV_INDEV_STATE_PR as lvgl_sys::lv_indev_state_t; - false - } - BufferStatus::Once(InputState::Released(Data::Pointer(PointerInputData::Touch(point)))) => { - (*data).point.x = point.x as lvgl_sys::lv_coord_t; - (*data).point.y = point.y as lvgl_sys::lv_coord_t; - (*data).state = lvgl_sys::LV_INDEV_STATE_REL as lvgl_sys::lv_indev_state_t; - false - } - BufferStatus::Buffered(InputState::Pressed(Data::Pointer(PointerInputData::Touch( - point, - )))) => { - (*data).point.x = point.x as lvgl_sys::lv_coord_t; - (*data).point.y = point.y as lvgl_sys::lv_coord_t; - (*data).state = lvgl_sys::LV_INDEV_STATE_PR as lvgl_sys::lv_indev_state_t; - true - } - BufferStatus::Buffered(InputState::Released(Data::Pointer(PointerInputData::Touch( - point, - )))) => { - (*data).point.x = point.x as lvgl_sys::lv_coord_t; - (*data).point.y = point.y as lvgl_sys::lv_coord_t; - (*data).state = lvgl_sys::LV_INDEV_STATE_REL as lvgl_sys::lv_indev_state_t; - true - } - BufferStatus::Once(InputState::Released(Data::Pointer(PointerInputData::Key(_)))) => false, - BufferStatus::Once(InputState::Pressed(Data::Pointer(PointerInputData::Key(_)))) => false, - BufferStatus::Buffered(InputState::Released(Data::Pointer(PointerInputData::Key(_)))) => { - true - } - BufferStatus::Buffered(InputState::Pressed(Data::Pointer(PointerInputData::Key(_)))) => { - true + unsafe { + (*data).continue_reading = match info { + BufferStatus::Once(InputState::Pressed(Data::Pointer(PointerInputData::Touch( + point, + )))) => { + (*data).point.x = point.x as lvgl_sys::lv_coord_t; + (*data).point.y = point.y as lvgl_sys::lv_coord_t; + (*data).state = + lvgl_sys::lv_indev_state_t_LV_INDEV_STATE_PRESSED as lvgl_sys::lv_indev_state_t; + false + } + BufferStatus::Once(InputState::Released(Data::Pointer(PointerInputData::Touch( + point, + )))) => { + (*data).point.x = point.x as lvgl_sys::lv_coord_t; + (*data).point.y = point.y as lvgl_sys::lv_coord_t; + (*data).state = lvgl_sys::lv_indev_state_t_LV_INDEV_STATE_RELEASED + as lvgl_sys::lv_indev_state_t; + false + } + BufferStatus::Buffered(InputState::Pressed(Data::Pointer( + PointerInputData::Touch(point), + ))) => { + (*data).point.x = point.x as lvgl_sys::lv_coord_t; + (*data).point.y = point.y as lvgl_sys::lv_coord_t; + (*data).state = + lvgl_sys::lv_indev_state_t_LV_INDEV_STATE_PRESSED as lvgl_sys::lv_indev_state_t; + true + } + BufferStatus::Buffered(InputState::Released(Data::Pointer( + PointerInputData::Touch(point), + ))) => { + (*data).point.x = point.x as lvgl_sys::lv_coord_t; + (*data).point.y = point.y as lvgl_sys::lv_coord_t; + (*data).state = lvgl_sys::lv_indev_state_t_LV_INDEV_STATE_RELEASED + as lvgl_sys::lv_indev_state_t; + true + } + BufferStatus::Once(InputState::Released(Data::Pointer(PointerInputData::Key(_)))) => { + false + } + BufferStatus::Once(InputState::Pressed(Data::Pointer(PointerInputData::Key(_)))) => { + false + } + BufferStatus::Buffered(InputState::Released(Data::Pointer(PointerInputData::Key( + _, + )))) => true, + BufferStatus::Buffered(InputState::Pressed(Data::Pointer(PointerInputData::Key( + _, + )))) => true, } } } +unsafe extern "C" fn feedback(_indev_drv: *mut lvgl_sys::lv_indev_drv_t, _code: u8) {} + #[cfg(test)] mod test { //use super::*; @@ -151,7 +166,7 @@ mod test { C: PixelColor, { fn size(&self) -> Size { - Size::new(crate::VER_RES_MAX, crate::HOR_RES_MAX) + Size::new(240, 240) } } diff --git a/lvgl/src/lib.rs b/lvgl/src/lib.rs index 41b804c2..c712edfc 100644 --- a/lvgl/src/lib.rs +++ b/lvgl/src/lib.rs @@ -58,11 +58,6 @@ mod support; pub mod input_device; pub mod widgets; -/// Maximum horizontal display resolution, as defined in `lv_conf.h`. -pub const HOR_RES_MAX: u32 = lvgl_sys::LV_HOR_RES_MAX; -/// Maximum vertical display resolution, as defined in `lv_conf.h`. -pub const VER_RES_MAX: u32 = lvgl_sys::LV_VER_RES_MAX; - struct RunOnce(AtomicBool); impl RunOnce { @@ -101,7 +96,7 @@ pub(crate) mod tests { let buffer = DrawBuffer::::new(); if ONCE_INIT.swap_and_check() { - let _ = Display::register(&buffer, |_| {}).unwrap(); + let _ = Display::register(buffer, 240, 240, |_| {}).unwrap(); } } } diff --git a/lvgl/src/lv_core/obj.rs b/lvgl/src/lv_core/obj.rs index d1adcbf7..3f2fe6dc 100644 --- a/lvgl/src/lv_core/obj.rs +++ b/lvgl/src/lv_core/obj.rs @@ -30,18 +30,18 @@ impl NativeObject for Obj { /// A wrapper for all LVGL common operations on generic objects. pub trait Widget: NativeObject { type SpecialEvent; - type Part: Into; + type Part: Into; /// Construct an instance of the object from a raw pointer. fn from_raw(raw_pointer: ptr::NonNull) -> Self; /// Adds a `Style` to a given widget. - fn add_style(&self, part: Self::Part, style: &mut Style) -> LvResult<()> { + fn add_style(&mut self, part: Self::Part, style: &mut Style) -> LvResult<()> { unsafe { lvgl_sys::lv_obj_add_style( self.raw()?.as_mut(), - part.into(), style.raw.as_mut() as *mut _, + part.into(), ); }; Ok(()) @@ -88,14 +88,10 @@ pub trait Widget: NativeObject { } /// Sets a widget's align relative to its parent along with an offset. - fn set_align(&mut self, base: &mut C, align: Align, x_mod: i32, y_mod: i32) -> LvResult<()> - where - C: NativeObject, - { + fn set_align(&mut self, align: Align, x_mod: i32, y_mod: i32) -> LvResult<()> { unsafe { lvgl_sys::lv_obj_align( self.raw()?.as_mut(), - base.raw()?.as_mut(), align.into(), x_mod as lvgl_sys::lv_coord_t, y_mod as lvgl_sys::lv_coord_t, @@ -106,7 +102,7 @@ pub trait Widget: NativeObject { } impl Widget for Obj { - type SpecialEvent = (); + type SpecialEvent = u32; type Part = Part; fn from_raw(raw: ptr::NonNull) -> Self { @@ -117,7 +113,7 @@ impl Widget for Obj { impl Default for Obj { fn default() -> Self { Self { - raw: unsafe { lvgl_sys::lv_obj_create(ptr::null_mut(), ptr::null_mut()) }, + raw: unsafe { lvgl_sys::lv_obj_create(ptr::null_mut()) }, } } } @@ -153,9 +149,11 @@ macro_rules! define_object { let obj = raw.as_mut(); let user_closure = $crate::Box::new(f); obj.user_data = $crate::Box::into_raw(user_closure) as *mut cty::c_void; - lvgl_sys::lv_obj_set_event_cb( + lvgl_sys::lv_obj_add_event_cb( obj, lvgl_sys::lv_event_cb_t::Some($crate::support::event_callback::), + lvgl_sys::lv_event_code_t_LV_EVENT_ALL, + obj.user_data, ); } Ok(()) @@ -213,41 +211,38 @@ macro_rules! define_object { // } // } -bitflags! { - pub struct State: u32 { - /// Normal, released - const DEFAULT = lvgl_sys::LV_STATE_DEFAULT as u32; - /// Toggled or checked - const CHECKED = lvgl_sys::LV_STATE_CHECKED as u32; - /// Focused via keypad or encoder or clicked via touchpad/mouse - const FOCUSED = lvgl_sys::LV_STATE_FOCUSED as u32; - /// Edit by an encoder - const EDITED = lvgl_sys::LV_STATE_EDITED as u32; - /// Hovered by mouse (not supported now) - const HOVERED = lvgl_sys::LV_STATE_HOVERED as u32; - /// Pressed - const PRESSED = lvgl_sys::LV_STATE_PRESSED as u32; - /// Disabled or inactive - const DISABLED = lvgl_sys::LV_STATE_DISABLED as u32; - } +pub enum Part { + Main, + Scrollbar, + Indicator, + Knob, + Selected, + Items, + Ticks, + Cursor, + CustomFirst, + Any, } -impl State { - pub(crate) fn get_bits(&self) -> u32 { - self.bits +impl Default for Part { + fn default() -> Self { + Self::Main } } -pub enum Part { - Main, - All, -} - -impl From for u8 { - fn from(self_: Part) -> u8 { +impl From for lvgl_sys::lv_part_t { + fn from(self_: Part) -> lvgl_sys::lv_part_t { match self_ { - Part::Main => lvgl_sys::LV_OBJ_PART_MAIN as u8, - Part::All => lvgl_sys::LV_OBJ_PART_ALL as u8, + Part::Main => lvgl_sys::LV_PART_MAIN, + Part::Scrollbar => lvgl_sys::LV_PART_SCROLLBAR, + Part::Indicator => lvgl_sys::LV_PART_INDICATOR, + Part::Knob => lvgl_sys::LV_PART_KNOB, + Part::Selected => lvgl_sys::LV_PART_SELECTED, + Part::Items => lvgl_sys::LV_PART_ITEMS, + Part::Ticks => lvgl_sys::LV_PART_TICKS, + Part::Cursor => lvgl_sys::LV_PART_CURSOR, + Part::CustomFirst => lvgl_sys::LV_PART_CUSTOM_FIRST, + Part::Any => lvgl_sys::LV_PART_ANY, } } } diff --git a/lvgl/src/lv_core/style.rs b/lvgl/src/lv_core/style.rs index 579f794c..35b022c0 100644 --- a/lvgl/src/lv_core/style.rs +++ b/lvgl/src/lv_core/style.rs @@ -1,7 +1,7 @@ -use crate::Box; -use crate::{Color, LvResult, State}; +use crate::{Box, Color, TextAlign}; use core::mem; -use cstr_core::CStr; +use cty::c_uint; +use paste::paste; pub enum Themes { Pretty, @@ -12,21 +12,6 @@ pub struct Style { pub(crate) raw: Box, } -impl Style { - pub fn set_value_str(&mut self, state: State, value: &CStr) -> LvResult<()> { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_ptr( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_VALUE_STR as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value.as_ptr() as *mut cty::c_void, - ); - } - Ok(()) - } -} - impl Default for Style { fn default() -> Self { let raw = unsafe { @@ -64,1144 +49,237 @@ impl From for u8 { bitflags! { pub struct StyleProp: u32 { - const RADIUS = lvgl_sys::LV_STYLE_RADIUS as u32; - const CLIP_CORNER = lvgl_sys::LV_STYLE_CLIP_CORNER as u32; - const SIZE = lvgl_sys::LV_STYLE_SIZE as u32; - const TRANSFORM_WIDTH = lvgl_sys::LV_STYLE_TRANSFORM_WIDTH as u32; - const TRANSFORM_HEIGHT = lvgl_sys::LV_STYLE_TRANSFORM_HEIGHT as u32; - const TRANSFORM_ANGLE = lvgl_sys::LV_STYLE_TRANSFORM_ANGLE as u32; - const TRANSFORM_ZOOM = lvgl_sys::LV_STYLE_TRANSFORM_ZOOM as u32; - const OPA_SCALE = lvgl_sys::LV_STYLE_OPA_SCALE as u32; - const PAD_TOP = lvgl_sys::LV_STYLE_PAD_TOP as u32; - const PAD_BOTTOM = lvgl_sys::LV_STYLE_PAD_BOTTOM as u32; - const PAD_LEFT = lvgl_sys::LV_STYLE_PAD_LEFT as u32; - const PAD_RIGHT = lvgl_sys::LV_STYLE_PAD_RIGHT as u32; - const PAD_INNER = lvgl_sys::LV_STYLE_PAD_INNER as u32; - const MARGIN_TOP = lvgl_sys::LV_STYLE_MARGIN_TOP as u32; - const MARGIN_BOTTOM = lvgl_sys::LV_STYLE_MARGIN_BOTTOM as u32; - const MARGIN_LEFT = lvgl_sys::LV_STYLE_MARGIN_LEFT as u32; - const MARGIN_RIGHT = lvgl_sys::LV_STYLE_MARGIN_RIGHT as u32; - const BG_BLEND_MODE = lvgl_sys::LV_STYLE_BG_BLEND_MODE as u32; - const BG_MAIN_STOP = lvgl_sys::LV_STYLE_BG_MAIN_STOP as u32; - const BG_GRAD_STOP = lvgl_sys::LV_STYLE_BG_GRAD_STOP as u32; - const BG_GRAD_DIR = lvgl_sys::LV_STYLE_BG_GRAD_DIR as u32; - const BG_COLOR = lvgl_sys::LV_STYLE_BG_COLOR as u32; - const BG_GRAD_COLOR = lvgl_sys::LV_STYLE_BG_GRAD_COLOR as u32; - const BG_OPA = lvgl_sys::LV_STYLE_BG_OPA as u32; - const BORDER_WIDTH = lvgl_sys::LV_STYLE_BORDER_WIDTH as u32; - const BORDER_SIDE = lvgl_sys::LV_STYLE_BORDER_SIDE as u32; - const BORDER_BLEND_MODE = lvgl_sys::LV_STYLE_BORDER_BLEND_MODE as u32; - const BORDER_POST = lvgl_sys::LV_STYLE_BORDER_POST as u32; - const BORDER_COLOR = lvgl_sys::LV_STYLE_BORDER_COLOR as u32; - const BORDER_OPA = lvgl_sys::LV_STYLE_BORDER_OPA as u32; - const OUTLINE_WIDTH = lvgl_sys::LV_STYLE_OUTLINE_WIDTH as u32; - const OUTLINE_PAD = lvgl_sys::LV_STYLE_OUTLINE_PAD as u32; - const OUTLINE_BLEND_MODE = lvgl_sys::LV_STYLE_OUTLINE_BLEND_MODE as u32; - const OUTLINE_COLOR = lvgl_sys::LV_STYLE_OUTLINE_COLOR as u32; - const OUTLINE_OPA = lvgl_sys::LV_STYLE_OUTLINE_OPA as u32; - const SHADOW_WIDTH = lvgl_sys::LV_STYLE_SHADOW_WIDTH as u32; - const SHADOW_OFS_X = lvgl_sys::LV_STYLE_SHADOW_OFS_X as u32; - const SHADOW_OFS_Y = lvgl_sys::LV_STYLE_SHADOW_OFS_Y as u32; - const SHADOW_SPREAD = lvgl_sys::LV_STYLE_SHADOW_SPREAD as u32; - const SHADOW_BLEND_MODE = lvgl_sys::LV_STYLE_SHADOW_BLEND_MODE as u32; - const SHADOW_COLOR = lvgl_sys::LV_STYLE_SHADOW_COLOR as u32; - const SHADOW_OPA = lvgl_sys::LV_STYLE_SHADOW_OPA as u32; - const PATTERN_BLEND_MODE = lvgl_sys::LV_STYLE_PATTERN_BLEND_MODE as u32; - const PATTERN_REPEAT = lvgl_sys::LV_STYLE_PATTERN_REPEAT as u32; - const PATTERN_RECOLOR = lvgl_sys::LV_STYLE_PATTERN_RECOLOR as u32; - const PATTERN_OPA = lvgl_sys::LV_STYLE_PATTERN_OPA as u32; - const PATTERN_RECOLOR_OPA = lvgl_sys::LV_STYLE_PATTERN_RECOLOR_OPA as u32; - const PATTERN_IMAGE = lvgl_sys::LV_STYLE_PATTERN_IMAGE as u32; - const VALUE_LETTER_SPACE = lvgl_sys::LV_STYLE_VALUE_LETTER_SPACE as u32; - const VALUE_LINE_SPACE = lvgl_sys::LV_STYLE_VALUE_LINE_SPACE as u32; - const VALUE_BLEND_MODE = lvgl_sys::LV_STYLE_VALUE_BLEND_MODE as u32; - const VALUE_OFS_X = lvgl_sys::LV_STYLE_VALUE_OFS_X as u32; - const VALUE_OFS_Y = lvgl_sys::LV_STYLE_VALUE_OFS_Y as u32; - const VALUE_ALIGN = lvgl_sys::LV_STYLE_VALUE_ALIGN as u32; - const VALUE_COLOR = lvgl_sys::LV_STYLE_VALUE_COLOR as u32; - const VALUE_OPA = lvgl_sys::LV_STYLE_VALUE_OPA as u32; - const VALUE_FONT = lvgl_sys::LV_STYLE_VALUE_FONT as u32; - const VALUE_STR = lvgl_sys::LV_STYLE_VALUE_STR as u32; - const TEXT_LETTER_SPACE = lvgl_sys::LV_STYLE_TEXT_LETTER_SPACE as u32; - const TEXT_LINE_SPACE = lvgl_sys::LV_STYLE_TEXT_LINE_SPACE as u32; - const TEXT_DECOR = lvgl_sys::LV_STYLE_TEXT_DECOR as u32; - const TEXT_BLEND_MODE = lvgl_sys::LV_STYLE_TEXT_BLEND_MODE as u32; - const TEXT_COLOR = lvgl_sys::LV_STYLE_TEXT_COLOR as u32; - const TEXT_SEL_COLOR = lvgl_sys::LV_STYLE_TEXT_SEL_COLOR as u32; - const TEXT_OPA = lvgl_sys::LV_STYLE_TEXT_OPA as u32; - const TEXT_FONT = lvgl_sys::LV_STYLE_TEXT_FONT as u32; - const LINE_WIDTH = lvgl_sys::LV_STYLE_LINE_WIDTH as u32; - const LINE_BLEND_MODE = lvgl_sys::LV_STYLE_LINE_BLEND_MODE as u32; - const LINE_DASH_WIDTH = lvgl_sys::LV_STYLE_LINE_DASH_WIDTH as u32; - const LINE_DASH_GAP = lvgl_sys::LV_STYLE_LINE_DASH_GAP as u32; - const LINE_ROUNDED = lvgl_sys::LV_STYLE_LINE_ROUNDED as u32; - const LINE_COLOR = lvgl_sys::LV_STYLE_LINE_COLOR as u32; - const LINE_OPA = lvgl_sys::LV_STYLE_LINE_OPA as u32; - const IMAGE_BLEND_MODE = lvgl_sys::LV_STYLE_IMAGE_BLEND_MODE as u32; - const IMAGE_RECOLOR = lvgl_sys::LV_STYLE_IMAGE_RECOLOR as u32; - const IMAGE_OPA = lvgl_sys::LV_STYLE_IMAGE_OPA as u32; - const IMAGE_RECOLOR_OPA = lvgl_sys::LV_STYLE_IMAGE_RECOLOR_OPA as u32; - const TRANSITION_TIME = lvgl_sys::LV_STYLE_TRANSITION_TIME as u32; - const TRANSITION_DELAY = lvgl_sys::LV_STYLE_TRANSITION_DELAY as u32; - const TRANSITION_PROP_1 = lvgl_sys::LV_STYLE_TRANSITION_PROP_1 as u32; - const TRANSITION_PROP_2 = lvgl_sys::LV_STYLE_TRANSITION_PROP_2 as u32; - const TRANSITION_PROP_3 = lvgl_sys::LV_STYLE_TRANSITION_PROP_3 as u32; - const TRANSITION_PROP_4 = lvgl_sys::LV_STYLE_TRANSITION_PROP_4 as u32; - const TRANSITION_PROP_5 = lvgl_sys::LV_STYLE_TRANSITION_PROP_5 as u32; - const TRANSITION_PROP_6 = lvgl_sys::LV_STYLE_TRANSITION_PROP_6 as u32; - const TRANSITION_PATH = lvgl_sys::LV_STYLE_TRANSITION_PATH as u32; - const SCALE_WIDTH = lvgl_sys::LV_STYLE_SCALE_WIDTH as u32; - const SCALE_BORDER_WIDTH = lvgl_sys::LV_STYLE_SCALE_BORDER_WIDTH as u32; - const SCALE_END_BORDER_WIDTH = lvgl_sys::LV_STYLE_SCALE_END_BORDER_WIDTH as u32; - const SCALE_END_LINE_WIDTH = lvgl_sys::LV_STYLE_SCALE_END_LINE_WIDTH as u32; - const SCALE_GRAD_COLOR = lvgl_sys::LV_STYLE_SCALE_GRAD_COLOR as u32; - const SCALE_END_COLOR = lvgl_sys::LV_STYLE_SCALE_END_COLOR as u32; + const PROP_INV = lvgl_sys::lv_style_prop_t_LV_STYLE_PROP_INV as u32; + + /*Group 0*/ + const WIDTH = lvgl_sys::lv_style_prop_t_LV_STYLE_WIDTH as u32; + const MIN_WIDTH = lvgl_sys::lv_style_prop_t_LV_STYLE_MIN_WIDTH as u32; + const MAX_WIDTH = lvgl_sys::lv_style_prop_t_LV_STYLE_MAX_WIDTH as u32; + const HEIGHT = lvgl_sys::lv_style_prop_t_LV_STYLE_HEIGHT as u32; + const MIN_HEIGHT = lvgl_sys::lv_style_prop_t_LV_STYLE_MIN_HEIGHT as u32; + const MAX_HEIGHT = lvgl_sys::lv_style_prop_t_LV_STYLE_MAX_HEIGHT as u32; + const X = lvgl_sys::lv_style_prop_t_LV_STYLE_X as u32; + const Y = lvgl_sys::lv_style_prop_t_LV_STYLE_Y as u32; + const ALIGN = lvgl_sys::lv_style_prop_t_LV_STYLE_ALIGN as u32; + const TRANSFORM_WIDTH = lvgl_sys::lv_style_prop_t_LV_STYLE_TRANSFORM_WIDTH as u32; + const TRANSFORM_HEIGHT = lvgl_sys::lv_style_prop_t_LV_STYLE_TRANSFORM_HEIGHT as u32; + const TRANSLATE_X = lvgl_sys::lv_style_prop_t_LV_STYLE_TRANSLATE_X as u32; + const TRANSLATE_Y = lvgl_sys::lv_style_prop_t_LV_STYLE_TRANSLATE_Y as u32; + const TRANSFORM_ZOOM = lvgl_sys::lv_style_prop_t_LV_STYLE_TRANSFORM_ZOOM as u32; + const TRANSFORM_ANGLE = lvgl_sys::lv_style_prop_t_LV_STYLE_TRANSFORM_ANGLE as u32; + + /*Group 1*/ + const PAD_TOP = lvgl_sys::lv_style_prop_t_LV_STYLE_PAD_TOP as u32; + const PAD_BOTTOM = lvgl_sys::lv_style_prop_t_LV_STYLE_PAD_BOTTOM as u32; + const PAD_LEFT = lvgl_sys::lv_style_prop_t_LV_STYLE_PAD_LEFT as u32; + const PAD_RIGHT = lvgl_sys::lv_style_prop_t_LV_STYLE_PAD_RIGHT as u32; + const PAD_ROW = lvgl_sys::lv_style_prop_t_LV_STYLE_PAD_ROW as u32; + const PAD_COLUMN = lvgl_sys::lv_style_prop_t_LV_STYLE_PAD_COLUMN as u32; + + /*Group 2*/ + const BG_COLOR = lvgl_sys::lv_style_prop_t_LV_STYLE_BG_COLOR as u32; + //const BG_COLOR_FILTERED = lvgl_sys::lv_style_prop_t_LV_STYLE_BG_COLOR_FILTERED as u32; + const BG_OPA = lvgl_sys::lv_style_prop_t_LV_STYLE_BG_OPA as u32; + const BG_GRAD_COLOR = lvgl_sys::lv_style_prop_t_LV_STYLE_BG_GRAD_COLOR as u32; + //const BG_GRAD_COLOR_FILTERED = lvgl_sys::lv_style_prop_t_LV_STYLE_BG_GRAD_COLOR_FILTERED as u32; + const BG_GRAD_DIR = lvgl_sys::lv_style_prop_t_LV_STYLE_BG_GRAD_DIR as u32; + const BG_MAIN_STOP = lvgl_sys::lv_style_prop_t_LV_STYLE_BG_MAIN_STOP as u32; + const BG_GRAD_STOP = lvgl_sys::lv_style_prop_t_LV_STYLE_BG_GRAD_STOP as u32; + + const BG_IMG_SRC = lvgl_sys::lv_style_prop_t_LV_STYLE_BG_IMG_SRC as u32; + const BG_IMG_OPA = lvgl_sys::lv_style_prop_t_LV_STYLE_BG_IMG_OPA as u32; + const BG_IMG_RECOLOR = lvgl_sys::lv_style_prop_t_LV_STYLE_BG_IMG_RECOLOR as u32; + //const BG_IMG_RECOLOR_FILTERED = lvgl_sys::lv_style_prop_t_LV_STYLE_BG_IMG_RECOLOR_FILTERED as u32; + const BG_IMG_RECOLOR_OPA = lvgl_sys::lv_style_prop_t_LV_STYLE_BG_IMG_RECOLOR_OPA as u32; + const BG_IMG_TILED = lvgl_sys::lv_style_prop_t_LV_STYLE_BG_IMG_TILED as u32; + + /*Group 3*/ + const BORDER_COLOR = lvgl_sys::lv_style_prop_t_LV_STYLE_BORDER_COLOR as u32; + //const BORDER_COLOR_FILTERED = lvgl_sys::lv_style_prop_t_LV_STYLE_BORDER_COLOR_FILTERED as u32; + const BORDER_OPA = lvgl_sys::lv_style_prop_t_LV_STYLE_BORDER_OPA as u32; + const BORDER_WIDTH = lvgl_sys::lv_style_prop_t_LV_STYLE_BORDER_WIDTH as u32; + const BORDER_SIDE = lvgl_sys::lv_style_prop_t_LV_STYLE_BORDER_SIDE as u32; + const BORDER_POST = lvgl_sys::lv_style_prop_t_LV_STYLE_BORDER_POST as u32; + + const OUTLINE_WIDTH = lvgl_sys::lv_style_prop_t_LV_STYLE_OUTLINE_WIDTH as u32; + const OUTLINE_COLOR = lvgl_sys::lv_style_prop_t_LV_STYLE_OUTLINE_COLOR as u32; + //const OUTLINE_COLOR_FILTERED = lvgl_sys::lv_style_prop_t_LV_STYLE_OUTLINE_COLOR_FILTERED as u32; + const OUTLINE_OPA = lvgl_sys::lv_style_prop_t_LV_STYLE_OUTLINE_OPA as u32; + const OUTLINE_PAD = lvgl_sys::lv_style_prop_t_LV_STYLE_OUTLINE_PAD as u32; + + /*Group 4*/ + const SHADOW_WIDTH = lvgl_sys::lv_style_prop_t_LV_STYLE_SHADOW_WIDTH as u32; + const SHADOW_OFS_X = lvgl_sys::lv_style_prop_t_LV_STYLE_SHADOW_OFS_X as u32; + const SHADOW_OFS_Y = lvgl_sys::lv_style_prop_t_LV_STYLE_SHADOW_OFS_Y as u32; + const SHADOW_SPREAD = lvgl_sys::lv_style_prop_t_LV_STYLE_SHADOW_SPREAD as u32; + const SHADOW_COLOR = lvgl_sys::lv_style_prop_t_LV_STYLE_SHADOW_COLOR as u32; + //const SHADOW_COLOR_FILTERED = lvgl_sys::lv_style_prop_t_LV_STYLE_SHADOW_COLOR_FILTERED as u32; + const SHADOW_OPA = lvgl_sys::lv_style_prop_t_LV_STYLE_SHADOW_OPA as u32; + + const IMG_OPA = lvgl_sys::lv_style_prop_t_LV_STYLE_IMG_OPA as u32; + const IMG_RECOLOR = lvgl_sys::lv_style_prop_t_LV_STYLE_IMG_RECOLOR as u32; + //const IMG_RECOLOR_FILTERED = lvgl_sys::lv_style_prop_t_LV_STYLE_IMG_RECOLOR_FILTERED as u32; + const IMG_RECOLOR_OPA = lvgl_sys::lv_style_prop_t_LV_STYLE_IMG_RECOLOR_OPA as u32; + + const LINE_WIDTH = lvgl_sys::lv_style_prop_t_LV_STYLE_LINE_WIDTH as u32; + const LINE_DASH_WIDTH = lvgl_sys::lv_style_prop_t_LV_STYLE_LINE_DASH_WIDTH as u32; + const LINE_DASH_GAP = lvgl_sys::lv_style_prop_t_LV_STYLE_LINE_DASH_GAP as u32; + const LINE_ROUNDED = lvgl_sys::lv_style_prop_t_LV_STYLE_LINE_ROUNDED as u32; + const LINE_COLOR = lvgl_sys::lv_style_prop_t_LV_STYLE_LINE_COLOR as u32; + //const LINE_COLOR_FILTERED = lvgl_sys::lv_style_prop_t_LV_STYLE_LINE_COLOR_FILTERED as u32; + const LINE_OPA = lvgl_sys::lv_style_prop_t_LV_STYLE_LINE_OPA as u32; + + /*Group 5*/ + const ARC_WIDTH = lvgl_sys::lv_style_prop_t_LV_STYLE_ARC_WIDTH as u32; + const ARC_ROUNDED = lvgl_sys::lv_style_prop_t_LV_STYLE_ARC_ROUNDED as u32; + const ARC_COLOR = lvgl_sys::lv_style_prop_t_LV_STYLE_ARC_COLOR as u32; + //const ARC_COLOR_FILTERED = lvgl_sys::lv_style_prop_t_LV_STYLE_ARC_COLOR_FILTERED as u32; + const ARC_OPA = lvgl_sys::lv_style_prop_t_LV_STYLE_ARC_OPA as u32; + const ARC_IMG_SRC = lvgl_sys::lv_style_prop_t_LV_STYLE_ARC_IMG_SRC as u32; + + const TEXT_COLOR = lvgl_sys::lv_style_prop_t_LV_STYLE_TEXT_COLOR as u32; + //const TEXT_COLOR_FILTERED = lvgl_sys::lv_style_prop_t_LV_STYLE_TEXT_COLOR_FILTERED as u32; + const TEXT_OPA = lvgl_sys::lv_style_prop_t_LV_STYLE_TEXT_OPA as u32; + const TEXT_FONT = lvgl_sys::lv_style_prop_t_LV_STYLE_TEXT_FONT as u32; + const TEXT_LETTER_SPACE = lvgl_sys::lv_style_prop_t_LV_STYLE_TEXT_LETTER_SPACE as u32; + const TEXT_LINE_SPACE = lvgl_sys::lv_style_prop_t_LV_STYLE_TEXT_LINE_SPACE as u32; + const TEXT_DECOR = lvgl_sys::lv_style_prop_t_LV_STYLE_TEXT_DECOR as u32; + const TEXT_ALIGN = lvgl_sys::lv_style_prop_t_LV_STYLE_TEXT_ALIGN as u32; + + /*Group 6*/ + const RADIUS = lvgl_sys::lv_style_prop_t_LV_STYLE_RADIUS as u32; + const CLIP_CORNER = lvgl_sys::lv_style_prop_t_LV_STYLE_CLIP_CORNER as u32; + const OPA = lvgl_sys::lv_style_prop_t_LV_STYLE_OPA as u32; + const COLOR_FILTER_DSC = lvgl_sys::lv_style_prop_t_LV_STYLE_COLOR_FILTER_DSC as u32; + const COLOR_FILTER_OPA = lvgl_sys::lv_style_prop_t_LV_STYLE_COLOR_FILTER_OPA as u32; + const ANIM_TIME = lvgl_sys::lv_style_prop_t_LV_STYLE_ANIM_TIME as u32; + const ANIM_SPEED = lvgl_sys::lv_style_prop_t_LV_STYLE_ANIM_SPEED as u32; + const TRANSITION = lvgl_sys::lv_style_prop_t_LV_STYLE_TRANSITION as u32; + const BLEND_MODE = lvgl_sys::lv_style_prop_t_LV_STYLE_BLEND_MODE as u32; + const LAYOUT = lvgl_sys::lv_style_prop_t_LV_STYLE_LAYOUT as u32; + const BASE_DIR = lvgl_sys::lv_style_prop_t_LV_STYLE_BASE_DIR as u32; + + const PROP_ANY = lvgl_sys::lv_style_prop_t_LV_STYLE_PROP_ANY as u32; } } -// Auto-gen code, please look into lvgl-codegen for any changes. -impl Style { - pub fn set_radius(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_RADIUS as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_clip_corner(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_CLIP_CORNER as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_size(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_SIZE as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_transform_width(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_TRANSFORM_WIDTH as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_transform_height(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_TRANSFORM_HEIGHT as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_transform_angle(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_TRANSFORM_ANGLE as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_transform_zoom(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_TRANSFORM_ZOOM as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_opa_scale(&mut self, state: State, value: Opacity) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_opa( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_OPA_SCALE as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value.into(), - ); - } - } - - pub fn set_pad_top(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_PAD_TOP as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_pad_bottom(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_PAD_BOTTOM as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_pad_left(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_PAD_LEFT as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_pad_right(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_PAD_RIGHT as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_pad_inner(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_PAD_INNER as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_margin_top(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_MARGIN_TOP as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_margin_bottom(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_MARGIN_BOTTOM as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_margin_left(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_MARGIN_LEFT as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_margin_right(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_MARGIN_RIGHT as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_bg_blend_mode(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_BG_BLEND_MODE as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_bg_main_stop(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_BG_MAIN_STOP as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_bg_grad_stop(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_BG_GRAD_STOP as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_bg_grad_dir(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_BG_GRAD_DIR as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_bg_color(&mut self, state: State, value: Color) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_color( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_BG_COLOR as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value.raw, - ); - } - } - - pub fn set_bg_grad_color(&mut self, state: State, value: Color) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_color( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_BG_GRAD_COLOR as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value.raw, - ); - } - } - - pub fn set_bg_opa(&mut self, state: State, value: Opacity) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_opa( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_BG_OPA as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value.into(), - ); - } - } - - pub fn set_border_width(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_BORDER_WIDTH as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_border_side(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_BORDER_SIDE as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_border_blend_mode(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_BORDER_BLEND_MODE as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_border_post(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_BORDER_POST as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_border_color(&mut self, state: State, value: Color) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_color( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_BORDER_COLOR as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value.raw, - ); - } - } - - pub fn set_border_opa(&mut self, state: State, value: Opacity) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_opa( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_BORDER_OPA as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value.into(), - ); - } - } - - pub fn set_outline_width(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_OUTLINE_WIDTH as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_outline_pad(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_OUTLINE_PAD as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_outline_blend_mode(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_OUTLINE_BLEND_MODE as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_outline_color(&mut self, state: State, value: Color) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_color( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_OUTLINE_COLOR as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value.raw, - ); - } - } - - pub fn set_outline_opa(&mut self, state: State, value: Opacity) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_opa( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_OUTLINE_OPA as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value.into(), - ); - } - } - - pub fn set_shadow_width(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_SHADOW_WIDTH as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_shadow_ofs_x(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_SHADOW_OFS_X as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_shadow_ofs_y(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_SHADOW_OFS_Y as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_shadow_spread(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_SHADOW_SPREAD as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_shadow_blend_mode(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_SHADOW_BLEND_MODE as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_shadow_color(&mut self, state: State, value: Color) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_color( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_SHADOW_COLOR as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value.raw, - ); - } - } - - pub fn set_shadow_opa(&mut self, state: State, value: Opacity) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_opa( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_SHADOW_OPA as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value.into(), - ); - } - } - - pub fn set_pattern_repeat(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_PATTERN_REPEAT as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_pattern_blend_mode(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_PATTERN_BLEND_MODE as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_pattern_recolor(&mut self, state: State, value: Color) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_color( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_PATTERN_RECOLOR as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value.raw, - ); - } - } - - pub fn set_pattern_opa(&mut self, state: State, value: Opacity) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_opa( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_PATTERN_OPA as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value.into(), - ); - } - } - - pub fn set_pattern_recolor_opa(&mut self, state: State, value: Opacity) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_opa( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_PATTERN_RECOLOR_OPA as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value.into(), - ); - } - } - - pub fn set_value_letter_space(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_VALUE_LETTER_SPACE as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_value_line_space(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_VALUE_LINE_SPACE as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_value_blend_mode(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_VALUE_BLEND_MODE as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_value_ofs_x(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_VALUE_OFS_X as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_value_ofs_y(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_VALUE_OFS_Y as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_value_align(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_VALUE_ALIGN as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_value_color(&mut self, state: State, value: Color) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_color( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_VALUE_COLOR as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value.raw, - ); - } - } - - pub fn set_value_opa(&mut self, state: State, value: Opacity) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_opa( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_VALUE_OPA as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value.into(), - ); - } - } - - pub fn set_text_letter_space(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_TEXT_LETTER_SPACE as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_text_line_space(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_TEXT_LINE_SPACE as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_text_decor(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_TEXT_DECOR as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_text_blend_mode(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_TEXT_BLEND_MODE as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_text_color(&mut self, state: State, value: Color) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_color( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_TEXT_COLOR as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value.raw, - ); - } - } - - pub fn set_text_sel_color(&mut self, state: State, value: Color) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_color( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_TEXT_SEL_COLOR as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value.raw, - ); - } - } - - pub fn set_text_opa(&mut self, state: State, value: Opacity) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_opa( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_TEXT_OPA as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value.into(), - ); - } - } - - pub fn set_line_width(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_LINE_WIDTH as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_line_blend_mode(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_LINE_BLEND_MODE as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_line_dash_width(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_LINE_DASH_WIDTH as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_line_dash_gap(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_LINE_DASH_GAP as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_line_rounded(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_LINE_ROUNDED as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_line_color(&mut self, state: State, value: Color) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_color( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_LINE_COLOR as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value.raw, - ); - } - } - - pub fn set_line_opa(&mut self, state: State, value: Opacity) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_opa( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_LINE_OPA as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value.into(), - ); - } - } - - pub fn set_image_blend_mode(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_IMAGE_BLEND_MODE as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_image_recolor(&mut self, state: State, value: Color) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_color( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_IMAGE_RECOLOR as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value.raw, - ); - } - } - - pub fn set_image_opa(&mut self, state: State, value: Opacity) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_opa( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_IMAGE_OPA as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value.into(), - ); - } - } - - pub fn set_image_recolor_opa(&mut self, state: State, value: Opacity) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_opa( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_IMAGE_RECOLOR_OPA as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value.into(), - ); - } - } - - pub fn set_transition_time(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_TRANSITION_TIME as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_transition_delay(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_TRANSITION_DELAY as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_transition_prop_1(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_TRANSITION_PROP_1 as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_transition_prop_2(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_TRANSITION_PROP_2 as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_transition_prop_3(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_TRANSITION_PROP_3 as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_transition_prop_4(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_TRANSITION_PROP_4 as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_transition_prop_5(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_TRANSITION_PROP_5 as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_transition_prop_6(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_TRANSITION_PROP_6 as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_scale_width(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_SCALE_WIDTH as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_scale_border_width(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_SCALE_BORDER_WIDTH as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_scale_end_border_width(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_SCALE_END_BORDER_WIDTH as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_scale_end_line_width(&mut self, state: State, value: i16) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_int( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_SCALE_END_LINE_WIDTH as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16, - value, - ); - } - } - - pub fn set_scale_grad_color(&mut self, state: State, value: Color) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_color( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_SCALE_GRAD_COLOR as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS)) as u16, - value.raw, - ); - } - } +macro_rules! gen_lv_style { + ($func_name:ident,$vty:ty) => { + paste! { + #[inline] + pub fn $func_name(&mut self, value: $vty) { + unsafe { + lvgl_sys::[]( + self.raw.as_mut(), + value.into(), + ); + } + } + } + }; +} - pub fn set_scale_end_color(&mut self, state: State, value: Color) { - let native_state: u32 = state.get_bits(); - unsafe { - lvgl_sys::_lv_style_set_color( - self.raw.as_mut(), - (lvgl_sys::LV_STYLE_SCALE_END_COLOR as u32 - | (native_state << lvgl_sys::LV_STYLE_STATE_POS)) as u16, - value.raw, - ); - } - } +// TODO: Move this into lvgl-codegen +impl Style { + gen_lv_style!(set_align, u8); + //gen_lv_style!(set_anim, ); + //gen_lv_style!(set_anim_speed, ); + //gen_lv_style!(set_anim_time, ); + gen_lv_style!(set_arc_color, Color); + //gen_lv_style!(set_arc_img_src, ); + gen_lv_style!(set_arc_opa, Opacity); + gen_lv_style!(set_arc_rounded, bool); + gen_lv_style!(set_arc_width, i16); + //gen_lv_style!(set_base_dir, ); + gen_lv_style!(set_bg_color, Color); + gen_lv_style!(set_bg_dither_mode, u8); + //gen_lv_style!(set_bg_grad, ); + gen_lv_style!(set_bg_grad_color, Color); + //gen_lv_style!(set_bg_grad_dir, ); + gen_lv_style!(set_bg_grad_stop, i16); + gen_lv_style!(set_bg_img_opa, Opacity); + gen_lv_style!(set_bg_img_recolor, Color); + gen_lv_style!(set_bg_img_recolor_opa, Opacity); + //gen_lv_style!(set_bg_img_src, ); + gen_lv_style!(set_bg_img_tiled, bool); + gen_lv_style!(set_bg_main_stop, i16); + gen_lv_style!(set_bg_opa, Opacity); + gen_lv_style!(set_blend_mode, u8); + gen_lv_style!(set_border_color, Color); + gen_lv_style!(set_border_opa, Opacity); + gen_lv_style!(set_border_post, bool); + gen_lv_style!(set_border_side, u8); + gen_lv_style!(set_border_width, i16); + gen_lv_style!(set_clip_corner, bool); + //gen_lv_style!(set_color_filter_dsc, ); + gen_lv_style!(set_color_filter_opa, Opacity); + gen_lv_style!(set_flex_cross_place, c_uint); + gen_lv_style!(set_flex_flow, c_uint); + gen_lv_style!(set_flex_grow, u8); + gen_lv_style!(set_flex_main_place, c_uint); + gen_lv_style!(set_flex_track_place, c_uint); + gen_lv_style!(set_grid_cell_column_pos, i16); + gen_lv_style!(set_grid_cell_column_span, i16); + gen_lv_style!(set_grid_cell_row_pos, i16); + gen_lv_style!(set_grid_cell_row_span, i16); + gen_lv_style!(set_grid_cell_x_align, i16); + gen_lv_style!(set_grid_cell_y_align, i16); + gen_lv_style!(set_grid_column_align, c_uint); + //gen_lv_style!(set_grid_column_dsc_array, ); + gen_lv_style!(set_grid_row_align, c_uint); + //gen_lv_style!(set_grid_row_dsc_array, ); + gen_lv_style!(set_height, i16); + gen_lv_style!(set_img_opa, Opacity); + gen_lv_style!(set_img_recolor, Color); + gen_lv_style!(set_img_recolor_opa, Opacity); + gen_lv_style!(set_layout, u16); + gen_lv_style!(set_line_color, Color); + gen_lv_style!(set_line_dash_gap, i16); + gen_lv_style!(set_line_dash_width, i16); + gen_lv_style!(set_line_opa, Opacity); + gen_lv_style!(set_line_rounded, bool); + gen_lv_style!(set_line_width, i16); + gen_lv_style!(set_max_height, i16); + gen_lv_style!(set_max_width, i16); + gen_lv_style!(set_min_height, i16); + gen_lv_style!(set_min_width, i16); + gen_lv_style!(set_opa, Opacity); + gen_lv_style!(set_outline_color, Color); + gen_lv_style!(set_outline_opa, Opacity); + gen_lv_style!(set_outline_pad, i16); + gen_lv_style!(set_outline_width, i16); + gen_lv_style!(set_pad_bottom, i16); + gen_lv_style!(set_pad_column, i16); + gen_lv_style!(set_pad_left, i16); + gen_lv_style!(set_pad_right, i16); + gen_lv_style!(set_pad_row, i16); + gen_lv_style!(set_pad_top, i16); + //gen_lv_style!(set_prop, ); + //gen_lv_style!(set_prop_meta, ); + gen_lv_style!(set_radius, i16); + gen_lv_style!(set_shadow_color, Color); + gen_lv_style!(set_shadow_ofs_x, i16); + gen_lv_style!(set_shadow_ofs_y, i16); + gen_lv_style!(set_shadow_opa, Opacity); + gen_lv_style!(set_shadow_spread, i16); + gen_lv_style!(set_shadow_width, i16); + gen_lv_style!(set_text_align, TextAlign); + gen_lv_style!(set_text_color, Color); + gen_lv_style!(set_text_decor, u8); + //gen_lv_style!(set_text_font, ); + gen_lv_style!(set_text_letter_space, i16); + gen_lv_style!(set_text_line_space, i16); + gen_lv_style!(set_text_opa, Opacity); + gen_lv_style!(set_transform_angle, i16); + gen_lv_style!(set_transform_height, i16); + gen_lv_style!(set_transform_pivot_x, i16); + gen_lv_style!(set_transform_pivot_y, i16); + gen_lv_style!(set_transform_width, i16); + gen_lv_style!(set_transform_zoom, i16); + //gen_lv_style!(set_transition, ); + gen_lv_style!(set_translate_x, i16); + gen_lv_style!(set_translate_y, i16); + gen_lv_style!(set_width, i16); + gen_lv_style!(set_x, i16); + gen_lv_style!(set_y, i16); } diff --git a/lvgl/src/mem.rs b/lvgl/src/mem.rs index fbcca38d..af359950 100644 --- a/lvgl/src/mem.rs +++ b/lvgl/src/mem.rs @@ -44,7 +44,7 @@ impl Box { impl Drop for Box { fn drop(&mut self) { unsafe { - lvgl_sys::lv_mem_free(self.0.as_ptr() as *const cty::c_void); + lvgl_sys::lv_mem_free(self.0.as_ptr() as *mut cty::c_void); } } } @@ -166,9 +166,9 @@ mod test { } drop(keep); - unsafe { - lvgl_sys::lv_mem_defrag(); - } + //unsafe { + // lvgl_sys::lv_mem_defrag(); + //} let final_info = mem_info(); println!("mem info: {:?}", &final_info); diff --git a/lvgl/src/support.rs b/lvgl/src/support.rs index c3d373ac..25cb2522 100644 --- a/lvgl/src/support.rs +++ b/lvgl/src/support.rs @@ -84,6 +84,12 @@ impl From for Rgb565 { } } +impl Into for Color { + fn into(self) -> lvgl_sys::lv_color_t { + self.raw + } +} + /// Events are triggered in LVGL when something happens which might be interesting to /// the user, e.g. if an object: /// - is clicked @@ -128,18 +134,19 @@ pub enum Event { Special(T), } -impl TryFrom for Event { +impl TryFrom for Event { type Error = (); - fn try_from(value: u8) -> Result { - const LV_EVENT_PRESSED: u32 = lvgl_sys::LV_EVENT_PRESSED as u32; - const LV_EVENT_PRESSING: u32 = lvgl_sys::LV_EVENT_PRESSING as u32; - const LV_EVENT_PRESS_LOST: u32 = lvgl_sys::LV_EVENT_PRESS_LOST as u32; - const LV_EVENT_SHORT_CLICKED: u32 = lvgl_sys::LV_EVENT_SHORT_CLICKED as u32; - const LV_EVENT_CLICKED: u32 = lvgl_sys::LV_EVENT_CLICKED as u32; - const LV_EVENT_LONG_PRESSED: u32 = lvgl_sys::LV_EVENT_LONG_PRESSED as u32; - const LV_EVENT_LONG_PRESSED_REPEAT: u32 = lvgl_sys::LV_EVENT_LONG_PRESSED_REPEAT as u32; - const LV_EVENT_RELEASED: u32 = lvgl_sys::LV_EVENT_RELEASED as u32; + fn try_from(value: lvgl_sys::lv_event_code_t) -> Result { + const LV_EVENT_PRESSED: u32 = lvgl_sys::lv_event_code_t_LV_EVENT_PRESSED as u32; + const LV_EVENT_PRESSING: u32 = lvgl_sys::lv_event_code_t_LV_EVENT_PRESSING as u32; + const LV_EVENT_PRESS_LOST: u32 = lvgl_sys::lv_event_code_t_LV_EVENT_PRESS_LOST as u32; + const LV_EVENT_SHORT_CLICKED: u32 = lvgl_sys::lv_event_code_t_LV_EVENT_SHORT_CLICKED as u32; + const LV_EVENT_CLICKED: u32 = lvgl_sys::lv_event_code_t_LV_EVENT_CLICKED as u32; + const LV_EVENT_LONG_PRESSED: u32 = lvgl_sys::lv_event_code_t_LV_EVENT_LONG_PRESSED as u32; + const LV_EVENT_LONG_PRESSED_REPEAT: u32 = + lvgl_sys::lv_event_code_t_LV_EVENT_LONG_PRESSED_REPEAT as u32; + const LV_EVENT_RELEASED: u32 = lvgl_sys::lv_event_code_t_LV_EVENT_RELEASED as u32; match value as u32 { LV_EVENT_PRESSED => Ok(Event::Pressed), @@ -155,21 +162,21 @@ impl TryFrom for Event { } } -impl From> for lvgl_sys::lv_event_t { +impl From> for lvgl_sys::lv_event_code_t { fn from(event: Event) -> Self { let native_event = match event { - Event::Pressed => lvgl_sys::LV_EVENT_PRESSED, - Event::Pressing => lvgl_sys::LV_EVENT_PRESSING, - Event::PressLost => lvgl_sys::LV_EVENT_PRESS_LOST, - Event::ShortClicked => lvgl_sys::LV_EVENT_SHORT_CLICKED, - Event::Clicked => lvgl_sys::LV_EVENT_CLICKED, - Event::LongPressed => lvgl_sys::LV_EVENT_LONG_PRESSED, - Event::LongPressedRepeat => lvgl_sys::LV_EVENT_LONG_PRESSED_REPEAT, - Event::Released => lvgl_sys::LV_EVENT_RELEASED, + Event::Pressed => lvgl_sys::lv_event_code_t_LV_EVENT_PRESSED, + Event::Pressing => lvgl_sys::lv_event_code_t_LV_EVENT_PRESSING, + Event::PressLost => lvgl_sys::lv_event_code_t_LV_EVENT_PRESS_LOST, + Event::ShortClicked => lvgl_sys::lv_event_code_t_LV_EVENT_SHORT_CLICKED, + Event::Clicked => lvgl_sys::lv_event_code_t_LV_EVENT_CLICKED, + Event::LongPressed => lvgl_sys::lv_event_code_t_LV_EVENT_LONG_PRESSED, + Event::LongPressedRepeat => lvgl_sys::lv_event_code_t_LV_EVENT_LONG_PRESSED_REPEAT, + Event::Released => lvgl_sys::lv_event_code_t_LV_EVENT_RELEASED, // TODO: handle all types... - _ => lvgl_sys::LV_EVENT_CLICKED, + _ => lvgl_sys::lv_event_code_t_LV_EVENT_CLICKED, }; - native_event as lvgl_sys::lv_event_t + native_event as lvgl_sys::lv_event_code_t } } @@ -181,21 +188,24 @@ pub enum PointerEvent { DragThrowBegin, } -pub(crate) unsafe extern "C" fn event_callback( - obj: *mut lvgl_sys::lv_obj_t, - event: lvgl_sys::lv_event_t, -) where +//pub(crate) unsafe extern "C" fn event_callback( +//obj: *mut lvgl_sys::lv_obj_t, +//event: lvgl_sys::lv_event_code_t, +pub(crate) unsafe extern "C" fn event_callback(event: *mut lvgl_sys::lv_event_t) +where T: Widget + Sized, F: FnMut(T, Event), { - // convert the lv_event_t to lvgl-rs Event type - if let Ok(event) = event.try_into() { + let code = (*event).code; + let obj = (*event).target; + // convert the lv_event_code_t to lvgl-rs Event type + if let Ok(code) = code.try_into() { if let Some(obj_ptr) = NonNull::new(obj) { let object = T::from_raw(obj_ptr); // get the pointer from the Rust callback closure FnMut provided by users let user_closure = &mut *((*obj).user_data as *mut F); // call user callback closure - user_closure(object, event); + user_closure(object, code); } } } @@ -203,14 +213,14 @@ pub(crate) unsafe extern "C" fn event_callback( /// Possible LVGL alignments for widgets. pub enum Align { Center, - InTopLeft, - InTopMid, - InTopRight, - InBottomLeft, - InBottomMid, - InBottomRight, - InLeftMid, - InRightMid, + TopLeft, + TopMid, + TopRight, + BottomLeft, + BottomMid, + BottomRight, + LeftMid, + RightMid, OutTopLeft, OutTopMid, OutTopRight, @@ -226,17 +236,17 @@ pub enum Align { } impl From for u8 { - fn from(self_: Align) -> u8 { - let native = match self_ { + fn from(value: Align) -> u8 { + let native = match value { Align::Center => lvgl_sys::LV_ALIGN_CENTER, - Align::InTopLeft => lvgl_sys::LV_ALIGN_IN_TOP_LEFT, - Align::InTopMid => lvgl_sys::LV_ALIGN_IN_TOP_MID, - Align::InTopRight => lvgl_sys::LV_ALIGN_IN_TOP_RIGHT, - Align::InBottomLeft => lvgl_sys::LV_ALIGN_IN_BOTTOM_LEFT, - Align::InBottomMid => lvgl_sys::LV_ALIGN_IN_BOTTOM_MID, - Align::InBottomRight => lvgl_sys::LV_ALIGN_IN_BOTTOM_RIGHT, - Align::InLeftMid => lvgl_sys::LV_ALIGN_IN_LEFT_MID, - Align::InRightMid => lvgl_sys::LV_ALIGN_IN_RIGHT_MID, + Align::TopLeft => lvgl_sys::LV_ALIGN_TOP_LEFT, + Align::TopMid => lvgl_sys::LV_ALIGN_TOP_MID, + Align::TopRight => lvgl_sys::LV_ALIGN_TOP_RIGHT, + Align::BottomLeft => lvgl_sys::LV_ALIGN_BOTTOM_LEFT, + Align::BottomMid => lvgl_sys::LV_ALIGN_BOTTOM_MID, + Align::BottomRight => lvgl_sys::LV_ALIGN_BOTTOM_RIGHT, + Align::LeftMid => lvgl_sys::LV_ALIGN_LEFT_MID, + Align::RightMid => lvgl_sys::LV_ALIGN_RIGHT_MID, Align::OutTopLeft => lvgl_sys::LV_ALIGN_OUT_TOP_LEFT, Align::OutTopMid => lvgl_sys::LV_ALIGN_OUT_TOP_MID, Align::OutTopRight => lvgl_sys::LV_ALIGN_OUT_TOP_RIGHT, @@ -254,6 +264,25 @@ impl From for u8 { } } +pub enum TextAlign { + Auto, + Center, + Left, + Right, +} + +impl From for u8 { + fn from(value: TextAlign) -> Self { + let native = match value { + TextAlign::Auto => lvgl_sys::LV_TEXT_ALIGN_AUTO, + TextAlign::Center => lvgl_sys::LV_TEXT_ALIGN_CENTER, + TextAlign::Left => lvgl_sys::LV_TEXT_ALIGN_LEFT, + TextAlign::Right => lvgl_sys::LV_TEXT_ALIGN_RIGHT, + }; + native as u8 + } +} + /// Boolean for determining whether animations are enabled. pub enum Animation { ON, @@ -263,8 +292,8 @@ pub enum Animation { impl From for lvgl_sys::lv_anim_enable_t { fn from(anim: Animation) -> Self { match anim { - Animation::ON => lvgl_sys::LV_ANIM_ON as u8, - Animation::OFF => lvgl_sys::LV_ANIM_OFF as u8, + Animation::ON => lvgl_sys::lv_anim_enable_t_LV_ANIM_ON, + Animation::OFF => lvgl_sys::lv_anim_enable_t_LV_ANIM_OFF, } } } diff --git a/lvgl/src/widgets/arc.rs b/lvgl/src/widgets/arc.rs index e168286f..0fa56592 100644 --- a/lvgl/src/widgets/arc.rs +++ b/lvgl/src/widgets/arc.rs @@ -37,7 +37,7 @@ impl Arc { // Ok(()) // } } - +/* /// The different parts, of an arc object. #[derive(Debug, Copy, Clone, PartialEq)] #[repr(u8)] @@ -54,3 +54,4 @@ impl From for u8 { part as u8 } } +*/ diff --git a/lvgl/src/widgets/bar.rs b/lvgl/src/widgets/bar.rs index 88e4aec8..aff39505 100644 --- a/lvgl/src/widgets/bar.rs +++ b/lvgl/src/widgets/bar.rs @@ -4,22 +4,22 @@ use crate::{LvResult, NativeObject}; impl Bar { /// Set minimum and the maximum values of the bar - pub fn set_range(&mut self, min: i16, max: i16) -> LvResult<()> { - unsafe { - lvgl_sys::lv_bar_set_range(self.core.raw()?.as_mut(), min, max); - } - Ok(()) - } + //pub fn set_range(&mut self, min: i16, max: i16) -> LvResult<()> { + // unsafe { + // lvgl_sys::lv_bar_set_range(self.core.raw()?.as_mut(), min, max); + // } + // Ok(()) + //} /// Set a new value on the bar - pub fn set_value(&mut self, value: i16, anim: Animation) -> LvResult<()> { + pub fn set_value(&mut self, value: i32, anim: Animation) -> LvResult<()> { unsafe { lvgl_sys::lv_bar_set_value(self.core.raw()?.as_mut(), value, anim.into()); } Ok(()) } } - +/* /// The different parts, of a bar object. pub enum BarPart { /// The background of the bar. @@ -37,3 +37,4 @@ impl From for u8 { } } } +*/ diff --git a/lvgl/src/widgets/gauge.rs b/lvgl/src/widgets/gauge.rs deleted file mode 100644 index 4ba1ebf4..00000000 --- a/lvgl/src/widgets/gauge.rs +++ /dev/null @@ -1,15 +0,0 @@ -pub enum GaugePart { - Main, - Major, - Needle, -} - -impl From for u8 { - fn from(part: GaugePart) -> Self { - match part { - GaugePart::Main => lvgl_sys::LV_GAUGE_PART_MAIN as u8, - GaugePart::Major => lvgl_sys::LV_GAUGE_PART_MAJOR as u8, - GaugePart::Needle => lvgl_sys::LV_GAUGE_PART_NEEDLE as u8, - } - } -} diff --git a/lvgl/src/widgets/label.rs b/lvgl/src/widgets/label.rs index acbb7858..7d4e08d1 100644 --- a/lvgl/src/widgets/label.rs +++ b/lvgl/src/widgets/label.rs @@ -1,15 +1,5 @@ -use crate::widgets::Label; -use crate::{LvResult, NativeObject}; - -impl Label { - pub fn set_label_align(&mut self, align: LabelAlign) -> LvResult<()> { - unsafe { - lvgl_sys::lv_label_set_align(self.core.raw()?.as_mut(), align as u8); - } - Ok(()) - } -} - +//use crate::widgets::Label; +//use crate::{LvResult, NativeObject}; #[cfg(feature = "alloc")] mod alloc_imp { use crate::widgets::Label; @@ -39,12 +29,3 @@ mod alloc_imp { // } // } } - -#[derive(Debug, Copy, Clone, PartialEq)] -#[repr(u8)] -pub enum LabelAlign { - Left = lvgl_sys::LV_LABEL_ALIGN_LEFT as u8, - Center = lvgl_sys::LV_LABEL_ALIGN_CENTER as u8, - Right = lvgl_sys::LV_LABEL_ALIGN_RIGHT as u8, - Auto = lvgl_sys::LV_LABEL_ALIGN_AUTO as u8, -} diff --git a/lvgl/src/widgets/meter.rs b/lvgl/src/widgets/meter.rs new file mode 100644 index 00000000..7d4dd752 --- /dev/null +++ b/lvgl/src/widgets/meter.rs @@ -0,0 +1,17 @@ +pub enum MeterPart { + Arc, + Needle, + Tick, +} + +impl From for u8 { + fn from(part: MeterPart) -> Self { + match part { + MeterPart::Arc => lvgl_sys::lv_meter_draw_part_type_t_LV_METER_DRAW_PART_ARC as u8, + MeterPart::Needle => { + lvgl_sys::lv_meter_draw_part_type_t_LV_METER_DRAW_PART_NEEDLE_LINE as u8 + } + MeterPart::Tick => lvgl_sys::lv_meter_draw_part_type_t_LV_METER_DRAW_PART_TICK as u8, + } + } +} diff --git a/lvgl/src/widgets/mod.rs b/lvgl/src/widgets/mod.rs index 6457a850..3179d0b0 100644 --- a/lvgl/src/widgets/mod.rs +++ b/lvgl/src/widgets/mod.rs @@ -1,12 +1,12 @@ mod arc; mod bar; -mod gauge; mod label; +mod meter; include!(concat!(env!("OUT_DIR"), "/generated.rs")); use crate::NativeObject; pub use arc::*; pub use bar::*; -pub use gauge::*; pub use label::*; +pub use meter::*;