Add layout draft for weather
This commit is contained in:
parent
e374a6e5dc
commit
bb693ac026
3 changed files with 103 additions and 0 deletions
11
src/lib.rs
11
src/lib.rs
|
@ -8,7 +8,18 @@ use std::process::Command;
|
||||||
use std::{fs, io};
|
use std::{fs, io};
|
||||||
use tinybmp::Bmp;
|
use tinybmp::Bmp;
|
||||||
|
|
||||||
|
mod weather;
|
||||||
|
|
||||||
pub fn populate<D>(display: &mut D)
|
pub fn populate<D>(display: &mut D)
|
||||||
|
where
|
||||||
|
D: DrawTarget<Color = Color>,
|
||||||
|
D::Error: Debug,
|
||||||
|
{
|
||||||
|
weather::get_weather(display)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
pub fn populate_default<D>(display: &mut D)
|
||||||
where
|
where
|
||||||
D: DrawTarget<Color = Color>,
|
D: DrawTarget<Color = Color>,
|
||||||
D::Error: Debug,
|
D::Error: Debug,
|
||||||
|
|
0
src/weather/data.rs
Normal file
0
src/weather/data.rs
Normal file
92
src/weather/mod.rs
Normal file
92
src/weather/mod.rs
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
use embedded_graphics::{
|
||||||
|
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, PROFONT_7_POINT};
|
||||||
|
use ssd1675::Color;
|
||||||
|
use std::fmt::Debug;
|
||||||
|
use tinybmp::Bmp;
|
||||||
|
|
||||||
|
mod data;
|
||||||
|
|
||||||
|
|
||||||
|
pub fn get_weather<D>(display: &mut D)
|
||||||
|
where
|
||||||
|
D: DrawTarget<Color = Color>,
|
||||||
|
D::Error: Debug,
|
||||||
|
{
|
||||||
|
// draw image
|
||||||
|
let bmp_data = include_bytes!("../../rain2.bmp");
|
||||||
|
let bmp = Bmp::<Color>::from_slice(bmp_data).unwrap();
|
||||||
|
Image::new(&bmp, Point::new(10, 10))
|
||||||
|
.draw(display)
|
||||||
|
.expect("Failed to draw image");
|
||||||
|
|
||||||
|
Text::new(
|
||||||
|
&format!("{:.1}°C", -28.1),
|
||||||
|
Point::new(75, 28),
|
||||||
|
MonoTextStyle::new(&PROFONT_24_POINT, Color::Black),
|
||||||
|
)
|
||||||
|
.draw(display)
|
||||||
|
.expect("error drawing text");
|
||||||
|
|
||||||
|
Text::new(
|
||||||
|
"gefühlt: 12°C",
|
||||||
|
Point::new(75, 39),
|
||||||
|
MonoTextStyle::new(&PROFONT_9_POINT, Color::Black),
|
||||||
|
)
|
||||||
|
.draw(display)
|
||||||
|
.expect("error drawing text");
|
||||||
|
|
||||||
|
Text::new(
|
||||||
|
&format!("{:2.0}%", 32),
|
||||||
|
Point::new(10, 62),
|
||||||
|
MonoTextStyle::new(&PROFONT_14_POINT, Color::Black),
|
||||||
|
)
|
||||||
|
.draw(display)
|
||||||
|
.expect("error drawing text");
|
||||||
|
|
||||||
|
Text::new(
|
||||||
|
&format!("Regen\nWahrsch."),
|
||||||
|
Point::new(44, 55),
|
||||||
|
MonoTextStyle::new(&PROFONT_7_POINT, Color::Black),
|
||||||
|
)
|
||||||
|
.draw(display)
|
||||||
|
.expect("error drawing text");
|
||||||
|
|
||||||
|
Text::new(
|
||||||
|
&format!("{:2.0}%", 2.0),
|
||||||
|
Point::new(10, 81),
|
||||||
|
MonoTextStyle::new(&PROFONT_14_POINT, Color::Black),
|
||||||
|
)
|
||||||
|
.draw(display)
|
||||||
|
.expect("error drawing text");
|
||||||
|
|
||||||
|
Text::new(
|
||||||
|
&format!("Luft\nfeuchte"),
|
||||||
|
Point::new(44, 74),
|
||||||
|
MonoTextStyle::new(&PROFONT_7_POINT, Color::Black),
|
||||||
|
)
|
||||||
|
.draw(display)
|
||||||
|
.expect("error drawing text");
|
||||||
|
|
||||||
|
Text::new(
|
||||||
|
&format!("{:2.0}", 3),
|
||||||
|
Point::new(20, 100),
|
||||||
|
MonoTextStyle::new(&PROFONT_14_POINT, Color::Black),
|
||||||
|
)
|
||||||
|
.draw(display)
|
||||||
|
.expect("error drawing text");
|
||||||
|
|
||||||
|
Text::new(
|
||||||
|
&format!("UV\nIdx"),
|
||||||
|
Point::new(44, 93),
|
||||||
|
MonoTextStyle::new(&PROFONT_7_POINT, Color::Black),
|
||||||
|
)
|
||||||
|
.draw(display)
|
||||||
|
.expect("error drawing text");
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue