From 489df6e33b280565eeeea7f2c52fc9fb3dfa75d9 Mon Sep 17 00:00:00 2001 From: Ollo Date: Sat, 16 Sep 2023 13:44:30 +0200 Subject: [PATCH] Fixed station handling --- client/bin/src/main.rs | 10 +++------- client/bin/src/straba.rs | 19 ++++++++++--------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/client/bin/src/main.rs b/client/bin/src/main.rs index 843e003..595cf19 100644 --- a/client/bin/src/main.rs +++ b/client/bin/src/main.rs @@ -233,12 +233,9 @@ fn send_package(ipaddress: String, image: [0; IMAGE_SIZE_BYTE], }; - - // Line::new(Point::new(0, 0), Point::new((IMAGE_WIDTH - 1) as i32, 0)) - // .into_styled(PRIMITIVE_STYLE) - // .draw(&mut display) - // .unwrap(); - render_weather(&mut display, data); + if (data.is_some()) { + render_weather(&mut display, data); + } if strabaRes.failure == false { let text_style = MonoTextStyle::new(&FONT_6X10, BinaryColor::On); @@ -274,7 +271,6 @@ fn send_package(ipaddress: String, socket .send_to(&package, ipaddress + ":4242") .expect("couldn't send data"); - println!("Packet sent"); } fn help() { diff --git a/client/bin/src/straba.rs b/client/bin/src/straba.rs index 3d01842..0d6455a 100644 --- a/client/bin/src/straba.rs +++ b/client/bin/src/straba.rs @@ -137,17 +137,18 @@ pub fn fetch_data() -> NextDeparture { let diff = next_departure.timestamp() - (seconds as i64); println!("To {:} {:} (in {:} seconds)", stop.destinationLabel, txt_departure, diff ); - if returnValue.outbound_station == "" { - if stop.destinationLabel.contains("Rheinau") && (diff < returnValue.outbound_diff) { + + if stop.destinationLabel.contains("Rheinau") { + if (diff < returnValue.outbound_diff) { returnValue.outbound_station = stop.destinationLabel; returnValue.outbound_diff = diff; - } else if stop.destinationLabel.contains("Hochschule") || - stop.destinationLabel.contains("Hauptbahnhof") || - stop.destinationLabel.contains("nau") { // Schönau - if returnValue.inbound_station == "" && (diff < returnValue.inbound_diff) { - returnValue.inbound_station = stop.destinationLabel; - returnValue.inbound_diff = diff; - } + } + } else if stop.destinationLabel.contains("Hochschule") || + stop.destinationLabel.contains("Hauptbahnhof") || + stop.destinationLabel.contains("Schönau") { + if (diff < returnValue.inbound_diff) { + returnValue.inbound_station = stop.destinationLabel; + returnValue.inbound_diff = diff; } } } else {