Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cef6faa05f | |||
| e758edd45a | |||
| 59c13dc46a |
+1
-1
@@ -14,7 +14,7 @@ zip = "8.3"
|
|||||||
csv = "1.4"
|
csv = "1.4"
|
||||||
|
|
||||||
[profile.dev]
|
[profile.dev]
|
||||||
opt-level = 1
|
opt-level = 0
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
opt-level = 3
|
opt-level = 3
|
||||||
|
|||||||
+33
-26
@@ -1,6 +1,6 @@
|
|||||||
use log::debug;
|
use log::debug;
|
||||||
use gtfs_structures::{Calendar, CalendarDate, RawStopTime, RawTrip, Route, Stop};
|
use gtfs_structures::{Calendar, CalendarDate, RawStopTime, RawTrip, Route, Stop};
|
||||||
use serde::de::DeserializeOwned;
|
use serde::de::{DeserializeOwned, value::MapAccessDeserializer};
|
||||||
use std::{
|
use std::{
|
||||||
collections::{HashMap, HashSet},
|
collections::{HashMap, HashSet},
|
||||||
fs::File,
|
fs::File,
|
||||||
@@ -14,14 +14,14 @@ use crate::gtfs::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
trait Filter<T> {
|
trait Filter<T> {
|
||||||
fn accept(&self, v: &T) -> bool;
|
fn accept(&self, v: &T) -> Option<bool>;
|
||||||
}
|
}
|
||||||
|
|
||||||
// No filter on loaded records
|
// No filter on loaded records
|
||||||
struct LoadAll {}
|
struct LoadAll {}
|
||||||
impl<T> Filter<T> for LoadAll {
|
impl<T> Filter<T> for LoadAll {
|
||||||
fn accept(&self, _: &T) -> bool {
|
fn accept(&self, _: &T) -> Option<bool> {
|
||||||
return true;
|
return Some(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,9 +29,9 @@ struct LoadRoutes<'a> {
|
|||||||
routes: &'a HashSet<String>,
|
routes: &'a HashSet<String>,
|
||||||
}
|
}
|
||||||
impl Filter<Route> for LoadRoutes<'_> {
|
impl Filter<Route> for LoadRoutes<'_> {
|
||||||
fn accept(&self, r: &Route) -> bool {
|
fn accept(&self, r: &Route) -> Option<bool> {
|
||||||
let short_name = &r.short_name;
|
let short_name = &r.short_name;
|
||||||
return short_name.is_some() && self.routes.contains(short_name.as_ref().unwrap());
|
return Some(short_name.is_some() && self.routes.contains(short_name.as_ref()?));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,9 +39,9 @@ struct LoadStops<'a> {
|
|||||||
stops: &'a HashSet<String>,
|
stops: &'a HashSet<String>,
|
||||||
}
|
}
|
||||||
impl Filter<Stop> for LoadStops<'_> {
|
impl Filter<Stop> for LoadStops<'_> {
|
||||||
fn accept(&self, s: &Stop) -> bool {
|
fn accept(&self, s: &Stop) -> Option<bool> {
|
||||||
let stop_code = &s.code;
|
let stop_code = &s.code;
|
||||||
return stop_code.is_some() && self.stops.contains(s.code.as_ref().unwrap());
|
return Some(stop_code.is_some() && self.stops.contains(s.code.as_ref()?));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,9 +49,9 @@ struct LoadTrips<'a> {
|
|||||||
route_ids: &'a HashSet<String>,
|
route_ids: &'a HashSet<String>,
|
||||||
}
|
}
|
||||||
impl Filter<RawTrip> for LoadTrips<'_> {
|
impl Filter<RawTrip> for LoadTrips<'_> {
|
||||||
fn accept(&self, t: &RawTrip) -> bool {
|
fn accept(&self, t: &RawTrip) -> Option<bool> {
|
||||||
let route_id = &t.route_id;
|
let route_id = &t.route_id;
|
||||||
return self.route_ids.contains(route_id);
|
return Some(self.route_ids.contains(route_id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,8 +60,8 @@ struct LoadStopTimes<'a> {
|
|||||||
stop_ids: &'a HashSet<String>,
|
stop_ids: &'a HashSet<String>,
|
||||||
}
|
}
|
||||||
impl Filter<RawStopTime> for LoadStopTimes<'_> {
|
impl Filter<RawStopTime> for LoadStopTimes<'_> {
|
||||||
fn accept(&self, st: &RawStopTime) -> bool {
|
fn accept(&self, st: &RawStopTime) -> Option<bool> {
|
||||||
return self.stop_ids.contains(&st.stop_id) && self.trip_ids.contains(&st.trip_id);
|
return Some(self.stop_ids.contains(&st.stop_id) && self.trip_ids.contains(&st.trip_id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,14 +70,15 @@ fn load_vector<T: serde::de::DeserializeOwned>(
|
|||||||
destination: &mut Vec<T>,
|
destination: &mut Vec<T>,
|
||||||
zip_reader: &mut ZipArchive<File>,
|
zip_reader: &mut ZipArchive<File>,
|
||||||
table_name: &str,
|
table_name: &str,
|
||||||
) {
|
) -> Option<bool> {
|
||||||
let file_reader = zip_reader.by_name(table_name).unwrap();
|
let file_reader = zip_reader.by_name(table_name);
|
||||||
let mut rdr = csv::Reader::from_reader(file_reader);
|
let mut rdr = csv::Reader::from_reader(file_reader.ok()?);
|
||||||
|
|
||||||
for row in rdr.deserialize() {
|
for row in rdr.deserialize() {
|
||||||
let record: T = row.unwrap();
|
let record: T = row.ok()?;
|
||||||
destination.push(record);
|
destination.push(record);
|
||||||
}
|
}
|
||||||
|
return Some(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loads a HashMap of the selected type, using the provided index function as the key
|
// Loads a HashMap of the selected type, using the provided index function as the key
|
||||||
@@ -87,27 +88,30 @@ fn load_map<K, V, IndexFn, FilterT>(
|
|||||||
table_name: &str,
|
table_name: &str,
|
||||||
index: IndexFn,
|
index: IndexFn,
|
||||||
filter: FilterT,
|
filter: FilterT,
|
||||||
) where
|
) -> Option<bool>
|
||||||
|
where
|
||||||
K: Eq + Hash,
|
K: Eq + Hash,
|
||||||
V: DeserializeOwned,
|
V: DeserializeOwned,
|
||||||
IndexFn: Fn(&V) -> K,
|
IndexFn: Fn(&V) -> K,
|
||||||
FilterT: Filter<V>,
|
FilterT: Filter<V>
|
||||||
{
|
{
|
||||||
let file_reader = zip_reader.by_name(table_name).unwrap();
|
let file_reader = (zip_reader.by_name(table_name)).ok()?;
|
||||||
let mut rdr = csv::Reader::from_reader(file_reader);
|
let mut rdr = csv::Reader::from_reader(file_reader);
|
||||||
|
|
||||||
for row in rdr.deserialize() {
|
for row in rdr.deserialize() {
|
||||||
if row.is_ok() {
|
if row.is_ok() {
|
||||||
let record: V = row.unwrap();
|
let record: V = row.ok()?;
|
||||||
if filter.accept(&record) {
|
let accepted = filter.accept(&record);
|
||||||
|
if accepted.is_some() && accepted? {
|
||||||
let idx: K = index(&record);
|
let idx: K = index(&record);
|
||||||
destination.insert(idx, record);
|
destination.insert(idx, record);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
print!("Row failed to deserialize row {:#?}", row.err());
|
print!("Row failed to deserialize row {:#?}", row.err());
|
||||||
panic!();
|
return None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return Some(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loads a HashMap of a vector of the selected type, using the provided index function as the key
|
// Loads a HashMap of a vector of the selected type, using the provided index function as the key
|
||||||
@@ -118,22 +122,25 @@ fn load_vector_map<'a, K, V, IndexFn, FilterT>(
|
|||||||
table_name: &str,
|
table_name: &str,
|
||||||
index: IndexFn,
|
index: IndexFn,
|
||||||
filter: FilterT,
|
filter: FilterT,
|
||||||
) where
|
) -> Option<bool>
|
||||||
|
where
|
||||||
K: Eq + Hash,
|
K: Eq + Hash,
|
||||||
V: DeserializeOwned,
|
V: DeserializeOwned,
|
||||||
IndexFn: Fn(&V) -> K,
|
IndexFn: Fn(&V) -> K,
|
||||||
FilterT: Filter<V>,
|
FilterT: Filter<V>,
|
||||||
{
|
{
|
||||||
let file_reader = zip_reader.by_name(table_name).unwrap();
|
let file_reader = zip_reader.by_name(table_name).ok()?;
|
||||||
let mut rdr = csv::Reader::from_reader(file_reader);
|
let mut rdr = csv::Reader::from_reader(file_reader);
|
||||||
|
|
||||||
for row in rdr.deserialize() {
|
for row in rdr.deserialize() {
|
||||||
let record: V = row.unwrap();
|
let record: V = row.ok()?;
|
||||||
if filter.accept(&record) {
|
let accepted = filter.accept(&record);
|
||||||
|
if accepted.is_some() && accepted? {
|
||||||
let idx = index(&record);
|
let idx = index(&record);
|
||||||
destination.entry(idx).or_insert_with(Vec::new).push(record);
|
destination.entry(idx).or_insert_with(Vec::new).push(record);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return Some(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn load_gtfs(
|
pub fn load_gtfs(
|
||||||
|
|||||||
+12
-11
@@ -5,8 +5,7 @@ pub mod structs;
|
|||||||
use chrono::{DateTime, Local, NaiveTime, Timelike};
|
use chrono::{DateTime, Local, NaiveTime, Timelike};
|
||||||
use log::{debug};
|
use log::{debug};
|
||||||
use std::{
|
use std::{
|
||||||
collections::{HashMap, HashSet},
|
collections::{HashMap, HashSet}, fs::File, io::Error
|
||||||
fs::File,
|
|
||||||
};
|
};
|
||||||
use gtfs_structures::{Exception, RawTrip};
|
use gtfs_structures::{Exception, RawTrip};
|
||||||
|
|
||||||
@@ -15,7 +14,7 @@ use crate::gtfs::{loader::load_gtfs, structs::{Arrival, Gtfs, Preferences}};
|
|||||||
|
|
||||||
impl Gtfs {
|
impl Gtfs {
|
||||||
|
|
||||||
pub fn get_next_arrivals_for(&self, target_datetime: &DateTime<Local>) -> Vec<Arrival<'_>> {
|
pub fn get_next_arrivals_for(&self, target_datetime: &DateTime<Local>) -> Option<Vec<Arrival<'_>>> {
|
||||||
let naive_target = target_datetime.naive_local();
|
let naive_target = target_datetime.naive_local();
|
||||||
let target_date = naive_target.date();
|
let target_date = naive_target.date();
|
||||||
|
|
||||||
@@ -66,31 +65,33 @@ impl Gtfs {
|
|||||||
|
|
||||||
for (_id, stop_time) in self.stop_times.iter() {
|
for (_id, stop_time) in self.stop_times.iter() {
|
||||||
if trips.contains_key(&stop_time.trip_id) {
|
if trips.contains_key(&stop_time.trip_id) {
|
||||||
let stop_timestamp = stop_time.departure_time.or(stop_time.arrival_time).unwrap();
|
let stop_timestamp = stop_time.departure_time.or(stop_time.arrival_time)?;
|
||||||
debug!("Stop timestamp {} current timestamp {}", stop_timestamp, current_timestamp);
|
debug!("Stop timestamp {} current timestamp {}", stop_timestamp, current_timestamp);
|
||||||
let trip= &self.trips.get(&stop_time.trip_id).unwrap();
|
let trip= &self.trips.get(&stop_time.trip_id).unwrap();
|
||||||
if current_timestamp < stop_timestamp.into() {
|
if current_timestamp < stop_timestamp.into() {
|
||||||
let arrival: Arrival = Arrival {
|
let arrival: Arrival = Arrival {
|
||||||
route: self.routes.get(&trip.route_id).unwrap(),
|
route: self.routes.get(&self.trips.get(&stop_time.trip_id)?.route_id)?,
|
||||||
stop: self.stops.get(&stop_time.stop_id).unwrap(),
|
stop: self.stops.get(&stop_time.stop_id)?,
|
||||||
stop_time: stop_time,
|
stop_time: stop_time,
|
||||||
trip: &trip,
|
trip: &trip,
|
||||||
departure_time: NaiveTime::from_num_seconds_from_midnight_opt(stop_timestamp, 0).unwrap()
|
departure_time: stop_timestamp.into()
|
||||||
};
|
};
|
||||||
arrivals.push(arrival);
|
arrivals.push(arrival);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
arrivals.sort();
|
||||||
debug!("Found {} arrivals", arrivals.len());
|
debug!("Found {} arrivals", arrivals.len());
|
||||||
|
|
||||||
return arrivals;
|
return Some(arrivals);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Load a GTFS structure from a zip file
|
/// Load a GTFS structure from a zip file
|
||||||
pub fn load(src_file: &str, prefs: &Preferences) -> Gtfs {
|
pub fn load(src_file: &str, prefs: &Preferences) -> Result<Gtfs, Error> {
|
||||||
// Open zip file
|
// Open zip file
|
||||||
let mut zip_reader = zip::ZipArchive::new(File::open(src_file).unwrap()).unwrap();
|
let zip_file = File::open(src_file)?;
|
||||||
|
let mut zip_reader = zip::ZipArchive::new(zip_file)?;
|
||||||
|
|
||||||
let mut gtfs: Gtfs = Gtfs {
|
let mut gtfs: Gtfs = Gtfs {
|
||||||
agencies: Vec::new(),
|
agencies: Vec::new(),
|
||||||
@@ -105,6 +106,6 @@ impl Gtfs {
|
|||||||
|
|
||||||
load_gtfs(&mut gtfs, &mut zip_reader, &prefs.route_numbers, &prefs.stop_codes);
|
load_gtfs(&mut gtfs, &mut zip_reader, &prefs.route_numbers, &prefs.stop_codes);
|
||||||
|
|
||||||
return gtfs;
|
return Ok(gtfs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -32,7 +32,7 @@ pub struct Gtfs {
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Arrival<'a> {
|
pub struct Arrival<'a> {
|
||||||
pub departure_time: NaiveTime,
|
pub departure_time: i64,
|
||||||
pub route: &'a Route,
|
pub route: &'a Route,
|
||||||
pub stop: &'a Stop,
|
pub stop: &'a Stop,
|
||||||
pub stop_time: &'a RawStopTime,
|
pub stop_time: &'a RawStopTime,
|
||||||
|
|||||||
+23
-13
@@ -1,7 +1,7 @@
|
|||||||
mod gtfs;
|
mod gtfs;
|
||||||
mod renderer;
|
mod renderer;
|
||||||
use std::{collections::{HashSet, btree_map::Entry}, ops::Add, process, rc::Rc, thread::Builder, time::SystemTime};
|
use std::{collections::HashSet, ops::Add, os::unix::process::ExitStatusExt, process, thread::Builder, time::SystemTime};
|
||||||
use chrono::{DateTime, Duration, Local, NaiveTime};
|
use chrono::{DateTime, Duration, Local, NaiveTime, Timelike};
|
||||||
use log::{Metadata, Record, debug, error, info};
|
use log::{Metadata, Record, debug, error, info};
|
||||||
use sdl3::event::Event;
|
use sdl3::event::Event;
|
||||||
use crate::{gtfs::structs::{Arrival, Gtfs}, renderer::structs::{DisplayData, DisplayEntry, Screen}};
|
use crate::{gtfs::structs::{Arrival, Gtfs}, renderer::structs::{DisplayData, DisplayEntry, Screen}};
|
||||||
@@ -15,41 +15,43 @@ struct RefreshDataEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn refresh_schedule<'a>(gtfs: &'a Gtfs, screen: &mut Screen<'a>) -> Vec<Arrival<'a>> {
|
fn refresh_schedule<'a>(gtfs: &'a Gtfs, screen : &mut Screen<'a>) -> Option<Vec<Arrival<'a>>> {
|
||||||
let current_timestamp = SystemTime::now();
|
let current_timestamp = SystemTime::now();
|
||||||
let datetime: DateTime<Local> = current_timestamp.clone().into();
|
let datetime: DateTime<Local> = current_timestamp.clone().into();
|
||||||
let mut next_arrivals: Vec<Arrival<'_>> = gtfs.get_next_arrivals_for(&datetime);
|
let mut next_arrivals: Vec<Arrival<'_>> = gtfs.get_next_arrivals_for(&datetime)?;
|
||||||
|
|
||||||
if next_arrivals.len() < NUM_ARRIVALS {
|
if next_arrivals.len() < NUM_ARRIVALS {
|
||||||
// If we don't have enough entries today, look for arrivals tomorrow.
|
// If we don't have enough entries today, look for arrivals tomorrow.
|
||||||
let mut tomorrow: DateTime<Local> = datetime.clone();
|
let mut tomorrow: DateTime<Local> = datetime.clone();
|
||||||
tomorrow = tomorrow.with_time(NaiveTime::from_hms_opt(0, 0, 0).unwrap()).unwrap();
|
tomorrow = tomorrow.with_time(NaiveTime::from_hms_opt(0, 0, 0).unwrap()).unwrap();
|
||||||
tomorrow = tomorrow.add(Duration::days(1));
|
tomorrow = tomorrow.add(Duration::days(1));
|
||||||
next_arrivals.append(&mut gtfs.get_next_arrivals_for(&tomorrow));
|
next_arrivals.append(&mut gtfs.get_next_arrivals_for(&tomorrow)?);
|
||||||
}
|
}
|
||||||
|
|
||||||
next_arrivals.sort();
|
next_arrivals.sort();
|
||||||
|
|
||||||
// Create the DisplayData structure to render the information to screen
|
// Create the DisplayData structure to render the information to screen
|
||||||
let current_time = Local::now().time();
|
let now =Local::now();
|
||||||
|
let current_time: i64 = (now.hour() * 3600 + now.minute() * 60 + now.second()).into();
|
||||||
let mut display_data: DisplayData = DisplayData {
|
let mut display_data: DisplayData = DisplayData {
|
||||||
lines: Vec::<DisplayEntry>::new(),
|
lines: Vec::<DisplayEntry>::new(),
|
||||||
status: None
|
status: None
|
||||||
};
|
};
|
||||||
|
|
||||||
display_data.lines.extend(next_arrivals.iter().map(|arrival| -> DisplayEntry {
|
display_data.lines.extend(next_arrivals.iter().map(|arrival| -> DisplayEntry {
|
||||||
|
|
||||||
DisplayEntry {
|
DisplayEntry {
|
||||||
destination: arrival.stop_time.stop_headsign.clone()
|
destination: arrival.stop_time.stop_headsign.clone()
|
||||||
.or(arrival.trip.trip_headsign.clone()
|
.or(arrival.trip.trip_headsign.clone()
|
||||||
.or(Option::Some(String::from("Unknown")
|
.or(Option::Some(String::from("Unknown")
|
||||||
))).unwrap(),
|
))).unwrap(),
|
||||||
route: arrival.route.short_name.clone().or(arrival.route.long_name.clone()).unwrap(),
|
route: arrival.route.short_name.clone().or(arrival.route.long_name.clone()).unwrap(),
|
||||||
due_in: (arrival.departure_time - current_time).num_minutes().try_into().unwrap()
|
due_in: (arrival.departure_time - current_time) / 60,
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
screen.update_information(&display_data);
|
screen.update_information(&display_data);
|
||||||
return next_arrivals;
|
return Some(next_arrivals);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -71,7 +73,11 @@ fn main() {
|
|||||||
fn flush(&self) {}
|
fn flush(&self) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
log::set_logger(&MY_LOGGER).unwrap();
|
let logger = log::set_logger(&MY_LOGGER);
|
||||||
|
if logger.is_err() {
|
||||||
|
print!("Error setting up the main logger:{:#?}", logger.err());
|
||||||
|
process::exit(-1);
|
||||||
|
}
|
||||||
log::set_max_level(log::LevelFilter::Trace);
|
log::set_max_level(log::LevelFilter::Trace);
|
||||||
|
|
||||||
// Create preferences structures from config
|
// Create preferences structures from config
|
||||||
@@ -88,7 +94,13 @@ fn main() {
|
|||||||
|
|
||||||
// Init GTFS static info
|
// Init GTFS static info
|
||||||
info!("Loading GTFS data...");
|
info!("Loading GTFS data...");
|
||||||
let gtfs = Gtfs::load(SRC_FILE, >fs_prefs);
|
let res = Gtfs::load(SRC_FILE, >fs_prefs);
|
||||||
|
|
||||||
|
if let Err(e) = res {
|
||||||
|
error!("Error loading GTFS data: {}", e);
|
||||||
|
process::exit(-1);
|
||||||
|
}
|
||||||
|
let gtfs = res.unwrap();
|
||||||
|
|
||||||
// Init screen
|
// Init screen
|
||||||
info!("Initializing screen...");
|
info!("Initializing screen...");
|
||||||
@@ -133,9 +145,7 @@ fn main() {
|
|||||||
// Is the custom event a Refresh Data event?
|
// Is the custom event a Refresh Data event?
|
||||||
let refresh_data = event.as_user_event_type::<RefreshDataEvent>();
|
let refresh_data = event.as_user_event_type::<RefreshDataEvent>();
|
||||||
if refresh_data.is_some() {
|
if refresh_data.is_some() {
|
||||||
debug!("Received user event: {:#?}", refresh_data.unwrap());
|
let _data: Option<Vec<Arrival<'_>>> = refresh_schedule(>fs, &mut screen);
|
||||||
let _data: Vec<Arrival<'_>> = refresh_schedule(>fs, &mut screen);
|
|
||||||
debug!("-------------------------------- Refresh done.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-2
@@ -38,12 +38,15 @@ impl Screen<'_> {
|
|||||||
|
|
||||||
pub fn update_information(&mut self, display_data: &DisplayData) {
|
pub fn update_information(&mut self, display_data: &DisplayData) {
|
||||||
self.do_clear();
|
self.do_clear();
|
||||||
|
|
||||||
|
// TODO: Add header
|
||||||
|
|
||||||
let num_arrivals: i32 = min(if display_data.status.is_some() {LINE_COUNT - 1} else {LINE_COUNT}, display_data.lines.len().try_into().unwrap());
|
let num_arrivals: i32 = min(if display_data.status.is_some() {LINE_COUNT - 1} else {LINE_COUNT}, display_data.lines.len().try_into().unwrap());
|
||||||
for line in 0..num_arrivals {
|
for line in 0..num_arrivals {
|
||||||
// Compose a line of text with all the information
|
// Compose a line of text with all the information
|
||||||
let entry = display_data.lines.get(line as usize).unwrap();
|
let entry = display_data.lines.get(line as usize).unwrap();
|
||||||
let line: u32 = line.try_into().unwrap();
|
let line: u32 = (line + 1).try_into().unwrap();
|
||||||
let due_in_mins = (entry.due_in / 60) as i32;
|
let due_in_mins = entry.due_in as i32;
|
||||||
let arrival_color: Color = self.color_for(due_in_mins);
|
let arrival_color: Color = self.color_for(due_in_mins);
|
||||||
|
|
||||||
self.color = COLOR_LCD_AMBER;
|
self.color = COLOR_LCD_AMBER;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ pub struct Prefs {
|
|||||||
pub struct DisplayEntry {
|
pub struct DisplayEntry {
|
||||||
pub route: String,
|
pub route: String,
|
||||||
pub destination: String,
|
pub destination: String,
|
||||||
pub due_in: i32,
|
pub due_in: i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct DisplayData {
|
pub struct DisplayData {
|
||||||
|
|||||||
Reference in New Issue
Block a user