diff --git a/client/src/broken_clouds.bmp b/client/src/broken_clouds.bmp new file mode 100644 index 0000000..8b9112d Binary files /dev/null and b/client/src/broken_clouds.bmp differ diff --git a/client/src/few_clouds.bmp b/client/src/few_clouds.bmp new file mode 100644 index 0000000..b6c3fd5 Binary files /dev/null and b/client/src/few_clouds.bmp differ diff --git a/client/src/main.rs b/client/src/main.rs index 4c54ee9..0923c62 100644 --- a/client/src/main.rs +++ b/client/src/main.rs @@ -105,6 +105,12 @@ impl DrawTarget for UdpDisplay { } } +fn renderWeatherIcon(display: &mut UdpDisplay, icon: &[u8]){ + let icon_image = Bmp::from_slice(icon).unwrap(); + Image::new(&icon_image, Point::new((IMAGE_WIDTH-40) as i32, 0)).draw(display).unwrap(); + +} + fn renderWeather(display: &mut UdpDisplay ,data: &Option>){ let text_style = MonoTextStyle::new(&FONT_6X10, BinaryColor::On); @@ -125,10 +131,31 @@ fn renderWeather(display: &mut UdpDisplay ,data: &Option { - let sun_icon = include_bytes!("sun.bmp"); - let sun_icon_image = Bmp::from_slice(sun_icon).unwrap(); - Image::new(&sun_icon_image, Point::new((IMAGE_WIDTH-40) as i32, 0)).draw(display).unwrap(); - + renderWeatherIcon(display, include_bytes!("sun.bmp")); + }, + "02" => { + renderWeatherIcon(display, include_bytes!("few_clouds.bmp")); + }, + "03" => { + renderWeatherIcon(display, include_bytes!("scattered_clouds.bmp")); + }, + "04" => { + renderWeatherIcon(display, include_bytes!("broken_clouds.bmp")); + }, + "09" => { + renderWeatherIcon(display, include_bytes!("shower.bmp")); + }, + "10" => { + renderWeatherIcon(display, include_bytes!("rain.bmp")); + }, + "11" => { + renderWeatherIcon(display, include_bytes!("thunderstorm.bmp")); + }, + "13" => { + renderWeatherIcon(display, include_bytes!("snow.bmp")); + }, + "50" => { + renderWeatherIcon(display, include_bytes!("mist.bmp")); }, _ => { println!("Missing icon for {short_icon_code}"); @@ -167,11 +194,9 @@ fn send_package(ipaddress: String, data: &Option> // .into_styled(PRIMITIVE_STYLE) // .draw(&mut display) // .unwrap(); - - renderWeather(&mut display, data); - + package[1..PACKAGE_LENGTH].copy_from_slice(&display.image); diff --git a/client/src/mist.bmp b/client/src/mist.bmp new file mode 100644 index 0000000..02304d8 Binary files /dev/null and b/client/src/mist.bmp differ diff --git a/client/src/rain.bmp b/client/src/rain.bmp new file mode 100644 index 0000000..727c81d Binary files /dev/null and b/client/src/rain.bmp differ diff --git a/client/src/scattered_clouds.bmp b/client/src/scattered_clouds.bmp new file mode 100644 index 0000000..171c920 Binary files /dev/null and b/client/src/scattered_clouds.bmp differ diff --git a/client/src/shower.bmp b/client/src/shower.bmp new file mode 100644 index 0000000..9189d5c Binary files /dev/null and b/client/src/shower.bmp differ diff --git a/client/src/snow.bmp b/client/src/snow.bmp new file mode 100644 index 0000000..9138b66 Binary files /dev/null and b/client/src/snow.bmp differ diff --git a/client/src/thunderstorm.bmp b/client/src/thunderstorm.bmp new file mode 100644 index 0000000..ca2420e Binary files /dev/null and b/client/src/thunderstorm.bmp differ