From 83b3946d2fc979b43f576bfaf17c4185a37d136d Mon Sep 17 00:00:00 2001 From: Felix Wittwer Date: Sat, 6 Aug 2022 01:56:50 +0200 Subject: [PATCH] RustFmt and some notes --- src/weather/mod.rs | 103 +++++++++++++++++++++++---------------------- 1 file changed, 52 insertions(+), 51 deletions(-) diff --git a/src/weather/mod.rs b/src/weather/mod.rs index 81ce681..6c76c32 100644 --- a/src/weather/mod.rs +++ b/src/weather/mod.rs @@ -1,18 +1,15 @@ use embedded_graphics::{ - draw_target::DrawTarget, - image::Image, - 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_7_POINT, PROFONT_9_POINT, }; -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(display: &mut D) where D: DrawTarget, @@ -24,7 +21,7 @@ where 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), @@ -40,53 +37,57 @@ where ) .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}%", 32), + Point::new(10, 62), + MonoTextStyle::new(&PROFONT_14_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!("Regen\nWahrsch."), + Point::new(44, 55), + MonoTextStyle::new(&PROFONT_7_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}%", 2.0), + Point::new(10, 81), + MonoTextStyle::new(&PROFONT_14_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!("Luft\nfeuchte"), + Point::new(44, 74), + MonoTextStyle::new(&PROFONT_7_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"); + // TODO(feliix42): Color based on the value. + // https://de.wikipedia.org/wiki/UV-Index + 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"); + + // TODO(feliix42): use test data to draw a forecast using + // https://crates.io/crates/embedded-plots }