diff --git a/client/bin/src/main.rs b/client/bin/src/main.rs index 10ce554..d5d467f 100644 --- a/client/bin/src/main.rs +++ b/client/bin/src/main.rs @@ -1,4 +1,4 @@ -use std::time::Duration; +use std::{time::Duration, fmt::format}; use bit::BitIndex; use chrono_tz::Europe::Berlin; use chrono::{DateTime, NaiveDateTime, Utc, Timelike}; @@ -228,6 +228,19 @@ fn render_weather_icon(condition: &Weather, display: &mut UdpDisplay ){ Image::new(&icon_image.unwrap(), Point::new((IMAGE_WIDTH-40) as i32, 0)).draw(display).unwrap(); } +fn render_clock(display: &mut UdpDisplay){ + let cur_time = DateTime::::default(); + let europe_time = cur_time.with_timezone(&Berlin); + let hour = europe_time.hour(); + let minute = europe_time.minute(); + let second = europe_time.second(); + let time = format!("{hour:0>2}:{minute:0>2}:{second:0>2}"); + let text_style = MonoTextStyle::new(&FONT_6X10, BinaryColor::On); + Text::new(&time, Point::new((1) as i32, 7), text_style) + .draw(display) + .unwrap(); +} + fn send_package(ipaddress: String, data: &Option>, straba_res: &NextDeparture) { @@ -272,6 +285,11 @@ fn send_package(ipaddress: String, .unwrap(); } + + + render_clock(&mut display); + + package[1..PACKAGE_LENGTH].copy_from_slice(&display.image); // client need to bind to client port (1 before 4242) let socket = UdpSocket::bind("0.0.0.0:14242").expect("couldn't bind to address"); diff --git a/client/bin/src/straba.rs b/client/bin/src/straba.rs index f0cd5ee..86f80ff 100644 --- a/client/bin/src/straba.rs +++ b/client/bin/src/straba.rs @@ -11,6 +11,7 @@ const STATION_URL:&str = "https://www.rnv-online.de/rest/departure/2494"; pub struct Station { pub id: String, pub name: String, + #[serde(alias = "graphQL")] pub graph_ql: GraphQL, }