time start

This commit is contained in:
Empire 2023-09-22 22:10:52 +02:00
parent 34957749cb
commit a28610f821
2 changed files with 20 additions and 1 deletions

View File

@ -1,4 +1,4 @@
use std::time::Duration; use std::{time::Duration, fmt::format};
use bit::BitIndex; use bit::BitIndex;
use chrono_tz::Europe::Berlin; use chrono_tz::Europe::Berlin;
use chrono::{DateTime, NaiveDateTime, Utc, Timelike}; 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(); 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::<Utc>::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, fn send_package(ipaddress: String,
data: &Option<Result<Forecast, String>>, data: &Option<Result<Forecast, String>>,
straba_res: &NextDeparture) { straba_res: &NextDeparture) {
@ -272,6 +285,11 @@ fn send_package(ipaddress: String,
.unwrap(); .unwrap();
} }
render_clock(&mut display);
package[1..PACKAGE_LENGTH].copy_from_slice(&display.image); package[1..PACKAGE_LENGTH].copy_from_slice(&display.image);
// client need to bind to client port (1 before 4242) // 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"); let socket = UdpSocket::bind("0.0.0.0:14242").expect("couldn't bind to address");

View File

@ -11,6 +11,7 @@ const STATION_URL:&str = "https://www.rnv-online.de/rest/departure/2494";
pub struct Station { pub struct Station {
pub id: String, pub id: String,
pub name: String, pub name: String,
#[serde(alias = "graphQL")]
pub graph_ql: GraphQL, pub graph_ql: GraphQL,
} }