From 82a0b4b2efd1f373801b7048eef075bd7a2289f1 Mon Sep 17 00:00:00 2001 From: Rafael Caricio Date: Sun, 12 Apr 2020 13:57:17 +0200 Subject: [PATCH] Remove direct dependencies --- .gitignore | 2 ++ Cargo.toml | 7 ------- examples/demo/Cargo.toml | 2 +- lvgl/Cargo.toml | 3 ++- lvgl/src/display.rs | 6 ++---- lvgl/src/lib.rs | 10 +--------- lvgl/src/objx.rs | 18 +++++++++++------- 7 files changed, 19 insertions(+), 29 deletions(-) delete mode 100644 Cargo.toml diff --git a/.gitignore b/.gitignore index aa982cd..89a11b8 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,5 @@ Cargo.lock # These are backup files generated by rustfmt **/*.rs.bk .idea/ +examples/demo/target/ +lvgl/target/ diff --git a/Cargo.toml b/Cargo.toml deleted file mode 100644 index ebbc5aa..0000000 --- a/Cargo.toml +++ /dev/null @@ -1,7 +0,0 @@ -[workspace] -members = [ - "lvgl-sys", - "lvgl", - "examples/demo", -] - diff --git a/examples/demo/Cargo.toml b/examples/demo/Cargo.toml index c9eee05..705d13d 100644 --- a/examples/demo/Cargo.toml +++ b/examples/demo/Cargo.toml @@ -8,6 +8,6 @@ publish = false # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -lvgl-sys = { path = "../../lvgl-sys" } lvgl = { path = "../../lvgl" } +lvgl-sys = "0.1.0" sdl2 = "0.33.0" diff --git a/lvgl/Cargo.toml b/lvgl/Cargo.toml index fa068b5..616d741 100644 --- a/lvgl/Cargo.toml +++ b/lvgl/Cargo.toml @@ -1,5 +1,6 @@ [package] name = "lvgl" +description = "LittlevGL bindings for Rust. A powerful and easy-to-use embedded GUI with many widgets, advanced visual effects (opacity, antialiasing, animations) and low memory requirements (16K RAM, 64K Flash)." version = "0.1.0" authors = ["Rafael Caricio "] edition = "2018" @@ -12,5 +13,5 @@ keywords = ["littlevgl", "lvgl", "graphical_interfaces"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -lvgl-sys = { path = "../lvgl-sys", version = "0.1.0" } +lvgl-sys = "0.1.0" cty = "0.2.1" diff --git a/lvgl/src/display.rs b/lvgl/src/display.rs index 4a06db4..855ec4b 100644 --- a/lvgl/src/display.rs +++ b/lvgl/src/display.rs @@ -1,10 +1,8 @@ - use crate::objx::Object; use core::ptr; pub fn get_active_screen() -> Object { - let raw = unsafe { - ptr::NonNull::new_unchecked(lvgl_sys::lv_disp_get_scr_act(ptr::null_mut())) - }; + let raw = + unsafe { ptr::NonNull::new_unchecked(lvgl_sys::lv_disp_get_scr_act(ptr::null_mut())) }; Object::new(raw) } diff --git a/lvgl/src/lib.rs b/lvgl/src/lib.rs index b8d5807..f9efaa6 100644 --- a/lvgl/src/lib.rs +++ b/lvgl/src/lib.rs @@ -1,14 +1,6 @@ #![no_std] -mod objx; pub mod display; +mod objx; pub use objx::*; - -#[cfg(test)] -mod tests { - #[test] - fn it_works() { - assert_eq!(2 + 2, 4); - } -} diff --git a/lvgl/src/objx.rs b/lvgl/src/objx.rs index 74d500f..fc52d40 100644 --- a/lvgl/src/objx.rs +++ b/lvgl/src/objx.rs @@ -1,7 +1,6 @@ -use lvgl_sys; -use core::ffi; use core::ptr; use cty; +use lvgl_sys; pub trait Container { fn raw(&self) -> ptr::NonNull; @@ -19,9 +18,7 @@ impl Object { impl Container for Object { fn raw(&self) -> ptr::NonNull { - unsafe { - ptr::NonNull::new_unchecked(self.raw.as_ptr()) - } + unsafe { ptr::NonNull::new_unchecked(self.raw.as_ptr()) } } } @@ -41,7 +38,11 @@ impl Button { pub fn set_pos(&mut self, x: u16, y: u16) { unsafe { - lvgl_sys::lv_obj_set_pos(self.raw().as_mut(), x as lvgl_sys::lv_coord_t, y as lvgl_sys::lv_coord_t); + lvgl_sys::lv_obj_set_pos( + self.raw().as_mut(), + x as lvgl_sys::lv_coord_t, + y as lvgl_sys::lv_coord_t, + ); } } } @@ -68,7 +69,10 @@ impl Label { pub fn set_text(&mut self, text: &str) { unsafe { - lvgl_sys::lv_label_set_text(self.core.raw().as_mut(), text.as_ptr() as *const cty::c_char); + lvgl_sys::lv_label_set_text( + self.core.raw().as_mut(), + text.as_ptr() as *const cty::c_char, + ); } } }