Compare commits
26 commits
Author | SHA1 | Date | |
---|---|---|---|
|
601a87d513 | ||
|
faa3a19215 | ||
|
029d230cab | ||
|
ade4ae5a2d | ||
|
37950d6e2e | ||
|
763b78e45d | ||
0a5b5a0416 | |||
a5c27b58ae | |||
|
cbbdc7e750 | ||
56cb470dc8 | |||
043bb52881 | |||
a5ffa62013 | |||
348963b80d | |||
|
3791b211b8 | ||
d699101afe | |||
f60d8d999b | |||
ab8b8ae05f | |||
9b9ea48920 | |||
7f5bec7366 | |||
3f226e94a4 | |||
bcd771df47 | |||
da8bae1f55 | |||
|
d3a2a9eff3 | ||
|
65b68e0f7c | ||
81cb1bee4c | |||
8fe36f6102 |
22 changed files with 1357 additions and 425 deletions
|
@ -1,7 +1,6 @@
|
|||
[workspace]
|
||||
members = [
|
||||
"lvgl",
|
||||
"lvgl-sys",
|
||||
"lvgl-codegen",
|
||||
"examples"
|
||||
"lvgl-sys",
|
||||
]
|
||||
|
|
46
README.md
46
README.md
|
@ -1,24 +1,41 @@
|
|||
<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>
|
||||
|
||||
---
|
||||
|
||||
![Rust bindings usage demo code.](demo.png)
|
||||
|
||||
## System Build Dependencies
|
||||
|
||||
In order to build the `lvgl` project you will need the following system dependencies to be installed:
|
||||
|
||||
```
|
||||
$ sudo apt install build-essential llvm clang
|
||||
```
|
||||
|
||||
If you want to build the examples, then you will need to install SDL2 as well.
|
||||
|
||||
```
|
||||
$ sudo apt install libsdl2-dev
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Edit your `Cargo.toml` file dependencies with:
|
||||
|
@ -28,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
|
||||
|
@ -44,9 +61,22 @@ 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:
|
||||
|
||||
```shell
|
||||
$ brew install sdl2
|
||||
```
|
||||
|
||||
[This project contains examples that can run in a desktop simulator.](./examples)
|
||||
|
||||
First, make sure to pull `lvgl-rs` submodules:
|
||||
|
@ -58,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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "lvgl-codegen"
|
||||
version = "0.4.0"
|
||||
version = "0.5.2"
|
||||
description = "Code generation based on LVGL source code"
|
||||
authors = ["Rafael Caricio <crates.lvgl@caric.io>"]
|
||||
readme = "README.md"
|
||||
|
@ -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,12 +1,11 @@
|
|||
use inflector::cases::pascalcase::to_pascal_case;
|
||||
use lazy_static::lazy_static;
|
||||
use proc_macro2::{Ident, TokenStream};
|
||||
use quote::format_ident;
|
||||
use quote::quote;
|
||||
use quote::{format_ident, ToTokens};
|
||||
use regex::Regex;
|
||||
use std::collections::HashMap;
|
||||
use std::error::Error;
|
||||
use syn::export::ToTokens;
|
||||
use syn::{FnArg, ForeignItem, ForeignItemFn, Item, ReturnType};
|
||||
|
||||
type CGResult<T> = Result<T, Box<dyn Error>>;
|
||||
|
@ -304,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,7 +1,7 @@
|
|||
[package]
|
||||
name = "lvgl-sys"
|
||||
description = "Raw bindings to the LittlevGL C library."
|
||||
version = "0.4.0"
|
||||
description = "Raw bindings to the LVGL C library."
|
||||
version = "0.5.2"
|
||||
authors = ["Rafael Caricio <crates.lvgl-sys@caric.io>"]
|
||||
edition = "2018"
|
||||
license = "MIT"
|
||||
|
@ -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,36 +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 raw_path = env::var(CONFIG_NAME).unwrap_or_else(|_| {
|
||||
panic!(
|
||||
"The environment variable {} is required to be defined",
|
||||
CONFIG_NAME
|
||||
);
|
||||
});
|
||||
let conf_path = PathBuf::from(raw_path);
|
||||
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.join("include")
|
||||
}
|
||||
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!(
|
||||
"Directory referenced by {} needs to exist",
|
||||
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!(
|
||||
"Directory referenced by {} needs to contain a file called lv_conf.h",
|
||||
panic!(
|
||||
"Directory {} referenced by {} needs to contain a file called lv_conf.h",
|
||||
conf_path.to_string_lossy(),
|
||||
CONFIG_NAME
|
||||
));
|
||||
);
|
||||
}
|
||||
|
||||
println!(
|
||||
|
@ -62,24 +76,58 @@ fn main() {
|
|||
.include(&lv_config_dir)
|
||||
.compile("lvgl");
|
||||
|
||||
let cc_args = [
|
||||
let mut cc_args = vec![
|
||||
"-DLV_CONF_INCLUDE_SIMPLE=1",
|
||||
"-I",
|
||||
lv_config_dir.to_str().unwrap(),
|
||||
"-I",
|
||||
vendor.to_str().unwrap(),
|
||||
"-fvisibility=default",
|
||||
];
|
||||
|
||||
// Set correct target triple for bindgen when cross-compiling
|
||||
let target = env::var("TARGET").expect("Cargo build scripts always have TARGET");
|
||||
let host = env::var("HOST").expect("Cargo build scripts always have HOST");
|
||||
if target != host {
|
||||
cc_args.push("-target");
|
||||
cc_args.push(target.as_str());
|
||||
}
|
||||
|
||||
let mut additional_args = Vec::new();
|
||||
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("-I".to_string());
|
||||
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
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
|
||||
bindgen::Builder::default()
|
||||
let bindings = bindgen::Builder::default()
|
||||
.header(shims_dir.join("lvgl_sys.h").to_str().unwrap())
|
||||
.generate_comments(false)
|
||||
.layout_tests(false)
|
||||
.use_core()
|
||||
.rustfmt_bindings(true)
|
||||
.ctypes_prefix("cty")
|
||||
.clang_args(&cc_args)
|
||||
.clang_args(&additional_args)
|
||||
.generate()
|
||||
.expect("Unable to generate bindings")
|
||||
.expect("Unable to generate bindings");
|
||||
|
||||
bindings
|
||||
.write_to_file(out_path.join("bindings.rs"))
|
||||
.expect("Can't write bindings!");
|
||||
}
|
||||
|
@ -95,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
701
lvgl-sys/vendor/include/lv_conf.h
vendored
Normal file
701
lvgl-sys/vendor/include/lv_conf.h
vendored
Normal file
|
@ -0,0 +1,701 @@
|
|||
/**
|
||||
* @file lv_conf.h
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* COPY THIS FILE AS `lv_conf.h` NEXT TO the `lvgl` FOLDER
|
||||
*/
|
||||
|
||||
#if 1 /*Set it to "1" to enable content*/
|
||||
|
||||
#ifndef LV_CONF_H
|
||||
#define LV_CONF_H
|
||||
/* clang-format off */
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/*====================
|
||||
Graphical 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
|
||||
|
||||
/* 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
|
||||
|
||||
/* Type of coordinates. Should be `int16_t` (or `int32_t` for extreme cases) */
|
||||
typedef int16_t lv_coord_t;
|
||||
|
||||
/*=========================
|
||||
Memory manager 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
|
||||
#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
|
||||
|
||||
/* 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 <stdlib.h> /*Header for the dynamic memory function*/
|
||||
# define LV_MEM_CUSTOM_ALLOC malloc /*Wrapper to malloc*/
|
||||
# define LV_MEM_CUSTOM_FREE free /*Wrapper to free*/
|
||||
#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 */
|
||||
|
||||
/*=======================
|
||||
Input device settings
|
||||
*=======================*/
|
||||
|
||||
/* Input device default settings.
|
||||
* Can be changed in the Input device driver (`lv_indev_drv_t`)*/
|
||||
|
||||
/* Input device read period in milliseconds */
|
||||
#define LV_INDEV_DEF_READ_PERIOD 30
|
||||
|
||||
/* Drag threshold in pixels */
|
||||
#define LV_INDEV_DEF_DRAG_LIMIT 10
|
||||
|
||||
/* Drag throw slow-down in [%]. Greater value -> faster slow-down */
|
||||
#define LV_INDEV_DEF_DRAG_THROW 10
|
||||
|
||||
/* Long press time in milliseconds.
|
||||
* Time to send `LV_EVENT_LONG_PRESSSED`) */
|
||||
#define LV_INDEV_DEF_LONG_PRESS_TIME 400
|
||||
|
||||
/* Repeated trigger period in long press [ms]
|
||||
* Time between `LV_EVENT_LONG_PRESSED_REPEAT */
|
||||
#define LV_INDEV_DEF_LONG_PRESS_REP_TIME 100
|
||||
|
||||
|
||||
/* Gesture threshold in pixels */
|
||||
#define LV_INDEV_DEF_GESTURE_LIMIT 50
|
||||
|
||||
/* Gesture min velocity at release before swipe (pixels)*/
|
||||
#define LV_INDEV_DEF_GESTURE_MIN_VELOCITY 3
|
||||
|
||||
/*==================
|
||||
* Feature usage
|
||||
*==================*/
|
||||
|
||||
/*1: Enable the Animations */
|
||||
#define LV_USE_ANIMATION 1
|
||||
#if LV_USE_ANIMATION
|
||||
|
||||
/*Declare the type of the user data of animations (can be e.g. `void *`, `int`, `struct`)*/
|
||||
typedef void * lv_anim_user_data_t;
|
||||
|
||||
#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
|
||||
#endif
|
||||
|
||||
/* 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
|
||||
|
||||
/* 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*/
|
||||
|
||||
/* 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
|
||||
|
||||
/* 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;
|
||||
#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: Enable indexed (palette) images */
|
||||
#define LV_IMG_CF_INDEXED 1
|
||||
|
||||
/* 1: Enable alpha indexed images */
|
||||
#define LV_IMG_CF_ALPHA 1
|
||||
|
||||
/* 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
|
||||
|
||||
/*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;
|
||||
|
||||
/*=====================
|
||||
* Compiler settings
|
||||
*====================*/
|
||||
/* 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_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))) */
|
||||
#define LV_ATTRIBUTE_MEM_ALIGN
|
||||
|
||||
/* 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_<CONST> 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) <my_assert_code>
|
||||
*/
|
||||
#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*/
|
||||
|
||||
/*==================
|
||||
* 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 */
|
||||
#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_SIMSUN_16_CJK 0 /*1000 most common CJK radicals*/
|
||||
|
||||
/*Pixel perfect monospace font
|
||||
* http://pelulamu.net/unscii/ */
|
||||
#define LV_FONT_UNSCII_8 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)
|
||||
*/
|
||||
#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
|
||||
|
||||
/* 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
|
||||
|
||||
/*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*/
|
||||
#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 <stdint.h> /*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
|
||||
|
||||
/*=================
|
||||
* Text settings
|
||||
*=================*/
|
||||
|
||||
/* 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 " ,.;:-_"
|
||||
|
||||
/* 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 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. */
|
||||
#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
|
||||
#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
|
||||
#endif
|
||||
|
||||
/* 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 <stdio.h>
|
||||
# define lv_snprintf snprintf
|
||||
# define lv_vsnprintf vsnprintf
|
||||
#else /*!LV_SPRINTF_CUSTOM*/
|
||||
# define LV_SPRINTF_DISABLE_FLOAT 1
|
||||
#endif /*LV_SPRINTF_CUSTOM*/
|
||||
|
||||
/*===================
|
||||
* LV_OBJ SETTINGS
|
||||
*==================*/
|
||||
|
||||
#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*/
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*1: enable `lv_obj_realaign()` based on `lv_obj_align()` parameters*/
|
||||
#define LV_USE_OBJ_REALIGN 1
|
||||
|
||||
/* 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
|
||||
|
||||
/*==================
|
||||
* LV OBJ X USAGE
|
||||
*================*/
|
||||
/*
|
||||
* Documentation of the object types: https://docs.lvgl.com/#Object-types
|
||||
*/
|
||||
|
||||
/*Arc (dependencies: -)*/
|
||||
#define LV_USE_ARC 1
|
||||
|
||||
/*Bar (dependencies: -)*/
|
||||
#define LV_USE_BAR 1
|
||||
|
||||
/*Button (dependencies: lv_cont*/
|
||||
#define LV_USE_BTN 1
|
||||
|
||||
/*Button matrix (dependencies: -)*/
|
||||
#define LV_USE_BTNMATRIX 1
|
||||
|
||||
/*Calendar (dependencies: -)*/
|
||||
#define LV_USE_CALENDAR 1
|
||||
|
||||
/*Canvas (dependencies: lv_img)*/
|
||||
#define LV_USE_CANVAS 1
|
||||
|
||||
/*Check box (dependencies: lv_btn, lv_label)*/
|
||||
#define LV_USE_CHECKBOX 1
|
||||
|
||||
/*Chart (dependencies: -)*/
|
||||
#define LV_USE_CHART 1
|
||||
#if LV_USE_CHART
|
||||
# define LV_CHART_AXIS_TICK_LABEL_MAX_LEN 256
|
||||
#endif
|
||||
|
||||
/*Container (dependencies: -*/
|
||||
#define LV_USE_CONT 1
|
||||
|
||||
/*Color picker (dependencies: -*/
|
||||
#define LV_USE_CPICKER 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
|
||||
#endif
|
||||
|
||||
/*Gauge (dependencies:lv_bar, lv_linemeter)*/
|
||||
#define LV_USE_GAUGE 1
|
||||
|
||||
/*Image (dependencies: lv_label*/
|
||||
#define LV_USE_IMG 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
|
||||
|
||||
/*Keyboard (dependencies: lv_btnm)*/
|
||||
#define LV_USE_KEYBOARD 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
|
||||
|
||||
/* Waiting period at beginning/end of animation cycle */
|
||||
# define LV_LABEL_WAIT_CHAR_COUNT 3
|
||||
|
||||
/*Enable selecting text of the label */
|
||||
# define LV_LABEL_TEXT_SEL 0
|
||||
|
||||
/*Store extra some info in labels (12 bytes) to speed up drawing of very long texts*/
|
||||
# define LV_LABEL_LONG_TXT_HINT 0
|
||||
#endif
|
||||
|
||||
/*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
|
||||
|
||||
/*Line (dependencies: -*/
|
||||
#define LV_USE_LINE 1
|
||||
|
||||
/*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
|
||||
|
||||
/*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
|
||||
#endif
|
||||
|
||||
/*Mask (dependencies: -)*/
|
||||
#define LV_USE_OBJMASK 1
|
||||
|
||||
/*Message box (dependencies: lv_rect, lv_btnm, lv_label)*/
|
||||
#define LV_USE_MSGBOX 1
|
||||
|
||||
/*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
|
||||
#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
|
||||
#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
|
||||
|
||||
/*Number of extra "pages" when the roller is infinite*/
|
||||
# define LV_ROLLER_INF_PAGES 7
|
||||
#endif
|
||||
|
||||
/*Slider (dependencies: lv_bar)*/
|
||||
#define LV_USE_SLIDER 1
|
||||
|
||||
/*Spinbox (dependencies: lv_ta)*/
|
||||
#define LV_USE_SPINBOX 1
|
||||
|
||||
/*Switch (dependencies: lv_slider)*/
|
||||
#define LV_USE_SWITCH 1
|
||||
|
||||
/*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
|
||||
|
||||
/*Table (dependencies: lv_label)*/
|
||||
#define LV_USE_TABLE 1
|
||||
#if LV_USE_TABLE
|
||||
# define LV_TABLE_COL_MAX 12
|
||||
#endif
|
||||
|
||||
/*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
|
||||
#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
|
||||
#endif
|
||||
|
||||
/*Window (dependencies: lv_cont, lv_btn, lv_label, lv_img, lv_page)*/
|
||||
#define LV_USE_WIN 1
|
||||
|
||||
/*==================
|
||||
* Non-user section
|
||||
*==================*/
|
||||
|
||||
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) /* Disable warnings for Visual Studio*/
|
||||
# define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
|
||||
/*--END OF LV_CONF_H--*/
|
||||
|
||||
#endif /*LV_CONF_H*/
|
||||
|
||||
#endif /*End of "Content enable"*/
|
2
lvgl-sys/vendor/lvgl
vendored
2
lvgl-sys/vendor/lvgl
vendored
|
@ -1 +1 @@
|
|||
Subproject commit 1ca1934dbe8e826ef1ed1690005fb678fea3a1f3
|
||||
Subproject commit 524709472757405ac0eef8d6d002632526430df3
|
|
@ -1,7 +1,7 @@
|
|||
[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)."
|
||||
version = "0.4.0"
|
||||
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"
|
||||
repository = "https://github.com/rafaelcaricio/lvgl-rs"
|
||||
|
@ -12,15 +12,47 @@ keywords = ["littlevgl", "lvgl", "graphical_interfaces"]
|
|||
build = "build.rs"
|
||||
|
||||
[dependencies]
|
||||
lvgl-sys = { version = "0.4.0", path = "../lvgl-sys" }
|
||||
lvgl-sys = { version = "0.5.2", path = "../lvgl-sys" }
|
||||
cty = "0.2.1"
|
||||
embedded-graphics = "0.6.2"
|
||||
cstr_core = { version = "0.2.0" }
|
||||
embedded-graphics = "0.7.1"
|
||||
cstr_core = "0.2.3"
|
||||
bitflags = "1.2.1"
|
||||
|
||||
[build-dependencies]
|
||||
quote = "1.0.7"
|
||||
proc-macro2 = "1.0.18"
|
||||
lvgl-codegen = { version = "0.4.0", path = "../lvgl-codegen" }
|
||||
lvgl-sys = { version = "0.4.0", path = "../lvgl-sys" }
|
||||
[features]
|
||||
alloc = ["cstr_core/alloc"]
|
||||
lvgl_alloc = ["alloc"]
|
||||
use-vendored-config = ["lvgl-sys/use-vendored-config"]
|
||||
|
||||
[build-dependencies]
|
||||
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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,18 @@ impl Color {
|
|||
pub fn from_raw(raw: lvgl_sys::lv_color_t) -> Self {
|
||||
Self { raw }
|
||||
}
|
||||
|
||||
pub fn r(&self) -> 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 }
|
||||
}
|
||||
|
||||
pub fn b(&self) -> u8 {
|
||||
unsafe { lvgl_sys::_LV_COLOR_GET_B(self.raw) as u8 }
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Color> for Rgb888 {
|
||||
|
@ -53,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
|
||||
|
@ -100,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(())
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -189,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,
|
||||
|
@ -231,3 +245,23 @@ impl From<Animation> for lvgl_sys::lv_anim_enable_t {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn color_properties_accessible() {
|
||||
let color = Color::from_rgb((206, 51, 255));
|
||||
|
||||
if lvgl_sys::LV_COLOR_DEPTH == 32 {
|
||||
assert_eq!(color.r(), 206);
|
||||
assert_eq!(color.g(), 51);
|
||||
assert_eq!(color.b(), 255);
|
||||
} else if lvgl_sys::LV_COLOR_DEPTH == 16 {
|
||||
assert_eq!(color.r(), 25);
|
||||
assert_eq!(color.g(), 12);
|
||||
assert_eq!(color.b(), 31);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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