Show time at the bottom unless there is a message.
This commit is contained in:
parent
b9cb2ac504
commit
a48ddfc9b7
|
|
@ -1,7 +1,7 @@
|
||||||
screen:
|
screen:
|
||||||
width: 1920
|
width: 1920
|
||||||
height: 720
|
height: 720
|
||||||
font-path: "resources/jd_lcd_rounded.ttf"
|
font-path: "resources/jd_lcd_rounded/jd-lcd-rounded.ttf"
|
||||||
|
|
||||||
gtfs:
|
gtfs:
|
||||||
routes:
|
routes:
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
pub mod structs;
|
pub mod structs;
|
||||||
use std::{cmp::min};
|
use std::{cmp::min};
|
||||||
use chrono::{Local, Timelike};
|
use chrono::{Datelike, Local, Timelike};
|
||||||
use log::{debug, error, warn};
|
use log::{debug, error, warn};
|
||||||
use sdl3::{Sdl, pixels::Color, rect::Rect};
|
use sdl3::{Sdl, pixels::Color, rect::Rect};
|
||||||
use structs::{Prefs, DisplayData};
|
use structs::{Prefs, DisplayData};
|
||||||
|
|
@ -46,17 +46,22 @@ impl Screen<'_> {
|
||||||
|
|
||||||
|
|
||||||
pub fn update_information(&mut self, display_data: &DisplayData) {
|
pub fn update_information(&mut self, display_data: &DisplayData) {
|
||||||
let seconds_since_midnight = Local::now().num_seconds_from_midnight();
|
let local_time = Local::now();
|
||||||
|
let seconds_since_midnight = local_time.num_seconds_from_midnight();
|
||||||
|
|
||||||
self.do_clear();
|
self.do_clear();
|
||||||
|
|
||||||
// Print status first
|
// Print status first
|
||||||
|
self.color = COLOR_LCD_AMBER;
|
||||||
if display_data.status.is_some() {
|
if display_data.status.is_some() {
|
||||||
// If the update has some information text, show it
|
// If the update has some information text, show it
|
||||||
self.do_print_at(5, display_data.status.as_ref().unwrap(), 0);
|
self.do_print_at(5, display_data.status.as_ref().unwrap(), 0);
|
||||||
} else {
|
} else {
|
||||||
// Display date and time otherwise
|
// Display date and time otherwise
|
||||||
self.do_print_at(5, &format!("TODO: DATE/TIME GOES HERE").to_string(), 0);
|
self.do_print_at(5, &format!("Current time: {:02}/{:02}/{:4} {:02}:{:02}",
|
||||||
|
local_time.day(), local_time.month(), local_time.year(),
|
||||||
|
local_time.hour(), local_time.minute()
|
||||||
|
).to_string(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Then data lines from the bottom
|
// Then data lines from the bottom
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue