Compare commits
18 commits
Author | SHA1 | Date | |
---|---|---|---|
601a87d513 | |||
faa3a19215 | |||
029d230cab | |||
ade4ae5a2d | |||
37950d6e2e | |||
763b78e45d | |||
Rafael Caricio | 0a5b5a0416 | ||
Rafael Caricio | a5c27b58ae | ||
cbbdc7e750 | |||
Rafael Caricio | 56cb470dc8 | ||
Rafael Caricio | 043bb52881 | ||
Rafael Caricio | a5ffa62013 | ||
Rafael Caricio | 348963b80d | ||
3791b211b8 | |||
Rafael Caricio | d699101afe | ||
Rafael Caricio | f60d8d999b | ||
Rafael Caricio | ab8b8ae05f | ||
Rafael Caricio | 9b9ea48920 |
|
@ -1,7 +1,6 @@
|
|||
[workspace]
|
||||
members = [
|
||||
"lvgl",
|
||||
"lvgl-sys",
|
||||
"lvgl-codegen",
|
||||
"examples"
|
||||
"lvgl-sys",
|
||||
]
|
||||
|
|
28
README.md
28
README.md
|
@ -1,18 +1,21 @@
|
|||
<h1 align="center"> LittlevGL - Open-source Embedded GUI Library in Rust</h1>
|
||||
[![SWUbanner](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner2-direct.svg)](https://github.com/vshymanskyy/StandWithUkraine/blob/main/docs/README.md)
|
||||
|
||||
![Original LittlevGL demo image](lv_demo.png)
|
||||
<h1 align="center"> LVGL - Open-source Embedded GUI Library in Rust</h1>
|
||||
|
||||
![Original LVGL demo image](lv_demo.png)
|
||||
|
||||
<p align="center">
|
||||
LittlevGL provides everything you need to create a Graphical User Interface (GUI) on embedded systems with easy-to-use graphical elements, beautiful visual effects and low memory footprint.
|
||||
LVGL provides everything you need to create a Graphical User Interface (GUI) on embedded systems with easy-to-use graphical elements, beautiful visual effects and low memory footprint.
|
||||
</p>
|
||||
<p align="center">
|
||||
LittlevGL is compatible with <samp>#![no_std]</samp> environments by default.
|
||||
LVGL is compatible with <samp>#![no_std]</samp> environments by default.
|
||||
</p>
|
||||
|
||||
<h4 align="center">
|
||||
<a href="https://lvgl.io/">Official LittlevGL Website </a> ·
|
||||
<a href="https://github.com/rafaelcaricio/lvgl-rs-wasm">Rust to WASM demo</a> ·
|
||||
<a href="https://lvgl.io/">Official LVGL Website </a> ·
|
||||
<a href="https://github.com/littlevgl/lvgl">C library repository</a> ·
|
||||
<a href="https://lvgl.io/demos">Live demo</a>
|
||||
<a href="https://lvgl.io/demos">Official live demos</a>
|
||||
</h4>
|
||||
|
||||
---
|
||||
|
@ -42,7 +45,7 @@ $ cargo add lvgl
|
|||
|
||||
The build requires the environment variable bellow to be set:
|
||||
|
||||
- `DEP_LV_CONFIG_PATH`: Path to the directory containing the `lv_conf.h` header file used for configuration of LittlevGL library.
|
||||
- `DEP_LV_CONFIG_PATH`: Path to the directory containing the `lv_conf.h` header file used for configuration of LVGL library.
|
||||
|
||||
We recommend the `lv_conf.h` file to be in your project's root directory. If so, the command to build your project would be:
|
||||
```shell script
|
||||
|
@ -58,10 +61,17 @@ for `no_std`, so we need to use a workaround to build "lvgl-rs". The mainstrem i
|
|||
```shell
|
||||
$ DEP_LV_CONFIG_PATH=`pwd` cargo build -Zfeatures=build_dep
|
||||
```
|
||||
### LVGL Global Allocator
|
||||
|
||||
A [global allocator](https://doc.rust-lang.org/std/alloc/trait.GlobalAlloc.html) for Rust leveraging the
|
||||
[LVGL memory allocator](https://github.com/lvgl/lvgl/blob/master/src/misc/lv_mem.h) is provided, but not enabled
|
||||
by default. Can be enabled by the feature `lvgl_alloc`. This will make all dynamic memory to be allocated by LVGL
|
||||
internal memory manager.
|
||||
|
||||
## Running the demo
|
||||
|
||||
**Hint for macOS users**: Before you run the demos you need to make sure you have [libsdl](https://www.libsdl.org) installed on your machine. To install it, use HomeBrew:
|
||||
**Hint for macOS users**: Before you run the demos you need to make sure you have [libsdl](https://www.libsdl.org)
|
||||
installed on your machine. To install it, use HomeBrew:
|
||||
|
||||
```shell
|
||||
$ brew install sdl2
|
||||
|
@ -78,7 +88,7 @@ $ git submodule update
|
|||
Then run the `demo` example:
|
||||
|
||||
```shell
|
||||
$ DEP_LV_CONFIG_PATH=`pwd`/examples/include cargo run --example demo
|
||||
$ DEP_LV_CONFIG_PATH=`pwd`/examples/include cargo run --example demo --features="alloc"
|
||||
```
|
||||
|
||||
## Feature Support
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
[package]
|
||||
name = "demo"
|
||||
version = "0.1.0"
|
||||
authors = ["Rafael Caricio <crates@caric.io>"]
|
||||
edition = "2018"
|
||||
publish = false
|
||||
|
||||
[dev-dependencies]
|
||||
lvgl = { path = "../lvgl" }
|
||||
lvgl-sys = { path = "../lvgl-sys" }
|
||||
embedded-graphics = "0.6"
|
||||
embedded-graphics-simulator = "0.2.0"
|
||||
heapless = "0.5.5"
|
||||
cstr_core = { version = "0.2.0", features = ["alloc"] }
|
||||
|
||||
[[example]]
|
||||
name = "demo"
|
||||
path = "demo.rs"
|
||||
|
||||
[[example]]
|
||||
name = "bar"
|
||||
path = "bar.rs"
|
||||
|
||||
[[example]]
|
||||
name = "button_click"
|
||||
path = "button_click.rs"
|
||||
|
||||
[[example]]
|
||||
name = "gauge"
|
||||
path = "gauge.rs"
|
||||
|
||||
[[example]]
|
||||
name = "arc"
|
||||
path = "arc.rs"
|
|
@ -11,7 +11,31 @@ use lvgl::{LvError, Widget};
|
|||
use lvgl_sys;
|
||||
use std::time::Instant;
|
||||
|
||||
fn mem_info() -> lvgl_sys::lv_mem_monitor_t {
|
||||
let mut info = lvgl_sys::lv_mem_monitor_t {
|
||||
total_size: 0,
|
||||
free_cnt: 0,
|
||||
free_size: 0,
|
||||
free_biggest_size: 0,
|
||||
used_cnt: 0,
|
||||
max_used: 0,
|
||||
used_pct: 0,
|
||||
frag_pct: 0,
|
||||
};
|
||||
unsafe {
|
||||
lvgl_sys::lv_mem_monitor(&mut info as *mut _);
|
||||
}
|
||||
info
|
||||
}
|
||||
|
||||
fn main() -> Result<(), LvError> {
|
||||
println!("meminfo init: {:?}", mem_info());
|
||||
run_arc_demo()?;
|
||||
println!("meminfo end: {:?}", mem_info());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn run_arc_demo() -> Result<(), LvError> {
|
||||
let display: SimulatorDisplay<Rgb565> = SimulatorDisplay::new(Size::new(
|
||||
lvgl_sys::LV_HOR_RES_MAX,
|
||||
lvgl_sys::LV_VER_RES_MAX,
|
||||
|
@ -58,6 +82,7 @@ fn main() -> Result<(), LvError> {
|
|||
if i > 270 {
|
||||
forward = if forward { false } else { true };
|
||||
i = 1;
|
||||
println!("meminfo running: {:?}", mem_info());
|
||||
}
|
||||
angle = if forward { angle + 1 } else { angle - 1 };
|
||||
arc.set_end_angle(angle + 135)?;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use cstr_core::{CStr, CString};
|
||||
use cstr_core::CString;
|
||||
use embedded_graphics::pixelcolor::Rgb565;
|
||||
use embedded_graphics::prelude::*;
|
||||
use embedded_graphics_simulator::{
|
||||
|
@ -52,20 +52,6 @@ fn main() -> Result<(), LvError> {
|
|||
bt.set_label_align(LabelAlign::Left)?;
|
||||
bt.set_align(&mut screen, Align::InTopLeft, 0, 0)?;
|
||||
|
||||
fn set_text<S>(text: S) -> Result<(), ()>
|
||||
where
|
||||
S: AsRef<cstr_core::CStr>,
|
||||
{
|
||||
let _v: *const i8 = text.as_ref().as_ptr();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
let mut t: heapless::String<heapless::consts::U8> = heapless::String::from("test");
|
||||
t.push('\0').unwrap();
|
||||
set_text(CStr::from_bytes_with_nul(t.as_bytes()).unwrap()).unwrap();
|
||||
set_text(cstr_core::CStr::from_bytes_with_nul("test\0".as_bytes()).unwrap()).unwrap();
|
||||
set_text(cstr_core::CString::new("test").unwrap().as_c_str()).unwrap();
|
||||
|
||||
let mut power = Label::new(&mut screen)?;
|
||||
power.set_recolor(true)?;
|
||||
power.set_width(80)?;
|
||||
|
@ -80,8 +66,8 @@ fn main() -> Result<(), LvError> {
|
|||
if i > 59 {
|
||||
i = 0;
|
||||
}
|
||||
let val = format!("21:{:02}", i);
|
||||
time.set_text(CString::new(val.as_str()).unwrap().as_c_str())?;
|
||||
let val = CString::new(format!("21:{:02}", i)).unwrap();
|
||||
time.set_text(&val)?;
|
||||
i = 1 + i;
|
||||
|
||||
ui.task_handler();
|
||||
|
@ -102,7 +88,7 @@ fn main() -> Result<(), LvError> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
// Reference to native font for LittlevGL, defined in the file: "fonts_noto_sans_numeric_80.c"
|
||||
// Reference to native font for LVGL, defined in the file: "fonts_noto_sans_numeric_80.c"
|
||||
// TODO: Create a macro for defining a safe wrapper for fonts.
|
||||
// Maybe sometihng like:
|
||||
//
|
||||
|
|
|
@ -80,7 +80,7 @@ typedef int16_t lv_coord_t;
|
|||
#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)
|
||||
# define LV_MEM_SIZE (1048576U) // 1Mb
|
||||
|
||||
/* Complier prefix for a big array declaration */
|
||||
# define LV_MEM_ATTR
|
||||
|
|
|
@ -9,10 +9,10 @@ license = "MIT"
|
|||
repository = "https://github.com/rafaelcaricio/lvgl-rs"
|
||||
|
||||
[dependencies]
|
||||
regex = "1.3.9"
|
||||
quote = "1.0.7"
|
||||
regex = "1.4.3"
|
||||
quote = "1.0.9"
|
||||
lazy_static = "1.4.0"
|
||||
proc-macro2 = "1.0.18"
|
||||
proc-macro2 = "1.0.27"
|
||||
Inflector = "0.11.4"
|
||||
syn = { version = "1.0.31", features = ["full"]}
|
||||
syn = { version = "1.0.72", features = ["full"]}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use inflector::cases::pascalcase::to_pascal_case;
|
||||
use lazy_static::lazy_static;
|
||||
use proc_macro2::{Ident, TokenStream};
|
||||
use quote::{format_ident, ToTokens};
|
||||
use quote::quote;
|
||||
use quote::{format_ident, ToTokens};
|
||||
use regex::Regex;
|
||||
use std::collections::HashMap;
|
||||
use std::error::Error;
|
||||
|
@ -303,21 +303,21 @@ impl Rusty for LvArg {
|
|||
#[derive(Clone)]
|
||||
pub struct LvType {
|
||||
literal_name: String,
|
||||
r_type: Option<Box<syn::Type>>,
|
||||
_r_type: Option<Box<syn::Type>>,
|
||||
}
|
||||
|
||||
impl LvType {
|
||||
pub fn new(literal_name: String) -> Self {
|
||||
Self {
|
||||
literal_name,
|
||||
r_type: None,
|
||||
_r_type: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from(r_type: Box<syn::Type>) -> Self {
|
||||
Self {
|
||||
literal_name: r_type.to_token_stream().to_string(),
|
||||
r_type: Some(r_type),
|
||||
_r_type: Some(r_type),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "lvgl-sys"
|
||||
description = "Raw bindings to the LittlevGL C library."
|
||||
description = "Raw bindings to the LVGL C library."
|
||||
version = "0.5.2"
|
||||
authors = ["Rafael Caricio <crates.lvgl-sys@caric.io>"]
|
||||
edition = "2018"
|
||||
|
@ -20,5 +20,8 @@ name = "lvgl_sys"
|
|||
cty = "0.2.1"
|
||||
|
||||
[build-dependencies]
|
||||
cc = "1.0.50"
|
||||
bindgen = "0.54.0"
|
||||
cc = "1.0.68"
|
||||
bindgen = "0.59.2"
|
||||
|
||||
[features]
|
||||
use-vendored-config = []
|
||||
|
|
|
@ -5,7 +5,7 @@ Rust raw bindings for LittlevGL library.
|
|||
|
||||
Build requires environment variables to be set:
|
||||
|
||||
- `DEP_LV_CONFIG_PATH`: Path to the directory containing the `lv_conf.h` header file used for configuration of LittlevGL library.
|
||||
- `DEP_LV_CONFIG_PATH`: Path to the directory containing the `lv_conf.h` header file used for configuration of LVGL library.
|
||||
|
||||
We recommend the `lv_conf.h` file to be in your project's root directory. If so, the command to build your project would be:
|
||||
```shell script
|
||||
|
|
|
@ -4,44 +4,50 @@ use std::{env, path::Path, path::PathBuf};
|
|||
static CONFIG_NAME: &str = "DEP_LV_CONFIG_PATH";
|
||||
|
||||
fn main() {
|
||||
let project_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap())
|
||||
.canonicalize()
|
||||
.unwrap();
|
||||
let project_dir = canonicalize(PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()));
|
||||
let shims_dir = project_dir.join("shims");
|
||||
let vendor = project_dir.join("vendor");
|
||||
let vendor_src = vendor.join("lvgl").join("src");
|
||||
|
||||
let lv_config_dir = {
|
||||
let conf_path = env::var(CONFIG_NAME).map(|raw_path| PathBuf::from(raw_path)).unwrap_or_else(|_| {
|
||||
let conf_path = env::var(CONFIG_NAME)
|
||||
.map(PathBuf::from)
|
||||
.unwrap_or_else(|_| {
|
||||
match std::env::var("DOCS_RS") {
|
||||
Ok(_) => {
|
||||
// We've detected that we are building for docs.rs
|
||||
// so let's use the vendored `lv_conf.h` file.
|
||||
vendor.clone()
|
||||
vendor.join("include")
|
||||
}
|
||||
Err(_) => panic!(
|
||||
"The environment variable {} is required to be defined",
|
||||
CONFIG_NAME
|
||||
)
|
||||
}
|
||||
});
|
||||
Err(_) => {
|
||||
#[cfg(not(feature = "use-vendored-config"))]
|
||||
panic!(
|
||||
"The environment variable {} is required to be defined",
|
||||
CONFIG_NAME
|
||||
);
|
||||
|
||||
#[cfg(feature = "use-vendored-config")]
|
||||
vendor.join("include")
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if !conf_path.exists() {
|
||||
panic!(format!(
|
||||
panic!(
|
||||
"Directory {} referenced by {} needs to exist",
|
||||
conf_path.to_string_lossy(),
|
||||
CONFIG_NAME
|
||||
));
|
||||
);
|
||||
}
|
||||
if !conf_path.is_dir() {
|
||||
panic!(format!("{} needs to be a directory", CONFIG_NAME));
|
||||
panic!("{} needs to be a directory", CONFIG_NAME);
|
||||
}
|
||||
if !conf_path.join("lv_conf.h").exists() {
|
||||
panic!(format!(
|
||||
panic!(
|
||||
"Directory {} referenced by {} needs to contain a file called lv_conf.h",
|
||||
conf_path.to_string_lossy(),
|
||||
CONFIG_NAME
|
||||
));
|
||||
);
|
||||
}
|
||||
|
||||
println!(
|
||||
|
@ -91,11 +97,20 @@ fn main() {
|
|||
if target.ends_with("emscripten") {
|
||||
if let Ok(em_path) = env::var("EMSDK") {
|
||||
additional_args.push("-I".to_string());
|
||||
additional_args.push(format!("{}/upstream/emscripten/system/include/libc", em_path));
|
||||
additional_args.push(format!(
|
||||
"{}/upstream/emscripten/system/include/libc",
|
||||
em_path
|
||||
));
|
||||
additional_args.push("-I".to_string());
|
||||
additional_args.push(format!("{}/upstream/emscripten/system/lib/libc/musl/arch/emscripten", em_path));
|
||||
additional_args.push(format!(
|
||||
"{}/upstream/emscripten/system/lib/libc/musl/arch/emscripten",
|
||||
em_path
|
||||
));
|
||||
additional_args.push("-I".to_string());
|
||||
additional_args.push(format!("{}/upstream/emscripten/system/include/SDL", em_path));
|
||||
additional_args.push(format!(
|
||||
"{}/upstream/emscripten/system/include/SDL",
|
||||
em_path
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -112,7 +127,8 @@ fn main() {
|
|||
.generate()
|
||||
.expect("Unable to generate bindings");
|
||||
|
||||
bindings.write_to_file(out_path.join("bindings.rs"))
|
||||
bindings
|
||||
.write_to_file(out_path.join("bindings.rs"))
|
||||
.expect("Can't write bindings!");
|
||||
}
|
||||
|
||||
|
@ -127,3 +143,10 @@ fn add_c_files(build: &mut cc::Build, path: impl AsRef<Path>) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn canonicalize(path: impl AsRef<Path>) -> PathBuf {
|
||||
let canonicalized = path.as_ref().canonicalize().unwrap();
|
||||
let canonicalized = &*canonicalized.to_string_lossy();
|
||||
|
||||
PathBuf::from(canonicalized.strip_prefix(r"\\?\").unwrap_or(canonicalized))
|
||||
}
|
||||
|
|
|
@ -23,10 +23,10 @@ mod tests {
|
|||
lv_init();
|
||||
|
||||
let horizontal_resolution = lv_disp_get_hor_res(core::ptr::null_mut());
|
||||
assert_eq!(horizontal_resolution, 240);
|
||||
assert_eq!(horizontal_resolution, LV_HOR_RES_MAX as i16);
|
||||
|
||||
let vertical_resolution = lv_disp_get_ver_res(core::ptr::null_mut());
|
||||
assert_eq!(vertical_resolution, 240);
|
||||
assert_eq!(vertical_resolution, LV_VER_RES_MAX as i16);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
2
lvgl-sys/vendor/lvgl
vendored
2
lvgl-sys/vendor/lvgl
vendored
|
@ -1 +1 @@
|
|||
Subproject commit 1ca1934dbe8e826ef1ed1690005fb678fea3a1f3
|
||||
Subproject commit 524709472757405ac0eef8d6d002632526430df3
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "lvgl"
|
||||
description = "LittlevGL bindings for Rust. A powerful and easy-to-use embedded GUI with many widgets, advanced visual effects (opacity, antialiasing, animations) and low memory requirements (16K RAM, 64K Flash)."
|
||||
description = "LVGL bindings for Rust. A powerful and easy-to-use embedded GUI with many widgets, advanced visual effects (opacity, antialiasing, animations) and low memory requirements (16K RAM, 64K Flash)."
|
||||
version = "0.5.2"
|
||||
authors = ["Rafael Caricio <crates.lvgl@caric.io>"]
|
||||
edition = "2018"
|
||||
|
@ -14,13 +14,45 @@ build = "build.rs"
|
|||
[dependencies]
|
||||
lvgl-sys = { version = "0.5.2", path = "../lvgl-sys" }
|
||||
cty = "0.2.1"
|
||||
embedded-graphics = "0.6.2"
|
||||
cstr_core = "0.2.0"
|
||||
embedded-graphics = "0.7.1"
|
||||
cstr_core = "0.2.3"
|
||||
bitflags = "1.2.1"
|
||||
|
||||
[features]
|
||||
alloc = ["cstr_core/alloc"]
|
||||
lvgl_alloc = ["alloc"]
|
||||
use-vendored-config = ["lvgl-sys/use-vendored-config"]
|
||||
|
||||
[build-dependencies]
|
||||
quote = "1.0.7"
|
||||
proc-macro2 = "1.0.18"
|
||||
quote = "1.0.9"
|
||||
proc-macro2 = "1.0.24"
|
||||
lvgl-codegen = { version = "0.5.2", path = "../lvgl-codegen" }
|
||||
lvgl-sys = { version = "0.5.2", path = "../lvgl-sys" }
|
||||
|
||||
[dev-dependencies]
|
||||
embedded-graphics-simulator = "0.3.0"
|
||||
heapless = "0.7.13"
|
||||
|
||||
[[example]]
|
||||
name = "demo"
|
||||
path = "../examples/demo.rs"
|
||||
required-features = ["alloc"]
|
||||
|
||||
[[example]]
|
||||
name = "bar"
|
||||
path = "../examples/bar.rs"
|
||||
required-features = ["alloc"]
|
||||
|
||||
[[example]]
|
||||
name = "button_click"
|
||||
path = "../examples/button_click.rs"
|
||||
required-features = ["alloc"]
|
||||
|
||||
[[example]]
|
||||
name = "gauge"
|
||||
path = "../examples/gauge.rs"
|
||||
|
||||
[[example]]
|
||||
name = "arc"
|
||||
path = "../examples/arc.rs"
|
||||
required-features = ["lvgl_alloc"]
|
||||
|
|
20
lvgl/src/allocator.rs
Normal file
20
lvgl/src/allocator.rs
Normal file
|
@ -0,0 +1,20 @@
|
|||
use core::alloc::{GlobalAlloc, Layout};
|
||||
|
||||
// Register the global allocator
|
||||
#[global_allocator]
|
||||
static ALLOCATOR: LvglAlloc = LvglAlloc;
|
||||
|
||||
pub struct LvglAlloc;
|
||||
|
||||
unsafe impl GlobalAlloc for LvglAlloc {
|
||||
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
|
||||
// Make sure LVGL is initialized!
|
||||
crate::lvgl_init();
|
||||
lvgl_sys::lv_mem_alloc(layout.size() as lvgl_sys::size_t) as *mut u8
|
||||
}
|
||||
|
||||
unsafe fn dealloc(&self, ptr: *mut u8, _layout: Layout) {
|
||||
crate::lvgl_init();
|
||||
lvgl_sys::lv_mem_free(ptr as *const cty::c_void)
|
||||
}
|
||||
}
|
|
@ -1,15 +1,68 @@
|
|||
//! [![github]](https://github.com/rafaelcaricio/lvgl-rs) [![crates-io]](https://crates.io/crates/lvgl) [![docs-rs]](crate)
|
||||
//!
|
||||
//! [github]: https://img.shields.io/badge/github-8da0cb?style=for-the-badge&labelColor=555555&logo=github
|
||||
//! [crates-io]: https://img.shields.io/badge/crates.io-fc8d62?style=for-the-badge&labelColor=555555&logo=rust
|
||||
//! [docs-rs]: https://img.shields.io/badge/docs.rs-66c2a5?style=for-the-badge&labelColor=555555&logoColor=white&logo=data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDUxMiA1MTIiPjxwYXRoIGZpbGw9IiNmNWY1ZjUiIGQ9Ik00ODguNiAyNTAuMkwzOTIgMjE0VjEwNS41YzAtMTUtOS4zLTI4LjQtMjMuNC0zMy43bC0xMDAtMzcuNWMtOC4xLTMuMS0xNy4xLTMuMS0yNS4zIDBsLTEwMCAzNy41Yy0xNC4xIDUuMy0yMy40IDE4LjctMjMuNCAzMy43VjIxNGwtOTYuNiAzNi4yQzkuMyAyNTUuNSAwIDI2OC45IDAgMjgzLjlWMzk0YzAgMTMuNiA3LjcgMjYuMSAxOS45IDMyLjJsMTAwIDUwYzEwLjEgNS4xIDIyLjEgNS4xIDMyLjIgMGwxMDMuOS01MiAxMDMuOSA1MmMxMC4xIDUuMSAyMi4xIDUuMSAzMi4yIDBsMTAwLTUwYzEyLjItNi4xIDE5LjktMTguNiAxOS45LTMyLjJWMjgzLjljMC0xNS05LjMtMjguNC0yMy40LTMzLjd6TTM1OCAyMTQuOGwtODUgMzEuOXYtNjguMmw4NS0zN3Y3My4zek0xNTQgMTA0LjFsMTAyLTM4LjIgMTAyIDM4LjJ2LjZsLTEwMiA0MS40LTEwMi00MS40di0uNnptODQgMjkxLjFsLTg1IDQyLjV2LTc5LjFsODUtMzguOHY3NS40em0wLTExMmwtMTAyIDQxLjQtMTAyLTQxLjR2LS42bDEwMi0zOC4yIDEwMiAzOC4ydi42em0yNDAgMTEybC04NSA0Mi41di03OS4xbDg1LTM4Ljh2NzUuNHptMC0xMTJsLTEwMiA0MS40LTEwMi00MS40di0uNmwxMDItMzguMiAxMDIgMzguMnYuNnoiPjwvcGF0aD48L3N2Zz4K
|
||||
//!
|
||||
//! <br>
|
||||
//!
|
||||
//! [LVGL][1] bindings for Rust. A powerful and easy-to-use embedded GUI with many widgets, advanced visual effects, and
|
||||
//! low memory footprint. This crate is compatible with `#![no_std]` environments by default.
|
||||
//!
|
||||
//! [1]: https://docs.lvgl.io/v7/en/html/get-started/quick-overview.html
|
||||
//!
|
||||
|
||||
#![cfg_attr(not(test), no_std)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate bitflags;
|
||||
|
||||
pub(crate) mod mem;
|
||||
#[cfg(feature = "lvgl_alloc")]
|
||||
extern crate alloc;
|
||||
|
||||
// We can ONLY use `alloc::boxed::Box` if `lvgl_alloc` is enabled.
|
||||
// That is because we use `Box` to send memory references to LVGL. Since the global allocator, when
|
||||
// `lvgl_alloc` feature is enabled, is the LVGL memory manager then everything is in LVGL
|
||||
// managed memory anyways. In that case we can use the Rust's provided Box definition.
|
||||
//
|
||||
#[cfg(feature = "lvgl_alloc")]
|
||||
use ::alloc::boxed::Box;
|
||||
|
||||
#[cfg(feature = "lvgl_alloc")]
|
||||
mod allocator;
|
||||
|
||||
mod support;
|
||||
mod ui;
|
||||
#[macro_use]
|
||||
mod lv_core;
|
||||
pub mod widgets;
|
||||
|
||||
#[cfg(not(feature = "lvgl_alloc"))]
|
||||
pub(crate) mod mem;
|
||||
|
||||
// When LVGL allocator is not used on the Rust code, we need a way to add objects to the LVGL
|
||||
// managed memory. We implement a very simple `Box` that has the minimal features to copy memory
|
||||
// safely to the LVGL managed memory.
|
||||
//
|
||||
#[cfg(not(feature = "lvgl_alloc"))]
|
||||
use crate::mem::Box;
|
||||
|
||||
pub use lv_core::*;
|
||||
pub use support::*;
|
||||
pub use ui::*;
|
||||
|
||||
use core::sync::atomic::{AtomicBool, Ordering};
|
||||
|
||||
// Initialize LVGL only once.
|
||||
static LVGL_INITIALIZED: AtomicBool = AtomicBool::new(false);
|
||||
|
||||
pub(crate) fn lvgl_init() {
|
||||
if LVGL_INITIALIZED
|
||||
.compare_exchange(false, true, Ordering::Relaxed, Ordering::Relaxed)
|
||||
.is_ok()
|
||||
{
|
||||
unsafe {
|
||||
lvgl_sys::lv_init();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
use crate::lv_core::style::Style;
|
||||
use crate::mem::Box;
|
||||
use crate::Box;
|
||||
use crate::{Align, LvError, LvResult};
|
||||
use core::ptr;
|
||||
|
||||
/// Represents a native LittlevGL object
|
||||
/// Represents a native LVGL object
|
||||
pub trait NativeObject {
|
||||
/// Provide common way to access to the underlying native object pointer.
|
||||
fn raw(&self) -> LvResult<ptr::NonNull<lvgl_sys::lv_obj_t>>;
|
||||
|
@ -28,7 +28,7 @@ impl NativeObject for Obj {
|
|||
}
|
||||
}
|
||||
|
||||
/// A wrapper for all LittlevGL common operations on generic objects.
|
||||
/// A wrapper for all LVGL common operations on generic objects.
|
||||
pub trait Widget: NativeObject {
|
||||
type SpecialEvent;
|
||||
type Part: Into<u8>;
|
||||
|
@ -146,8 +146,8 @@ macro_rules! define_object {
|
|||
unsafe {
|
||||
let mut raw = self.raw()?;
|
||||
let obj = raw.as_mut();
|
||||
let user_closure = $crate::mem::Box::new(f)?;
|
||||
obj.user_data = $crate::mem::Box::into_raw(user_closure) as *mut cty::c_void;
|
||||
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(
|
||||
obj,
|
||||
lvgl_sys::lv_event_cb_t::Some($crate::support::event_callback::<Self, F>),
|
||||
|
@ -179,19 +179,19 @@ macro_rules! define_object {
|
|||
bitflags! {
|
||||
pub struct State: u32 {
|
||||
/// Normal, released
|
||||
const DEFAULT = lvgl_sys::LV_STATE_DEFAULT;
|
||||
const DEFAULT = lvgl_sys::LV_STATE_DEFAULT as u32;
|
||||
/// Toggled or checked
|
||||
const CHECKED = lvgl_sys::LV_STATE_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;
|
||||
const FOCUSED = lvgl_sys::LV_STATE_FOCUSED as u32;
|
||||
/// Edit by an encoder
|
||||
const EDITED = lvgl_sys::LV_STATE_EDITED;
|
||||
const EDITED = lvgl_sys::LV_STATE_EDITED as u32;
|
||||
/// Hovered by mouse (not supported now)
|
||||
const HOVERED = lvgl_sys::LV_STATE_HOVERED;
|
||||
const HOVERED = lvgl_sys::LV_STATE_HOVERED as u32;
|
||||
/// Pressed
|
||||
const PRESSED = lvgl_sys::LV_STATE_PRESSED;
|
||||
const PRESSED = lvgl_sys::LV_STATE_PRESSED as u32;
|
||||
/// Disabled or inactive
|
||||
const DISABLED = lvgl_sys::LV_STATE_DISABLED;
|
||||
const DISABLED = lvgl_sys::LV_STATE_DISABLED as u32;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -206,9 +206,9 @@ pub enum Part {
|
|||
All,
|
||||
}
|
||||
|
||||
impl Into<u8> for Part {
|
||||
fn into(self) -> u8 {
|
||||
match self {
|
||||
impl From<Part> for u8 {
|
||||
fn from(self_: Part) -> u8 {
|
||||
match self_ {
|
||||
Part::Main => lvgl_sys::LV_OBJ_PART_MAIN as u8,
|
||||
Part::All => lvgl_sys::LV_OBJ_PART_ALL as u8,
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::mem::Box;
|
||||
use crate::Box;
|
||||
use crate::{Color, LvResult, State};
|
||||
use core::mem;
|
||||
use cstr_core::CStr;
|
||||
|
@ -7,6 +7,7 @@ pub enum Themes {
|
|||
Pretty,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Style {
|
||||
pub(crate) raw: Box<lvgl_sys::lv_style_t>,
|
||||
}
|
||||
|
@ -17,7 +18,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_ptr(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_VALUE_STR
|
||||
(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,
|
||||
);
|
||||
|
@ -31,7 +32,7 @@ impl Default for Style {
|
|||
let raw = unsafe {
|
||||
let mut style = mem::MaybeUninit::<lvgl_sys::lv_style_t>::uninit();
|
||||
lvgl_sys::lv_style_init(style.as_mut_ptr());
|
||||
Box::new(style.assume_init()).unwrap()
|
||||
Box::new(style.assume_init())
|
||||
};
|
||||
Self { raw }
|
||||
}
|
||||
|
@ -39,122 +40,122 @@ impl Default for Style {
|
|||
|
||||
bitflags! {
|
||||
pub struct Opacity: u32 {
|
||||
const OPA_TRANSP = lvgl_sys::LV_OPA_TRANSP;
|
||||
const OPA_0 = lvgl_sys::LV_OPA_0;
|
||||
const OPA_10 = lvgl_sys::LV_OPA_10;
|
||||
const OPA_20 = lvgl_sys::LV_OPA_20;
|
||||
const OPA_30 = lvgl_sys::LV_OPA_30;
|
||||
const OPA_40 = lvgl_sys::LV_OPA_40;
|
||||
const OPA_50 = lvgl_sys::LV_OPA_50;
|
||||
const OPA_60 = lvgl_sys::LV_OPA_60;
|
||||
const OPA_70 = lvgl_sys::LV_OPA_70;
|
||||
const OPA_80 = lvgl_sys::LV_OPA_80;
|
||||
const OPA_90 = lvgl_sys::LV_OPA_90;
|
||||
const OPA_100 = lvgl_sys::LV_OPA_100;
|
||||
const OPA_COVER = lvgl_sys::LV_OPA_COVER;
|
||||
const OPA_TRANSP = lvgl_sys::LV_OPA_TRANSP as u32;
|
||||
const OPA_0 = lvgl_sys::LV_OPA_0 as u32;
|
||||
const OPA_10 = lvgl_sys::LV_OPA_10 as u32;
|
||||
const OPA_20 = lvgl_sys::LV_OPA_20 as u32;
|
||||
const OPA_30 = lvgl_sys::LV_OPA_30 as u32;
|
||||
const OPA_40 = lvgl_sys::LV_OPA_40 as u32;
|
||||
const OPA_50 = lvgl_sys::LV_OPA_50 as u32;
|
||||
const OPA_60 = lvgl_sys::LV_OPA_60 as u32;
|
||||
const OPA_70 = lvgl_sys::LV_OPA_70 as u32;
|
||||
const OPA_80 = lvgl_sys::LV_OPA_80 as u32;
|
||||
const OPA_90 = lvgl_sys::LV_OPA_90 as u32;
|
||||
const OPA_100 = lvgl_sys::LV_OPA_100 as u32;
|
||||
const OPA_COVER = lvgl_sys::LV_OPA_COVER as u32;
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<u8> for Opacity {
|
||||
fn into(self) -> u8 {
|
||||
self.bits as u8
|
||||
impl From<Opacity> for u8 {
|
||||
fn from(self_: Opacity) -> u8 {
|
||||
self_.bits as u8
|
||||
}
|
||||
}
|
||||
|
||||
bitflags! {
|
||||
pub struct StyleProp: u32 {
|
||||
const RADIUS = lvgl_sys::LV_STYLE_RADIUS;
|
||||
const CLIP_CORNER = lvgl_sys::LV_STYLE_CLIP_CORNER;
|
||||
const SIZE = lvgl_sys::LV_STYLE_SIZE;
|
||||
const TRANSFORM_WIDTH = lvgl_sys::LV_STYLE_TRANSFORM_WIDTH;
|
||||
const TRANSFORM_HEIGHT = lvgl_sys::LV_STYLE_TRANSFORM_HEIGHT;
|
||||
const TRANSFORM_ANGLE = lvgl_sys::LV_STYLE_TRANSFORM_ANGLE;
|
||||
const TRANSFORM_ZOOM = lvgl_sys::LV_STYLE_TRANSFORM_ZOOM;
|
||||
const OPA_SCALE = lvgl_sys::LV_STYLE_OPA_SCALE;
|
||||
const PAD_TOP = lvgl_sys::LV_STYLE_PAD_TOP;
|
||||
const PAD_BOTTOM = lvgl_sys::LV_STYLE_PAD_BOTTOM;
|
||||
const PAD_LEFT = lvgl_sys::LV_STYLE_PAD_LEFT;
|
||||
const PAD_RIGHT = lvgl_sys::LV_STYLE_PAD_RIGHT;
|
||||
const PAD_INNER = lvgl_sys::LV_STYLE_PAD_INNER;
|
||||
const MARGIN_TOP = lvgl_sys::LV_STYLE_MARGIN_TOP;
|
||||
const MARGIN_BOTTOM = lvgl_sys::LV_STYLE_MARGIN_BOTTOM;
|
||||
const MARGIN_LEFT = lvgl_sys::LV_STYLE_MARGIN_LEFT;
|
||||
const MARGIN_RIGHT = lvgl_sys::LV_STYLE_MARGIN_RIGHT;
|
||||
const BG_BLEND_MODE = lvgl_sys::LV_STYLE_BG_BLEND_MODE;
|
||||
const BG_MAIN_STOP = lvgl_sys::LV_STYLE_BG_MAIN_STOP;
|
||||
const BG_GRAD_STOP = lvgl_sys::LV_STYLE_BG_GRAD_STOP;
|
||||
const BG_GRAD_DIR = lvgl_sys::LV_STYLE_BG_GRAD_DIR;
|
||||
const BG_COLOR = lvgl_sys::LV_STYLE_BG_COLOR;
|
||||
const BG_GRAD_COLOR = lvgl_sys::LV_STYLE_BG_GRAD_COLOR;
|
||||
const BG_OPA = lvgl_sys::LV_STYLE_BG_OPA;
|
||||
const BORDER_WIDTH = lvgl_sys::LV_STYLE_BORDER_WIDTH;
|
||||
const BORDER_SIDE = lvgl_sys::LV_STYLE_BORDER_SIDE;
|
||||
const BORDER_BLEND_MODE = lvgl_sys::LV_STYLE_BORDER_BLEND_MODE;
|
||||
const BORDER_POST = lvgl_sys::LV_STYLE_BORDER_POST;
|
||||
const BORDER_COLOR = lvgl_sys::LV_STYLE_BORDER_COLOR;
|
||||
const BORDER_OPA = lvgl_sys::LV_STYLE_BORDER_OPA;
|
||||
const OUTLINE_WIDTH = lvgl_sys::LV_STYLE_OUTLINE_WIDTH;
|
||||
const OUTLINE_PAD = lvgl_sys::LV_STYLE_OUTLINE_PAD;
|
||||
const OUTLINE_BLEND_MODE = lvgl_sys::LV_STYLE_OUTLINE_BLEND_MODE;
|
||||
const OUTLINE_COLOR = lvgl_sys::LV_STYLE_OUTLINE_COLOR;
|
||||
const OUTLINE_OPA = lvgl_sys::LV_STYLE_OUTLINE_OPA;
|
||||
const SHADOW_WIDTH = lvgl_sys::LV_STYLE_SHADOW_WIDTH;
|
||||
const SHADOW_OFS_X = lvgl_sys::LV_STYLE_SHADOW_OFS_X;
|
||||
const SHADOW_OFS_Y = lvgl_sys::LV_STYLE_SHADOW_OFS_Y;
|
||||
const SHADOW_SPREAD = lvgl_sys::LV_STYLE_SHADOW_SPREAD;
|
||||
const SHADOW_BLEND_MODE = lvgl_sys::LV_STYLE_SHADOW_BLEND_MODE;
|
||||
const SHADOW_COLOR = lvgl_sys::LV_STYLE_SHADOW_COLOR;
|
||||
const SHADOW_OPA = lvgl_sys::LV_STYLE_SHADOW_OPA;
|
||||
const PATTERN_BLEND_MODE = lvgl_sys::LV_STYLE_PATTERN_BLEND_MODE;
|
||||
const PATTERN_REPEAT = lvgl_sys::LV_STYLE_PATTERN_REPEAT;
|
||||
const PATTERN_RECOLOR = lvgl_sys::LV_STYLE_PATTERN_RECOLOR;
|
||||
const PATTERN_OPA = lvgl_sys::LV_STYLE_PATTERN_OPA;
|
||||
const PATTERN_RECOLOR_OPA = lvgl_sys::LV_STYLE_PATTERN_RECOLOR_OPA;
|
||||
const PATTERN_IMAGE = lvgl_sys::LV_STYLE_PATTERN_IMAGE;
|
||||
const VALUE_LETTER_SPACE = lvgl_sys::LV_STYLE_VALUE_LETTER_SPACE;
|
||||
const VALUE_LINE_SPACE = lvgl_sys::LV_STYLE_VALUE_LINE_SPACE;
|
||||
const VALUE_BLEND_MODE = lvgl_sys::LV_STYLE_VALUE_BLEND_MODE;
|
||||
const VALUE_OFS_X = lvgl_sys::LV_STYLE_VALUE_OFS_X;
|
||||
const VALUE_OFS_Y = lvgl_sys::LV_STYLE_VALUE_OFS_Y;
|
||||
const VALUE_ALIGN = lvgl_sys::LV_STYLE_VALUE_ALIGN;
|
||||
const VALUE_COLOR = lvgl_sys::LV_STYLE_VALUE_COLOR;
|
||||
const VALUE_OPA = lvgl_sys::LV_STYLE_VALUE_OPA;
|
||||
const VALUE_FONT = lvgl_sys::LV_STYLE_VALUE_FONT;
|
||||
const VALUE_STR = lvgl_sys::LV_STYLE_VALUE_STR;
|
||||
const TEXT_LETTER_SPACE = lvgl_sys::LV_STYLE_TEXT_LETTER_SPACE;
|
||||
const TEXT_LINE_SPACE = lvgl_sys::LV_STYLE_TEXT_LINE_SPACE;
|
||||
const TEXT_DECOR = lvgl_sys::LV_STYLE_TEXT_DECOR;
|
||||
const TEXT_BLEND_MODE = lvgl_sys::LV_STYLE_TEXT_BLEND_MODE;
|
||||
const TEXT_COLOR = lvgl_sys::LV_STYLE_TEXT_COLOR;
|
||||
const TEXT_SEL_COLOR = lvgl_sys::LV_STYLE_TEXT_SEL_COLOR;
|
||||
const TEXT_OPA = lvgl_sys::LV_STYLE_TEXT_OPA;
|
||||
const TEXT_FONT = lvgl_sys::LV_STYLE_TEXT_FONT;
|
||||
const LINE_WIDTH = lvgl_sys::LV_STYLE_LINE_WIDTH;
|
||||
const LINE_BLEND_MODE = lvgl_sys::LV_STYLE_LINE_BLEND_MODE;
|
||||
const LINE_DASH_WIDTH = lvgl_sys::LV_STYLE_LINE_DASH_WIDTH;
|
||||
const LINE_DASH_GAP = lvgl_sys::LV_STYLE_LINE_DASH_GAP;
|
||||
const LINE_ROUNDED = lvgl_sys::LV_STYLE_LINE_ROUNDED;
|
||||
const LINE_COLOR = lvgl_sys::LV_STYLE_LINE_COLOR;
|
||||
const LINE_OPA = lvgl_sys::LV_STYLE_LINE_OPA;
|
||||
const IMAGE_BLEND_MODE = lvgl_sys::LV_STYLE_IMAGE_BLEND_MODE;
|
||||
const IMAGE_RECOLOR = lvgl_sys::LV_STYLE_IMAGE_RECOLOR;
|
||||
const IMAGE_OPA = lvgl_sys::LV_STYLE_IMAGE_OPA;
|
||||
const IMAGE_RECOLOR_OPA = lvgl_sys::LV_STYLE_IMAGE_RECOLOR_OPA;
|
||||
const TRANSITION_TIME = lvgl_sys::LV_STYLE_TRANSITION_TIME;
|
||||
const TRANSITION_DELAY = lvgl_sys::LV_STYLE_TRANSITION_DELAY;
|
||||
const TRANSITION_PROP_1 = lvgl_sys::LV_STYLE_TRANSITION_PROP_1;
|
||||
const TRANSITION_PROP_2 = lvgl_sys::LV_STYLE_TRANSITION_PROP_2;
|
||||
const TRANSITION_PROP_3 = lvgl_sys::LV_STYLE_TRANSITION_PROP_3;
|
||||
const TRANSITION_PROP_4 = lvgl_sys::LV_STYLE_TRANSITION_PROP_4;
|
||||
const TRANSITION_PROP_5 = lvgl_sys::LV_STYLE_TRANSITION_PROP_5;
|
||||
const TRANSITION_PROP_6 = lvgl_sys::LV_STYLE_TRANSITION_PROP_6;
|
||||
const TRANSITION_PATH = lvgl_sys::LV_STYLE_TRANSITION_PATH;
|
||||
const SCALE_WIDTH = lvgl_sys::LV_STYLE_SCALE_WIDTH;
|
||||
const SCALE_BORDER_WIDTH = lvgl_sys::LV_STYLE_SCALE_BORDER_WIDTH;
|
||||
const SCALE_END_BORDER_WIDTH = lvgl_sys::LV_STYLE_SCALE_END_BORDER_WIDTH;
|
||||
const SCALE_END_LINE_WIDTH = lvgl_sys::LV_STYLE_SCALE_END_LINE_WIDTH;
|
||||
const SCALE_GRAD_COLOR = lvgl_sys::LV_STYLE_SCALE_GRAD_COLOR;
|
||||
const SCALE_END_COLOR = lvgl_sys::LV_STYLE_SCALE_END_COLOR;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -165,8 +166,8 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_RADIUS | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32))
|
||||
as u16,
|
||||
(lvgl_sys::LV_STYLE_RADIUS as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
}
|
||||
|
@ -177,7 +178,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_CLIP_CORNER
|
||||
(lvgl_sys::LV_STYLE_CLIP_CORNER as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -189,8 +190,8 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_SIZE | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32))
|
||||
as u16,
|
||||
(lvgl_sys::LV_STYLE_SIZE as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
}
|
||||
|
@ -201,7 +202,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_TRANSFORM_WIDTH
|
||||
(lvgl_sys::LV_STYLE_TRANSFORM_WIDTH as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -213,7 +214,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_TRANSFORM_HEIGHT
|
||||
(lvgl_sys::LV_STYLE_TRANSFORM_HEIGHT as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -225,7 +226,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_TRANSFORM_ANGLE
|
||||
(lvgl_sys::LV_STYLE_TRANSFORM_ANGLE as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -237,7 +238,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_TRANSFORM_ZOOM
|
||||
(lvgl_sys::LV_STYLE_TRANSFORM_ZOOM as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -249,7 +250,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_opa(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_OPA_SCALE
|
||||
(lvgl_sys::LV_STYLE_OPA_SCALE as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value.into(),
|
||||
);
|
||||
|
@ -261,8 +262,8 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_PAD_TOP | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32))
|
||||
as u16,
|
||||
(lvgl_sys::LV_STYLE_PAD_TOP as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
}
|
||||
|
@ -273,7 +274,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_PAD_BOTTOM
|
||||
(lvgl_sys::LV_STYLE_PAD_BOTTOM as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -285,7 +286,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_PAD_LEFT
|
||||
(lvgl_sys::LV_STYLE_PAD_LEFT as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -297,7 +298,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_PAD_RIGHT
|
||||
(lvgl_sys::LV_STYLE_PAD_RIGHT as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -309,7 +310,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_PAD_INNER
|
||||
(lvgl_sys::LV_STYLE_PAD_INNER as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -321,7 +322,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_MARGIN_TOP
|
||||
(lvgl_sys::LV_STYLE_MARGIN_TOP as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -333,7 +334,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_MARGIN_BOTTOM
|
||||
(lvgl_sys::LV_STYLE_MARGIN_BOTTOM as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -345,7 +346,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_MARGIN_LEFT
|
||||
(lvgl_sys::LV_STYLE_MARGIN_LEFT as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -357,7 +358,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_MARGIN_RIGHT
|
||||
(lvgl_sys::LV_STYLE_MARGIN_RIGHT as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -369,7 +370,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_BG_BLEND_MODE
|
||||
(lvgl_sys::LV_STYLE_BG_BLEND_MODE as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -381,7 +382,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_BG_MAIN_STOP
|
||||
(lvgl_sys::LV_STYLE_BG_MAIN_STOP as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -393,7 +394,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_BG_GRAD_STOP
|
||||
(lvgl_sys::LV_STYLE_BG_GRAD_STOP as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -405,7 +406,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_BG_GRAD_DIR
|
||||
(lvgl_sys::LV_STYLE_BG_GRAD_DIR as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -417,7 +418,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_color(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_BG_COLOR
|
||||
(lvgl_sys::LV_STYLE_BG_COLOR as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value.raw,
|
||||
);
|
||||
|
@ -429,7 +430,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_color(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_BG_GRAD_COLOR
|
||||
(lvgl_sys::LV_STYLE_BG_GRAD_COLOR as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value.raw,
|
||||
);
|
||||
|
@ -441,8 +442,8 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_opa(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_BG_OPA | (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32))
|
||||
as u16,
|
||||
(lvgl_sys::LV_STYLE_BG_OPA as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value.into(),
|
||||
);
|
||||
}
|
||||
|
@ -453,7 +454,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_BORDER_WIDTH
|
||||
(lvgl_sys::LV_STYLE_BORDER_WIDTH as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -465,7 +466,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_BORDER_SIDE
|
||||
(lvgl_sys::LV_STYLE_BORDER_SIDE as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -477,7 +478,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_BORDER_BLEND_MODE
|
||||
(lvgl_sys::LV_STYLE_BORDER_BLEND_MODE as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -489,7 +490,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_BORDER_POST
|
||||
(lvgl_sys::LV_STYLE_BORDER_POST as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -501,7 +502,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_color(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_BORDER_COLOR
|
||||
(lvgl_sys::LV_STYLE_BORDER_COLOR as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value.raw,
|
||||
);
|
||||
|
@ -513,7 +514,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_opa(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_BORDER_OPA
|
||||
(lvgl_sys::LV_STYLE_BORDER_OPA as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value.into(),
|
||||
);
|
||||
|
@ -525,7 +526,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_OUTLINE_WIDTH
|
||||
(lvgl_sys::LV_STYLE_OUTLINE_WIDTH as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -537,7 +538,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_OUTLINE_PAD
|
||||
(lvgl_sys::LV_STYLE_OUTLINE_PAD as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -549,7 +550,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_OUTLINE_BLEND_MODE
|
||||
(lvgl_sys::LV_STYLE_OUTLINE_BLEND_MODE as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -561,7 +562,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_color(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_OUTLINE_COLOR
|
||||
(lvgl_sys::LV_STYLE_OUTLINE_COLOR as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value.raw,
|
||||
);
|
||||
|
@ -573,7 +574,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_opa(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_OUTLINE_OPA
|
||||
(lvgl_sys::LV_STYLE_OUTLINE_OPA as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value.into(),
|
||||
);
|
||||
|
@ -585,7 +586,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_SHADOW_WIDTH
|
||||
(lvgl_sys::LV_STYLE_SHADOW_WIDTH as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -597,7 +598,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_SHADOW_OFS_X
|
||||
(lvgl_sys::LV_STYLE_SHADOW_OFS_X as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -609,7 +610,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_SHADOW_OFS_Y
|
||||
(lvgl_sys::LV_STYLE_SHADOW_OFS_Y as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -621,7 +622,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_SHADOW_SPREAD
|
||||
(lvgl_sys::LV_STYLE_SHADOW_SPREAD as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -633,7 +634,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_SHADOW_BLEND_MODE
|
||||
(lvgl_sys::LV_STYLE_SHADOW_BLEND_MODE as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -645,7 +646,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_color(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_SHADOW_COLOR
|
||||
(lvgl_sys::LV_STYLE_SHADOW_COLOR as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value.raw,
|
||||
);
|
||||
|
@ -657,7 +658,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_opa(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_SHADOW_OPA
|
||||
(lvgl_sys::LV_STYLE_SHADOW_OPA as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value.into(),
|
||||
);
|
||||
|
@ -669,7 +670,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_PATTERN_REPEAT
|
||||
(lvgl_sys::LV_STYLE_PATTERN_REPEAT as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -681,7 +682,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_PATTERN_BLEND_MODE
|
||||
(lvgl_sys::LV_STYLE_PATTERN_BLEND_MODE as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -693,7 +694,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_color(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_PATTERN_RECOLOR
|
||||
(lvgl_sys::LV_STYLE_PATTERN_RECOLOR as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value.raw,
|
||||
);
|
||||
|
@ -705,7 +706,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_opa(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_PATTERN_OPA
|
||||
(lvgl_sys::LV_STYLE_PATTERN_OPA as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value.into(),
|
||||
);
|
||||
|
@ -717,7 +718,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_opa(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_PATTERN_RECOLOR_OPA
|
||||
(lvgl_sys::LV_STYLE_PATTERN_RECOLOR_OPA as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value.into(),
|
||||
);
|
||||
|
@ -729,7 +730,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_VALUE_LETTER_SPACE
|
||||
(lvgl_sys::LV_STYLE_VALUE_LETTER_SPACE as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -741,7 +742,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_VALUE_LINE_SPACE
|
||||
(lvgl_sys::LV_STYLE_VALUE_LINE_SPACE as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -753,7 +754,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_VALUE_BLEND_MODE
|
||||
(lvgl_sys::LV_STYLE_VALUE_BLEND_MODE as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -765,7 +766,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_VALUE_OFS_X
|
||||
(lvgl_sys::LV_STYLE_VALUE_OFS_X as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -777,7 +778,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_VALUE_OFS_Y
|
||||
(lvgl_sys::LV_STYLE_VALUE_OFS_Y as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -789,7 +790,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_VALUE_ALIGN
|
||||
(lvgl_sys::LV_STYLE_VALUE_ALIGN as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -801,7 +802,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_color(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_VALUE_COLOR
|
||||
(lvgl_sys::LV_STYLE_VALUE_COLOR as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value.raw,
|
||||
);
|
||||
|
@ -813,7 +814,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_opa(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_VALUE_OPA
|
||||
(lvgl_sys::LV_STYLE_VALUE_OPA as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value.into(),
|
||||
);
|
||||
|
@ -825,7 +826,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_TEXT_LETTER_SPACE
|
||||
(lvgl_sys::LV_STYLE_TEXT_LETTER_SPACE as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -837,7 +838,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_TEXT_LINE_SPACE
|
||||
(lvgl_sys::LV_STYLE_TEXT_LINE_SPACE as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -849,7 +850,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_TEXT_DECOR
|
||||
(lvgl_sys::LV_STYLE_TEXT_DECOR as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -861,7 +862,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_TEXT_BLEND_MODE
|
||||
(lvgl_sys::LV_STYLE_TEXT_BLEND_MODE as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -873,7 +874,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_color(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_TEXT_COLOR
|
||||
(lvgl_sys::LV_STYLE_TEXT_COLOR as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value.raw,
|
||||
);
|
||||
|
@ -885,7 +886,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_color(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_TEXT_SEL_COLOR
|
||||
(lvgl_sys::LV_STYLE_TEXT_SEL_COLOR as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value.raw,
|
||||
);
|
||||
|
@ -897,7 +898,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_opa(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_TEXT_OPA
|
||||
(lvgl_sys::LV_STYLE_TEXT_OPA as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value.into(),
|
||||
);
|
||||
|
@ -909,7 +910,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_LINE_WIDTH
|
||||
(lvgl_sys::LV_STYLE_LINE_WIDTH as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -921,7 +922,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_LINE_BLEND_MODE
|
||||
(lvgl_sys::LV_STYLE_LINE_BLEND_MODE as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -933,7 +934,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_LINE_DASH_WIDTH
|
||||
(lvgl_sys::LV_STYLE_LINE_DASH_WIDTH as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -945,7 +946,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_LINE_DASH_GAP
|
||||
(lvgl_sys::LV_STYLE_LINE_DASH_GAP as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -957,7 +958,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_LINE_ROUNDED
|
||||
(lvgl_sys::LV_STYLE_LINE_ROUNDED as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -969,7 +970,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_color(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_LINE_COLOR
|
||||
(lvgl_sys::LV_STYLE_LINE_COLOR as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value.raw,
|
||||
);
|
||||
|
@ -981,7 +982,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_opa(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_LINE_OPA
|
||||
(lvgl_sys::LV_STYLE_LINE_OPA as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value.into(),
|
||||
);
|
||||
|
@ -993,7 +994,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_IMAGE_BLEND_MODE
|
||||
(lvgl_sys::LV_STYLE_IMAGE_BLEND_MODE as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -1005,7 +1006,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_color(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_IMAGE_RECOLOR
|
||||
(lvgl_sys::LV_STYLE_IMAGE_RECOLOR as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value.raw,
|
||||
);
|
||||
|
@ -1017,7 +1018,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_opa(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_IMAGE_OPA
|
||||
(lvgl_sys::LV_STYLE_IMAGE_OPA as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value.into(),
|
||||
);
|
||||
|
@ -1029,7 +1030,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_opa(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_IMAGE_RECOLOR_OPA
|
||||
(lvgl_sys::LV_STYLE_IMAGE_RECOLOR_OPA as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value.into(),
|
||||
);
|
||||
|
@ -1041,7 +1042,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_TRANSITION_TIME
|
||||
(lvgl_sys::LV_STYLE_TRANSITION_TIME as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -1053,7 +1054,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_TRANSITION_DELAY
|
||||
(lvgl_sys::LV_STYLE_TRANSITION_DELAY as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -1065,7 +1066,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_TRANSITION_PROP_1
|
||||
(lvgl_sys::LV_STYLE_TRANSITION_PROP_1 as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -1077,7 +1078,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_TRANSITION_PROP_2
|
||||
(lvgl_sys::LV_STYLE_TRANSITION_PROP_2 as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -1089,7 +1090,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_TRANSITION_PROP_3
|
||||
(lvgl_sys::LV_STYLE_TRANSITION_PROP_3 as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -1101,7 +1102,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_TRANSITION_PROP_4
|
||||
(lvgl_sys::LV_STYLE_TRANSITION_PROP_4 as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -1113,7 +1114,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_TRANSITION_PROP_5
|
||||
(lvgl_sys::LV_STYLE_TRANSITION_PROP_5 as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -1125,7 +1126,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_TRANSITION_PROP_6
|
||||
(lvgl_sys::LV_STYLE_TRANSITION_PROP_6 as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -1137,7 +1138,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_SCALE_WIDTH
|
||||
(lvgl_sys::LV_STYLE_SCALE_WIDTH as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -1149,7 +1150,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_SCALE_BORDER_WIDTH
|
||||
(lvgl_sys::LV_STYLE_SCALE_BORDER_WIDTH as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -1161,7 +1162,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_SCALE_END_BORDER_WIDTH
|
||||
(lvgl_sys::LV_STYLE_SCALE_END_BORDER_WIDTH as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -1173,7 +1174,7 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_int(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_SCALE_END_LINE_WIDTH
|
||||
(lvgl_sys::LV_STYLE_SCALE_END_LINE_WIDTH as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
value,
|
||||
);
|
||||
|
@ -1185,8 +1186,8 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_color(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_SCALE_GRAD_COLOR
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
(lvgl_sys::LV_STYLE_SCALE_GRAD_COLOR as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS)) as u16,
|
||||
value.raw,
|
||||
);
|
||||
}
|
||||
|
@ -1197,8 +1198,8 @@ impl Style {
|
|||
unsafe {
|
||||
lvgl_sys::_lv_style_set_color(
|
||||
self.raw.as_mut(),
|
||||
(lvgl_sys::LV_STYLE_SCALE_END_COLOR
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS as u32)) as u16,
|
||||
(lvgl_sys::LV_STYLE_SCALE_END_COLOR as u32
|
||||
| (native_state << lvgl_sys::LV_STYLE_STATE_POS)) as u16,
|
||||
value.raw,
|
||||
);
|
||||
}
|
||||
|
|
114
lvgl/src/mem.rs
114
lvgl/src/mem.rs
|
@ -1,13 +1,17 @@
|
|||
use crate::{LvError, LvResult};
|
||||
use core::mem;
|
||||
use core::ops::{Deref, DerefMut};
|
||||
use core::ptr::NonNull;
|
||||
|
||||
/// Places `T` into LVGL memory.
|
||||
/// Places a sized `T` into LVGL memory.
|
||||
///
|
||||
/// This is useful for cases when we need to allocate memory on Rust side
|
||||
/// and handover the management of that memory to LVGL. May also be used in cases we
|
||||
/// want to use dynamic memory in the Rust side.
|
||||
pub(crate) struct Box<T>(NonNull<T>);
|
||||
|
||||
impl<T> Box<T> {
|
||||
pub fn new(inner: T) -> LvResult<Box<T>> {
|
||||
/// Allocate memory using LVGL memory API and place `T` in the LVGL tracked memory.
|
||||
pub fn new(value: T) -> Box<T> {
|
||||
let size = mem::size_of::<T>();
|
||||
let inner = unsafe {
|
||||
let ptr = lvgl_sys::lv_mem_alloc(size as lvgl_sys::size_t) as *mut T;
|
||||
|
@ -19,17 +23,16 @@ impl<T> Box<T> {
|
|||
"Memory address not aligned!"
|
||||
);
|
||||
|
||||
match NonNull::new(ptr) {
|
||||
Some(v) => {
|
||||
// Move `T` to LVGL managed memory
|
||||
// It will panic if LVGL memory is not aligned
|
||||
ptr.write(inner);
|
||||
Ok(v)
|
||||
}
|
||||
None => Err(LvError::LvOOMemory),
|
||||
}
|
||||
NonNull::new(ptr)
|
||||
.map(|p| {
|
||||
p.as_ptr().write(value);
|
||||
p
|
||||
})
|
||||
.unwrap_or_else(|| {
|
||||
panic!("Could not allocate memory {} bytes", size);
|
||||
})
|
||||
};
|
||||
Ok(Box(inner?))
|
||||
Box(inner)
|
||||
}
|
||||
|
||||
pub fn into_raw(self) -> *mut T {
|
||||
|
@ -66,35 +69,30 @@ impl<T> AsMut<T> for Box<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T: Clone> Clone for Box<T> {
|
||||
fn clone(&self) -> Self {
|
||||
unsafe { Self::new(self.0.as_ref().clone()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use core::mem::MaybeUninit;
|
||||
use std::sync::Once;
|
||||
|
||||
static INIT_LVGL: Once = Once::new();
|
||||
|
||||
fn init() {
|
||||
INIT_LVGL.call_once(|| {
|
||||
unsafe {
|
||||
lvgl_sys::lv_init();
|
||||
};
|
||||
});
|
||||
}
|
||||
use std::vec::Vec;
|
||||
|
||||
#[test]
|
||||
fn place_value_in_lv_mem() {
|
||||
init();
|
||||
crate::lvgl_init();
|
||||
|
||||
let v = Box::new(5).unwrap();
|
||||
let v = Box::new(5);
|
||||
drop(v);
|
||||
let v = Box::new(10).unwrap();
|
||||
let v = Box::new(10);
|
||||
drop(v);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn place_complex_value_in_lv_mem() {
|
||||
init();
|
||||
crate::lvgl_init();
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
|
@ -105,6 +103,9 @@ mod test {
|
|||
disp: i32,
|
||||
}
|
||||
|
||||
let initial_mem_info = mem_info();
|
||||
|
||||
let mut keep = Vec::new();
|
||||
for i in 0..100 {
|
||||
let p = Point {
|
||||
x: i,
|
||||
|
@ -114,31 +115,60 @@ mod test {
|
|||
};
|
||||
|
||||
println!("{:?}", p);
|
||||
let mut b = Box::new(p).unwrap_or_else(|_| {
|
||||
print_mem_info();
|
||||
panic!("OOM");
|
||||
});
|
||||
let mut b = Box::new(p);
|
||||
|
||||
println!("memory address is {:p}", b.as_mut());
|
||||
|
||||
let point = b.as_mut();
|
||||
if point.x != i {
|
||||
print_mem_info();
|
||||
|
||||
println!("{:?}", point);
|
||||
}
|
||||
assert_eq!(point.x, i);
|
||||
|
||||
let info = mem_info();
|
||||
println!("mem info: {:?}", &info);
|
||||
keep.push(b);
|
||||
}
|
||||
drop(keep);
|
||||
|
||||
unsafe {
|
||||
lvgl_sys::lv_mem_defrag();
|
||||
}
|
||||
|
||||
let final_info = mem_info();
|
||||
println!("mem info: {:?}", &final_info);
|
||||
|
||||
// If this fails, we are leaking memory! BOOM! \o/
|
||||
assert_eq!(initial_mem_info.free_size, final_info.free_size)
|
||||
}
|
||||
|
||||
fn print_mem_info() {
|
||||
let mut info = MaybeUninit::uninit();
|
||||
#[test]
|
||||
fn clone_object_in_lv_mem() {
|
||||
crate::lvgl_init();
|
||||
|
||||
let v1 = Box::new(5);
|
||||
let v2 = v1.clone();
|
||||
|
||||
// Ensure that the two objects have identical values.
|
||||
assert_eq!(*v1, *v2);
|
||||
// They should have different memory addresses, however.
|
||||
assert_ne!(v1.into_raw() as usize, v2.into_raw() as usize);
|
||||
}
|
||||
|
||||
fn mem_info() -> lvgl_sys::lv_mem_monitor_t {
|
||||
let mut info = lvgl_sys::lv_mem_monitor_t {
|
||||
total_size: 0,
|
||||
free_cnt: 0,
|
||||
free_size: 0,
|
||||
free_biggest_size: 0,
|
||||
used_cnt: 0,
|
||||
max_used: 0,
|
||||
used_pct: 0,
|
||||
frag_pct: 0,
|
||||
};
|
||||
unsafe {
|
||||
lvgl_sys::lv_mem_monitor(info.as_mut_ptr());
|
||||
}
|
||||
if !info.as_ptr().is_null() {
|
||||
let info = unsafe { info.assume_init() };
|
||||
println!("mem info: {:?}", info);
|
||||
lvgl_sys::lv_mem_monitor(&mut info as *mut _);
|
||||
}
|
||||
info
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,21 +29,15 @@ impl Color {
|
|||
}
|
||||
|
||||
pub fn r(&self) -> u8 {
|
||||
unsafe {
|
||||
lvgl_sys::_LV_COLOR_GET_R(self.raw) as u8
|
||||
}
|
||||
unsafe { lvgl_sys::_LV_COLOR_GET_R(self.raw) as u8 }
|
||||
}
|
||||
|
||||
pub fn g(&self) -> u8 {
|
||||
unsafe {
|
||||
lvgl_sys::_LV_COLOR_GET_G(self.raw) as u8
|
||||
}
|
||||
unsafe { lvgl_sys::_LV_COLOR_GET_G(self.raw) as u8 }
|
||||
}
|
||||
|
||||
pub fn b(&self) -> u8 {
|
||||
unsafe {
|
||||
lvgl_sys::_LV_COLOR_GET_B(self.raw) as u8
|
||||
}
|
||||
unsafe { lvgl_sys::_LV_COLOR_GET_B(self.raw) as u8 }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -71,7 +65,7 @@ impl From<Color> for Rgb565 {
|
|||
}
|
||||
}
|
||||
|
||||
/// Events are triggered in LittlevGL when something happens which might be interesting to
|
||||
/// Events are triggered in LVGL when something happens which might be interesting to
|
||||
/// the user, e.g. if an object:
|
||||
/// - is clicked
|
||||
/// - is dragged
|
||||
|
@ -118,23 +112,25 @@ impl<S> TryFrom<lvgl_sys::lv_event_t> for Event<S> {
|
|||
type Error = ();
|
||||
|
||||
fn try_from(value: u8) -> Result<Self, Self::Error> {
|
||||
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;
|
||||
|
||||
match value as u32 {
|
||||
lvgl_sys::LV_EVENT_PRESSED => Ok(Event::Pressed),
|
||||
lvgl_sys::LV_EVENT_PRESSING => Ok(Event::Pressing),
|
||||
lvgl_sys::LV_EVENT_PRESS_LOST => Ok(Event::PressLost),
|
||||
lvgl_sys::LV_EVENT_SHORT_CLICKED => Ok(Event::ShortClicked),
|
||||
lvgl_sys::LV_EVENT_CLICKED => Ok(Event::Clicked),
|
||||
lvgl_sys::LV_EVENT_LONG_PRESSED => Ok(Event::LongPressed),
|
||||
lvgl_sys::LV_EVENT_LONG_PRESSED_REPEAT => Ok(Event::LongPressedRepeat),
|
||||
lvgl_sys::LV_EVENT_RELEASED => Ok(Event::Released),
|
||||
LV_EVENT_PRESSED => Ok(Event::Pressed),
|
||||
LV_EVENT_PRESSING => Ok(Event::Pressing),
|
||||
LV_EVENT_PRESS_LOST => Ok(Event::PressLost),
|
||||
LV_EVENT_SHORT_CLICKED => Ok(Event::ShortClicked),
|
||||
LV_EVENT_CLICKED => Ok(Event::Clicked),
|
||||
LV_EVENT_LONG_PRESSED => Ok(Event::LongPressed),
|
||||
LV_EVENT_LONG_PRESSED_REPEAT => Ok(Event::LongPressedRepeat),
|
||||
LV_EVENT_RELEASED => Ok(Event::Released),
|
||||
_ => Err(()),
|
||||
// _ => {
|
||||
// if let Ok(special_event_type) = S::try_from(value) {
|
||||
// Ok(Event::Special(special_event_type))
|
||||
// } else {
|
||||
// Err(())
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -207,9 +203,9 @@ pub enum Align {
|
|||
OutRightBottom,
|
||||
}
|
||||
|
||||
impl Into<u8> for Align {
|
||||
fn into(self) -> u8 {
|
||||
let native = match self {
|
||||
impl From<Align> for u8 {
|
||||
fn from(self_: Align) -> u8 {
|
||||
let native = match self_ {
|
||||
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,
|
||||
|
@ -250,11 +246,9 @@ impl From<Animation> for lvgl_sys::lv_anim_enable_t {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use lvgl_sys;
|
||||
|
||||
#[test]
|
||||
fn color_properties_accessible() {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::mem::Box;
|
||||
use crate::Box;
|
||||
use crate::{Color, Event, LvError, LvResult, Obj, Widget};
|
||||
use core::marker::PhantomData;
|
||||
use core::mem::MaybeUninit;
|
||||
|
@ -6,11 +6,11 @@ use core::ptr;
|
|||
use core::ptr::NonNull;
|
||||
use core::sync::atomic::{AtomicBool, Ordering};
|
||||
use core::time::Duration;
|
||||
use embedded_graphics::pixelcolor::PixelColor;
|
||||
use embedded_graphics::draw_target::DrawTarget;
|
||||
use embedded_graphics::prelude::*;
|
||||
use embedded_graphics::{drawable, DrawTarget};
|
||||
use embedded_graphics::{pixelcolor::PixelColor, Pixel};
|
||||
|
||||
// There can only be a single reference to LittlevGL library.
|
||||
// There can only be a single reference to LVGL library.
|
||||
static LVGL_IN_USE: AtomicBool = AtomicBool::new(false);
|
||||
|
||||
// TODO: Make this an external configuration
|
||||
|
@ -20,33 +20,34 @@ pub(crate) const BUF_SIZE: usize = lvgl_sys::LV_HOR_RES_MAX as usize * REFRESH_B
|
|||
|
||||
pub struct UI<T, C>
|
||||
where
|
||||
T: DrawTarget<C>,
|
||||
T: DrawTarget<Color = C>,
|
||||
C: PixelColor + From<Color>,
|
||||
{
|
||||
// LittlevGL is not thread-safe by default.
|
||||
// LVGL is not thread-safe by default.
|
||||
_not_sync: PhantomData<*mut ()>,
|
||||
// Later we can add possibility to have multiple displays by using `heapless::Vec`
|
||||
display_data: Option<DisplayUserData<T, C>>,
|
||||
}
|
||||
|
||||
// LittlevGL does not use thread locals.
|
||||
// LVGL does not use thread locals.
|
||||
unsafe impl<T, C> Send for UI<T, C>
|
||||
where
|
||||
T: DrawTarget<C>,
|
||||
T: DrawTarget<Color = C>,
|
||||
C: PixelColor + From<Color>,
|
||||
{
|
||||
}
|
||||
|
||||
impl<T, C> UI<T, C>
|
||||
where
|
||||
T: DrawTarget<C>,
|
||||
T: DrawTarget<Color = C>,
|
||||
C: PixelColor + From<Color>,
|
||||
{
|
||||
pub fn init() -> LvResult<Self> {
|
||||
if !LVGL_IN_USE.compare_and_swap(false, true, Ordering::SeqCst) {
|
||||
unsafe {
|
||||
lvgl_sys::lv_init();
|
||||
}
|
||||
if LVGL_IN_USE
|
||||
.compare_exchange(false, true, Ordering::Relaxed, Ordering::Relaxed)
|
||||
.is_ok()
|
||||
{
|
||||
crate::lvgl_init();
|
||||
Ok(Self {
|
||||
_not_sync: PhantomData,
|
||||
display_data: None,
|
||||
|
@ -72,15 +73,15 @@ where
|
|||
// Initialize the display buffer
|
||||
lvgl_sys::lv_disp_buf_init(
|
||||
disp_buf.as_mut_ptr(),
|
||||
Box::into_raw(Box::new(refresh_buffer1)?) as *mut cty::c_void,
|
||||
Box::into_raw(Box::new(refresh_buffer2)?) as *mut cty::c_void,
|
||||
Box::into_raw(Box::new(refresh_buffer1)) as *mut cty::c_void,
|
||||
Box::into_raw(Box::new(refresh_buffer2)) as *mut cty::c_void,
|
||||
lvgl_sys::LV_HOR_RES_MAX * REFRESH_BUFFER_LEN as u32,
|
||||
);
|
||||
// Basic initialization of the display driver
|
||||
lvgl_sys::lv_disp_drv_init(disp_drv.as_mut_ptr());
|
||||
let mut disp_drv = Box::new(disp_drv.assume_init())?;
|
||||
let mut disp_drv = Box::new(disp_drv.assume_init());
|
||||
// Assign the buffer to the display
|
||||
disp_drv.buffer = Box::into_raw(Box::new(disp_buf.assume_init())?);
|
||||
disp_drv.buffer = Box::into_raw(Box::new(disp_buf.assume_init()));
|
||||
// Set your driver function
|
||||
disp_drv.flush_cb = Some(display_callback_wrapper::<T, C>);
|
||||
disp_drv.user_data = &mut self.display_data as *mut _ as *mut cty::c_void;
|
||||
|
@ -134,7 +135,7 @@ where
|
|||
|
||||
pub(crate) struct DisplayUserData<T, C>
|
||||
where
|
||||
T: DrawTarget<C>,
|
||||
T: DrawTarget<Color = C>,
|
||||
C: PixelColor + From<Color>,
|
||||
{
|
||||
display: T,
|
||||
|
@ -146,7 +147,7 @@ unsafe extern "C" fn display_callback_wrapper<T, C>(
|
|||
area: *const lvgl_sys::lv_area_t,
|
||||
color_p: *mut lvgl_sys::lv_color_t,
|
||||
) where
|
||||
T: DrawTarget<C>,
|
||||
T: DrawTarget<Color = C>,
|
||||
C: PixelColor + From<Color>,
|
||||
{
|
||||
// In the `std` world we would make sure to capture panics here and make them not escape across
|
||||
|
@ -163,12 +164,12 @@ unsafe extern "C" fn display_callback_wrapper<T, C>(
|
|||
// TODO: Can we do anything when there is a error while flushing?
|
||||
let _ = display_flush(&mut user_data.display, (x1, x2), (y1, y2), color_p);
|
||||
}
|
||||
// Indicate to LittlevGL that we are ready with the flushing
|
||||
// Indicate to LVGL that we are ready with the flushing
|
||||
lvgl_sys::lv_disp_flush_ready(disp_drv);
|
||||
}
|
||||
|
||||
// We separate this display flush function to reduce the amount of unsafe code we need to write.
|
||||
// This also provides a good separation of concerns, what is necessary from LittlevGL to work and
|
||||
// This also provides a good separation of concerns, what is necessary from LVGL to work and
|
||||
// what is the lvgl-rs wrapper responsibility.
|
||||
fn display_flush<T, C>(
|
||||
display: &mut T,
|
||||
|
@ -177,7 +178,7 @@ fn display_flush<T, C>(
|
|||
color_p: *mut lvgl_sys::lv_color_t,
|
||||
) -> Result<(), T::Error>
|
||||
where
|
||||
T: DrawTarget<C>,
|
||||
T: DrawTarget<Color = C>,
|
||||
C: PixelColor + From<Color>,
|
||||
{
|
||||
let ys = y1..=y2;
|
||||
|
@ -186,17 +187,14 @@ where
|
|||
|
||||
// We use iterators here to ensure that the Rust compiler can apply all possible
|
||||
// optimizations at compile time.
|
||||
let pixels = ys
|
||||
.enumerate()
|
||||
.map(|(iy, y)| {
|
||||
xs.clone().map(move |(ix, x)| {
|
||||
let color_len = x_len * iy + ix;
|
||||
let lv_color = unsafe { *color_p.add(color_len) };
|
||||
let raw_color = Color::from_raw(lv_color);
|
||||
drawable::Pixel(Point::new(x as i32, y as i32), raw_color.into())
|
||||
})
|
||||
let pixels = ys.enumerate().flat_map(|(iy, y)| {
|
||||
xs.clone().map(move |(ix, x)| {
|
||||
let color_len = x_len * iy + ix;
|
||||
let lv_color = unsafe { *color_p.add(color_len) };
|
||||
let raw_color = Color::from_raw(lv_color);
|
||||
Pixel(Point::new(x as i32, y as i32), raw_color.into())
|
||||
})
|
||||
.flatten();
|
||||
});
|
||||
|
||||
Ok(display.draw_iter(pixels)?)
|
||||
display.draw_iter(pixels)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue