diff --git a/Cargo.lock b/Cargo.lock index d55622d..c2864ef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -172,14 +172,13 @@ checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43" [[package]] name = "buoyant" -version = "0.6.0-alpha.1" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbc36827a22794f33600a539fc2f16e6c535f9de5cf26509f8ce7ddb666cda1b" dependencies = [ "embedded-graphics", "embedded-graphics-core", - "embedded-touch", - "fixed", - "fixed-macro", - "heapless", + "heapless 0.8.0", "paste", "u8g2-fonts", ] @@ -228,7 +227,7 @@ dependencies = [ "embedded-graphics", "embedded-graphics-simulator", "embedded-sprites", - "heapless", + "heapless 0.9.2", "profont", "tinybmp", ] @@ -353,16 +352,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "embedded-touch" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93d19cf3f85ec63a8bdfc213ba3e3f1375acbb4ea9322060d3dded4afa5a8d6e" -dependencies = [ - "fixed", - "fixed-macro", -] - [[package]] name = "equator" version = "0.4.2" @@ -433,53 +422,6 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a3076410a55c90011c298b04d0cfa770b00fa04e1e3c97d3f6c9de105a03844" -[[package]] -name = "fixed" -version = "1.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "707070ccf8c4173548210893a0186e29c266901b71ed20cd9e2ca0193dfe95c3" -dependencies = [ - "az", - "bytemuck", - "half", - "typenum", -] - -[[package]] -name = "fixed-macro" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0c48af8cb14e02868f449f8a2187bd78af7a08da201fdc78d518ecb1675bc" -dependencies = [ - "fixed", - "fixed-macro-impl", - "fixed-macro-types", -] - -[[package]] -name = "fixed-macro-impl" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c93086f471c0a1b9c5e300ea92f5cd990ac6d3f8edf27616ef624b8fa6402d4b" -dependencies = [ - "fixed", - "paste", - "proc-macro-error", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "fixed-macro-types" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "044a61b034a2264a7f65aa0c3cd112a01b4d4ee58baace51fead3f21b993c7e4" -dependencies = [ - "fixed", - "fixed-macro-impl", -] - [[package]] name = "flate2" version = "1.1.5" @@ -541,6 +483,16 @@ dependencies = [ "byteorder", ] +[[package]] +name = "heapless" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bfb9eb618601c89945a70e254898da93b13be0388091d42117462b265bb3fad" +dependencies = [ + "hash32", + "stable_deref_trait", +] + [[package]] name = "heapless" version = "0.9.2" @@ -847,30 +799,6 @@ dependencies = [ "zerocopy", ] -[[package]] -name = "proc-macro-error" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" -dependencies = [ - "proc-macro-error-attr", - "proc-macro2", - "quote", - "syn 1.0.109", - "version_check", -] - -[[package]] -name = "proc-macro-error-attr" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" -dependencies = [ - "proc-macro2", - "quote", - "version_check", -] - [[package]] name = "proc-macro2" version = "1.0.103" @@ -1198,12 +1126,6 @@ dependencies = [ "embedded-graphics", ] -[[package]] -name = "typenum" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb" - [[package]] name = "u8g2-fonts" version = "0.7.2" diff --git a/Cargo.toml b/Cargo.toml index ed8c469..59e9e4f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,8 @@ edition = "2024" [dependencies] #buoyant = "0.6.0-alpha.0" -buoyant = {path = "buoyant" } +buoyant = "0.5.3" +#buoyant = {path = "buoyant" } embedded-graphics = "0.8.1" embedded-graphics-simulator = "0.8.0" embedded-sprites = "0.2.0" diff --git a/assets/indic-rising.bmp b/assets/indic-rising.bmp new file mode 100644 index 0000000..704080e Binary files /dev/null and b/assets/indic-rising.bmp differ diff --git a/assets/indic-rising.svg b/assets/indic-rising.svg new file mode 100644 index 0000000..b2fce48 --- /dev/null +++ b/assets/indic-rising.svg @@ -0,0 +1,97 @@ + + + + + + + + + + + + + diff --git a/src/main.rs b/src/main.rs index 5670a36..cb7c2f1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,29 +1,33 @@ #![feature(unsafe_cell_access)] mod images; -mod triangle; use core::fmt::Write; -use std::{cell::UnsafeCell, mem::MaybeUninit}; +use std::cell::UnsafeCell; +use std::mem::MaybeUninit; -use buoyant::{primitives::Point, render::StrokedShape, view::prelude::*}; -use embedded_graphics::{ - pixelcolor::{Rgb565, Rgb888}, - prelude::*, -}; -use embedded_graphics_simulator::{OutputSettings, SimulatorDisplay, Window}; -use embedded_sprites::{include_image, sprite::Sprite}; +use buoyant::primitives::Point; +use buoyant::render::StrokedShape; +use buoyant::view::prelude::*; +use embedded_graphics::pixelcolor::Rgb565; +use embedded_graphics::pixelcolor::Rgb888; +use embedded_graphics::prelude::*; +use embedded_graphics_simulator::OutputSettings; +use embedded_graphics_simulator::SimulatorDisplay; +use embedded_graphics_simulator::Window; +use embedded_sprites::include_image; +use embedded_sprites::sprite::Sprite; use heapless::format; -use profont::{PROFONT_12_POINT, PROFONT_14_POINT, PROFONT_18_POINT, PROFONT_24_POINT}; +use profont::PROFONT_12_POINT; +use profont::PROFONT_14_POINT; +use profont::PROFONT_18_POINT; +use profont::PROFONT_24_POINT; use tinybmp::Bmp; -use crate::triangle::Triangle; - const BACKGROUND_COLOR: Rgb565 = Rgb565::BLACK; const DEFAULT_COLOR: Rgb565 = Rgb565::WHITE; -fn main() -{ +fn main() { images::prepare_images(); let mut window = Window::new("Hello World", &OutputSettings::default()); @@ -38,8 +42,7 @@ fn main() window.show_static(&display); } -fn hello_view() -> impl View -{ +fn hello_view() -> impl View { VStack::new(( HStack::new(( main_menu_indicator(MenuIndicatorType::Temperature(31.5)), @@ -58,22 +61,18 @@ fn hello_view() -> impl View const FRAME_STROKE: u32 = 2; const FRAME_COLOR: Rgb565 = Rgb565::new(5, 9, 5); -pub enum MenuIndicatorType -{ +pub enum MenuIndicatorType { Temperature(f32), Humidity(f32), Co2(u32), Voc(u32), } -impl MenuIndicatorType -{ +impl MenuIndicatorType { pub fn get_corresponding_icon( &self, - ) -> &'static std::thread::LocalKey>>> - { - match self - { + ) -> &'static std::thread::LocalKey>>> { + match self { MenuIndicatorType::Temperature(_) => &images::TEMPERATURE_ICON, MenuIndicatorType::Humidity(_) => &images::HUMIDITY_ICON, MenuIndicatorType::Co2(_) => &images::CO2_ICON, @@ -81,10 +80,8 @@ impl MenuIndicatorType } } - pub fn get_corresponding_unit_string(&self) -> &'static str - { - match self - { + pub fn get_corresponding_unit_string(&self) -> &'static str { + match self { MenuIndicatorType::Temperature(_) => "C", MenuIndicatorType::Humidity(_) => "%", MenuIndicatorType::Co2(_) => "ppm", @@ -92,10 +89,8 @@ impl MenuIndicatorType } } - pub fn get_value_str(&self) -> heapless::String<16> - { - match self - { + pub fn get_value_str(&self) -> heapless::String<16> { + match self { MenuIndicatorType::Temperature(temp) => format!(16; "{:.1}", temp).unwrap(), MenuIndicatorType::Humidity(hum) => format!(16; "{:.1}", hum).unwrap(), MenuIndicatorType::Co2(co2) => format!(16; "{}", co2).unwrap(), @@ -104,8 +99,7 @@ impl MenuIndicatorType } } -fn main_menu_indicator(indicator_type: MenuIndicatorType) -> impl View -{ +fn main_menu_indicator(indicator_type: MenuIndicatorType) -> impl View { Rectangle .corner_radius(10) .stroked(FRAME_STROKE) @@ -145,23 +139,16 @@ fn main_menu_indicator(indicator_type: MenuIndicatorType) -> impl View }) } -pub enum Tendency -{ +pub enum Tendency { Rising, Steady, Falling, } -fn tendency_indicator(tendency: Tendency) -> impl View -{ - VStack::new(( - StrokedShape::new( - Triangle::new(Point::new(0, 5), Point::new(10, 0), Point::new(0, 10)), - 10, - ), - StrokedShape::new( - Triangle::new(Point::new(0, 5), Point::new(10, 0), Point::new(0, 10)), - 10, - ), - )) +fn tendency_indicator(tendency: Tendency) -> impl View { + Rectangle + .foreground_color(Rgb565::WHITE) + .flex_frame() + .with_min_size(10, 20) + .with_max_size(10, 20) } diff --git a/src/triangle.rs b/src/triangle.rs deleted file mode 100644 index e69de29..0000000