diff --git a/Cargo.lock b/Cargo.lock index 1fe26f0..38e1bba 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -298,6 +298,7 @@ dependencies = [ "linux-embedded-hal", "profont", "ssd1675", + "tinybmp", ] [[package]] @@ -354,6 +355,12 @@ dependencies = [ "void", ] +[[package]] +name = "memchr" +version = "2.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" + [[package]] name = "memoffset" version = "0.6.5" @@ -416,6 +423,16 @@ dependencies = [ "memoffset", ] +[[package]] +name = "nom" +version = "6.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c5c51b9083a3c620fa67a2a635d1ce7d95b897e957d6b28ff9a5da960a103a6" +dependencies = [ + "memchr", + "version_check", +] + [[package]] name = "num" version = "0.1.42" @@ -750,6 +767,22 @@ dependencies = [ "weezl", ] +[[package]] +name = "tinybmp" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44873aee48dd30712dc2610209902a78b9033a0148ac03c6c3e73e4ca2f49838" +dependencies = [ + "embedded-graphics", + "nom", +] + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + [[package]] name = "void" version = "1.0.2" diff --git a/Cargo.toml b/Cargo.toml index e4ef0dd..cceda34 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,7 @@ authors = ["Felix Wittwer "] [dependencies] embedded-graphics = "0.7.1" +tinybmp = "0.3.3" profont = "0.5.0" #ssd1675 = { git = "https://github.com/Feliix42/ssd1675" } ssd1675 = { path = "../ssd1675" } diff --git a/rain2.bmp b/rain2.bmp new file mode 100644 index 0000000..223b185 Binary files /dev/null and b/rain2.bmp differ diff --git a/src/bin/simulator.rs b/src/bin/simulator.rs index 86a4216..c78ddfc 100644 --- a/src/bin/simulator.rs +++ b/src/bin/simulator.rs @@ -1,38 +1,26 @@ +use embedded_graphics::prelude::*; +use embedded_graphics_simulator::{OutputSettings, SimulatorDisplay, Window}; use ssd1675::Color; -use embedded_graphics::{ - pixelcolor::BinaryColor, - prelude::*, - primitives::{Circle, Line, Rectangle, PrimitiveStyle}, - mono_font::{ascii::FONT_6X9, MonoTextStyle}, - text::Text, -}; -use embedded_graphics_simulator::{BinaryColorTheme, SimulatorDisplay, Window, OutputSettingsBuilder, OutputSettings}; - fn main() -> Result<(), core::convert::Infallible> { println!("Initialize Display"); let mut display = SimulatorDisplay::::new(Size::new(212, 104)); - let output_settings = OutputSettingsBuilder::new() - .theme(BinaryColorTheme::OledBlue) - .build(); println!("Creating Window"); let mut window = Window::new("Hello World", &OutputSettings::default()); - //loop { - //println!("Populate display..."); - //inky_ticker::populate(&mut display); + //println!("Populate display..."); + //inky_ticker::populate(&mut display); - //println!("Updating window"); - //window.update(&display); + //println!("Updating window"); + //window.update(&display); - //std::thread::sleep(std::time::Duration::from_secs(1)); + //std::thread::sleep(std::time::Duration::from_secs(1)); //} - + inky_ticker::populate(&mut display); window.show_static(&display); Ok(()) } - diff --git a/src/lib.rs b/src/lib.rs index 2054a96..0e6f48b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,16 +1,17 @@ use embedded_graphics::{ - draw_target::DrawTarget, mono_font::MonoTextStyle, prelude::*, text::Text, + draw_target::DrawTarget, image::Image, mono_font::MonoTextStyle, prelude::*, text::Text, }; use profont::{PROFONT_12_POINT, PROFONT_14_POINT, PROFONT_24_POINT, PROFONT_9_POINT}; use ssd1675::Color; -use std::process::Command; use std::fmt::Debug; +use std::process::Command; use std::{fs, io}; +use tinybmp::Bmp; pub fn populate(display: &mut D) where D: DrawTarget, - D::Error: Debug + D::Error: Debug, { Text::new( "Raspberry Pi", @@ -56,6 +57,19 @@ where .draw(display) .expect("error drawing text"); } + + let bmp_data = include_bytes!("../rain2.bmp"); + + // Load 16 BPP 8x8px image. + // Note: The color type is specified explicitly to match the format used by the BMP image. + let bmp = Bmp::::from_slice(bmp_data).unwrap(); + //let bmp: Bmp = bmp.into(); + + // Draw the image with the top left corner at (10, 20) by wrapping it in + // an embedded-graphics `Image`. + Image::new(&bmp, Point::new(10, 20)) + .draw(display) + .expect("Failed to draw image"); } pub fn read_cpu_temp() -> Result {