RustFmt and some notes
This commit is contained in:
parent
bb693ac026
commit
83b3946d2f
1 changed files with 52 additions and 51 deletions
|
@ -1,18 +1,15 @@
|
||||||
use embedded_graphics::{
|
use embedded_graphics::{
|
||||||
draw_target::DrawTarget,
|
draw_target::DrawTarget, image::Image, mono_font::MonoTextStyle, prelude::*, text::Text,
|
||||||
image::Image,
|
};
|
||||||
mono_font::MonoTextStyle,
|
use profont::{
|
||||||
prelude::*,
|
PROFONT_12_POINT, PROFONT_14_POINT, PROFONT_24_POINT, PROFONT_7_POINT, PROFONT_9_POINT,
|
||||||
text::Text
|
|
||||||
};
|
};
|
||||||
use profont::{PROFONT_12_POINT, PROFONT_14_POINT, PROFONT_24_POINT, PROFONT_9_POINT, PROFONT_7_POINT};
|
|
||||||
use ssd1675::Color;
|
use ssd1675::Color;
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use tinybmp::Bmp;
|
use tinybmp::Bmp;
|
||||||
|
|
||||||
mod data;
|
mod data;
|
||||||
|
|
||||||
|
|
||||||
pub fn get_weather<D>(display: &mut D)
|
pub fn get_weather<D>(display: &mut D)
|
||||||
where
|
where
|
||||||
D: DrawTarget<Color = Color>,
|
D: DrawTarget<Color = Color>,
|
||||||
|
@ -24,7 +21,7 @@ where
|
||||||
Image::new(&bmp, Point::new(10, 10))
|
Image::new(&bmp, Point::new(10, 10))
|
||||||
.draw(display)
|
.draw(display)
|
||||||
.expect("Failed to draw image");
|
.expect("Failed to draw image");
|
||||||
|
|
||||||
Text::new(
|
Text::new(
|
||||||
&format!("{:.1}°C", -28.1),
|
&format!("{:.1}°C", -28.1),
|
||||||
Point::new(75, 28),
|
Point::new(75, 28),
|
||||||
|
@ -40,53 +37,57 @@ where
|
||||||
)
|
)
|
||||||
.draw(display)
|
.draw(display)
|
||||||
.expect("error drawing text");
|
.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(
|
Text::new(
|
||||||
&format!("Regen\nWahrsch."),
|
&format!("{:2.0}%", 32),
|
||||||
Point::new(44, 55),
|
Point::new(10, 62),
|
||||||
MonoTextStyle::new(&PROFONT_7_POINT, Color::Black),
|
MonoTextStyle::new(&PROFONT_14_POINT, Color::Black),
|
||||||
)
|
)
|
||||||
.draw(display)
|
.draw(display)
|
||||||
.expect("error drawing text");
|
.expect("error drawing text");
|
||||||
|
|
||||||
Text::new(
|
Text::new(
|
||||||
&format!("{:2.0}%", 2.0),
|
&format!("Regen\nWahrsch."),
|
||||||
Point::new(10, 81),
|
Point::new(44, 55),
|
||||||
MonoTextStyle::new(&PROFONT_14_POINT, Color::Black),
|
MonoTextStyle::new(&PROFONT_7_POINT, Color::Black),
|
||||||
)
|
)
|
||||||
.draw(display)
|
.draw(display)
|
||||||
.expect("error drawing text");
|
.expect("error drawing text");
|
||||||
|
|
||||||
Text::new(
|
Text::new(
|
||||||
&format!("Luft\nfeuchte"),
|
&format!("{:2.0}%", 2.0),
|
||||||
Point::new(44, 74),
|
Point::new(10, 81),
|
||||||
MonoTextStyle::new(&PROFONT_7_POINT, Color::Black),
|
MonoTextStyle::new(&PROFONT_14_POINT, Color::Black),
|
||||||
)
|
)
|
||||||
.draw(display)
|
.draw(display)
|
||||||
.expect("error drawing text");
|
.expect("error drawing text");
|
||||||
|
|
||||||
Text::new(
|
Text::new(
|
||||||
&format!("{:2.0}", 3),
|
&format!("Luft\nfeuchte"),
|
||||||
Point::new(20, 100),
|
Point::new(44, 74),
|
||||||
MonoTextStyle::new(&PROFONT_14_POINT, Color::Black),
|
MonoTextStyle::new(&PROFONT_7_POINT, Color::Black),
|
||||||
)
|
)
|
||||||
.draw(display)
|
.draw(display)
|
||||||
.expect("error drawing text");
|
.expect("error drawing text");
|
||||||
|
|
||||||
Text::new(
|
// TODO(feliix42): Color based on the value.
|
||||||
&format!("UV\nIdx"),
|
// https://de.wikipedia.org/wiki/UV-Index
|
||||||
Point::new(44, 93),
|
Text::new(
|
||||||
MonoTextStyle::new(&PROFONT_7_POINT, Color::Black),
|
&format!("{:2.0}", 3),
|
||||||
)
|
Point::new(20, 100),
|
||||||
.draw(display)
|
MonoTextStyle::new(&PROFONT_14_POINT, Color::Black),
|
||||||
.expect("error drawing text");
|
)
|
||||||
|
.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");
|
||||||
|
|
||||||
|
// TODO(feliix42): use test data to draw a forecast using
|
||||||
|
// https://crates.io/crates/embedded-plots
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue