From a48ddfc9b77d3bac76492e2b9e741c1b03c538f6 Mon Sep 17 00:00:00 2001 From: Nahuel Lofeudo Date: Sun, 24 May 2026 07:54:40 +0100 Subject: [PATCH] Show time at the bottom unless there is a message. --- resources/dublinbus.yaml | 2 +- src/renderer/mod.rs | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/resources/dublinbus.yaml b/resources/dublinbus.yaml index ded3d30..cd618a2 100644 --- a/resources/dublinbus.yaml +++ b/resources/dublinbus.yaml @@ -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: diff --git a/src/renderer/mod.rs b/src/renderer/mod.rs index 9c80f85..1ed082f 100644 --- a/src/renderer/mod.rs +++ b/src/renderer/mod.rs @@ -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