Compare commits
No commits in common. "0381b8d14cd73bb23ec0f33b8953c57aa4ef6e92" and "b8c2dea685ad909da308dbbacea781a141f90931" have entirely different histories.
0381b8d14c
...
b8c2dea685
Before Width: | Height: | Size: 402 B |
Before Width: | Height: | Size: 402 B |
Before Width: | Height: | Size: 402 B |
BIN
assets/fog.bmp
Before Width: | Height: | Size: 402 B |
BIN
assets/rain.bmp
Before Width: | Height: | Size: 402 B |
BIN
assets/snow.bmp
Before Width: | Height: | Size: 402 B |
BIN
assets/sunny.bmp
Before Width: | Height: | Size: 402 B |
Before Width: | Height: | Size: 402 B |
Before Width: | Height: | Size: 402 B |
BIN
assets/wind.bmp
Before Width: | Height: | Size: 402 B |
BIN
rain2.bmp
Normal file
After Width: | Height: | Size: 402 B |
|
@ -18,7 +18,6 @@ where
|
||||||
weather::get_weather(display)
|
weather::get_weather(display)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(feliix42): Remove dead code here
|
|
||||||
|
|
||||||
pub fn populate_default<D>(display: &mut D)
|
pub fn populate_default<D>(display: &mut D)
|
||||||
where
|
where
|
||||||
|
@ -70,7 +69,7 @@ where
|
||||||
.expect("error drawing text");
|
.expect("error drawing text");
|
||||||
}
|
}
|
||||||
|
|
||||||
let bmp_data = include_bytes!("../assets/rain.bmp");
|
let bmp_data = include_bytes!("../rain2.bmp");
|
||||||
|
|
||||||
// Load 16 BPP 8x8px image.
|
// Load 16 BPP 8x8px image.
|
||||||
// Note: The color type is specified explicitly to match the format used by the BMP image.
|
// Note: The color type is specified explicitly to match the format used by the BMP image.
|
||||||
|
|
|
@ -7,9 +7,6 @@
|
||||||
|
|
||||||
use embedded_plots::curve::PlotPoint;
|
use embedded_plots::curve::PlotPoint;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use ssd1675::Color;
|
|
||||||
use tinybmp::Bmp;
|
|
||||||
use super::icons;
|
|
||||||
|
|
||||||
/// Response from the OpenWeather API with both current and forecast data for a given location.
|
/// Response from the OpenWeather API with both current and forecast data for a given location.
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
|
@ -58,10 +55,6 @@ impl WeatherData {
|
||||||
self.current.data.uvi.round() as u8
|
self.current.data.uvi.round() as u8
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn current_condition(&self) -> Bmp<'static, Color> {
|
|
||||||
unimplemented!()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn forecast_plot_data(&self) -> Vec<PlotPoint> {
|
pub fn forecast_plot_data(&self) -> Vec<PlotPoint> {
|
||||||
let data: Vec<f32> = self.hourly.iter().take(24).map(|h| h.data.temp).collect();
|
let data: Vec<f32> = self.hourly.iter().take(24).map(|h| h.data.temp).collect();
|
||||||
|
|
||||||
|
@ -193,7 +186,6 @@ pub enum WeatherCondition {
|
||||||
Squall,
|
Squall,
|
||||||
Tornado,
|
Tornado,
|
||||||
Clear,
|
Clear,
|
||||||
SunClouds,
|
|
||||||
Clouds,
|
Clouds,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,39 +207,9 @@ impl From<u16> for WeatherCondition {
|
||||||
771 => Self::Squall,
|
771 => Self::Squall,
|
||||||
781 => Self::Tornado,
|
781 => Self::Tornado,
|
||||||
800 => Self::Clear,
|
800 => Self::Clear,
|
||||||
801|802 => Self::SunClouds,
|
801..=804 => Self::Clouds,
|
||||||
803|804 => Self::Clouds,
|
|
||||||
// NOTE(feliix42): There's no `Error` mapping or something like that.
|
// NOTE(feliix42): There's no `Error` mapping or something like that.
|
||||||
_ => Self::Clear,
|
_ => Self::Clear,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<Bmp<'_, Color>> for WeatherCondition {
|
|
||||||
/// gets a bitmap for each current weather condition.
|
|
||||||
fn into(self) -> Bmp<'static, Color> {
|
|
||||||
let bmp = match self {
|
|
||||||
Self::Thunderstorm => icons::THUNDER,
|
|
||||||
Self::Drizzle => icons::DRIZZLE,
|
|
||||||
Self::Rain => icons::RAIN,
|
|
||||||
Self::Snow => icons::SNOW,
|
|
||||||
Self::Mist => icons::MIST,
|
|
||||||
Self::Smoke => icons::SMOKE,
|
|
||||||
Self::Haze => icons::HAZE,
|
|
||||||
Self::SandDust => icons::SANDDUST,
|
|
||||||
Self::Fog => icons::FOG,
|
|
||||||
Self::Sand => icons::SAND,
|
|
||||||
Self::Dust => icons::DUST,
|
|
||||||
Self::Ash => icons::ASH,
|
|
||||||
Self::Squall => icons::SQUALL,
|
|
||||||
Self::Tornado => icons::TORNADO,
|
|
||||||
// TODO(feliix42): Show Moon(phases) here after sundown
|
|
||||||
Self::Clear => icons::CLEAR,
|
|
||||||
Self::Clouds => icons::CLOUDS,
|
|
||||||
Self::SunClouds => icons::SUNCLOUDS,
|
|
||||||
};
|
|
||||||
|
|
||||||
Bmp::from_slice(bmp).unwrap()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
//! Icons for different weather conditions.
|
|
||||||
//!
|
|
||||||
//! This module contains raw byte arrays for different weather conditions supported by the
|
|
||||||
//! OpenWeather API v3. They are loaded and parsed by the `WeatherCondition::into` function.
|
|
||||||
|
|
||||||
pub static THUNDER: &'static [u8] = include_bytes!("../../assets/thunder.bmp");
|
|
||||||
pub static DRIZZLE: &'static [u8] = include_bytes!("../../assets/drizzle.bmp");
|
|
||||||
pub static RAIN: &'static [u8] = include_bytes!("../../assets/rain.bmp");
|
|
||||||
pub static SNOW: &'static [u8] = include_bytes!("../../assets/snow.bmp");
|
|
||||||
|
|
||||||
pub static MIST: &'static [u8] = include_bytes!("../../assets/fog.bmp");
|
|
||||||
pub static SMOKE: &'static [u8] = include_bytes!("../../assets/thick-fog.bmp");
|
|
||||||
pub static HAZE: &'static [u8] = include_bytes!("../../assets/fog.bmp");
|
|
||||||
pub static SANDDUST: &'static [u8] = include_bytes!("../../assets/thick-fog.bmp");
|
|
||||||
pub static FOG: &'static [u8] = include_bytes!("../../assets/fog.bmp");
|
|
||||||
pub static SAND: &'static [u8] = include_bytes!("../../assets/thick-fog.bmp");
|
|
||||||
pub static DUST: &'static [u8] = include_bytes!("../../assets/thick-fog.bmp");
|
|
||||||
pub static ASH: &'static [u8] = include_bytes!("../../assets/thick-fog.bmp");
|
|
||||||
pub static SQUALL: &'static [u8] = include_bytes!("../../assets/wind.bmp");
|
|
||||||
pub static TORNADO: &'static [u8] = include_bytes!("../../assets/wind.bmp");
|
|
||||||
|
|
||||||
pub static CLEAR: &'static [u8] = include_bytes!("../../assets/sunny.bmp");
|
|
||||||
pub static CLOUDS: &'static [u8] = include_bytes!("../../assets/cloudy.bmp");
|
|
||||||
pub static SUNCLOUDS: &'static [u8] = include_bytes!("../../assets/cloudsun.bmp");
|
|
|
@ -12,11 +12,11 @@ use profont::{
|
||||||
use ssd1675::Color;
|
use ssd1675::Color;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
|
use tinybmp::Bmp;
|
||||||
|
|
||||||
mod api;
|
mod api;
|
||||||
mod data;
|
mod data;
|
||||||
mod secret;
|
mod secret;
|
||||||
mod icons;
|
|
||||||
|
|
||||||
pub fn get_weather<D>(display: &mut D)
|
pub fn get_weather<D>(display: &mut D)
|
||||||
where
|
where
|
||||||
|
@ -32,7 +32,8 @@ where
|
||||||
};
|
};
|
||||||
|
|
||||||
// draw image
|
// draw image
|
||||||
let bmp = weather_data.current_condition();
|
let bmp_data = include_bytes!("../../rain2.bmp");
|
||||||
|
let bmp = Bmp::<Color>::from_slice(bmp_data).unwrap();
|
||||||
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");
|
||||||
|
|