Show time at the bottom unless there is a message.

This commit is contained in:
Nahuel Lofeudo 2026-05-24 07:54:40 +01:00
parent b9cb2ac504
commit a48ddfc9b7
2 changed files with 9 additions and 4 deletions

View File

@ -1,7 +1,7 @@
screen:
width: 1920
height: 720
font-path: "resources/jd_lcd_rounded.ttf"
font-path: "resources/jd_lcd_rounded/jd-lcd-rounded.ttf"
gtfs:
routes:

View File

@ -1,6 +1,6 @@
pub mod structs;
use std::{cmp::min};
use chrono::{Local, Timelike};
use chrono::{Datelike, Local, Timelike};
use log::{debug, error, warn};
use sdl3::{Sdl, pixels::Color, rect::Rect};
use structs::{Prefs, DisplayData};
@ -46,17 +46,22 @@ impl Screen<'_> {
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();
// Print status first
self.color = COLOR_LCD_AMBER;
if display_data.status.is_some() {
// If the update has some information text, show it
self.do_print_at(5, display_data.status.as_ref().unwrap(), 0);
} else {
// 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