Rudimentary image displaying

This commit is contained in:
Felix Suchert 2022-08-05 23:16:54 +02:00
parent 7d736fa378
commit e374a6e5dc
Signed by: feliix42
GPG key ID: 24363525EA0E8A99
5 changed files with 59 additions and 23 deletions

33
Cargo.lock generated
View file

@ -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"

View file

@ -9,6 +9,7 @@ authors = ["Felix Wittwer <dev@felixwittwer.de>"]
[dependencies]
embedded-graphics = "0.7.1"
tinybmp = "0.3.3"
profont = "0.5.0"
#ssd1675 = { git = "https://github.com/Feliix42/ssd1675" }
ssd1675 = { path = "../ssd1675" }

BIN
rain2.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 402 B

View file

@ -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::<Color>::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(())
}

View file

@ -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<D>(display: &mut D)
where
D: DrawTarget<Color = Color>,
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::<Color>::from_slice(bmp_data).unwrap();
//let bmp: Bmp<Color> = 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<f64, io::Error> {