small improvements to RTC
@@ -97,6 +97,7 @@ fn read_register(register: u8) -> u8{
}
/// A timestamp obtained from the real-time clock.
+#[derive(Debug)]
pub struct RtcTime {
pub seconds: u8,
pub minutes: u8,
@@ -105,6 +106,13 @@ pub struct RtcTime {
pub months: u8,
pub years: u8,
}
+use core::fmt;
+impl fmt::Display for RtcTime {
+ fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
+ write!(f, "RTC Time: {}/{}/{} {}:{}:{}",
+ self.years, self.months, self.days, self.hours, self.minutes, self.seconds)
+ }
+}
//call this function to print RTC's date and time
pub fn read_rtc() -> RtcTime {
@@ -117,8 +125,6 @@ pub fn read_rtc() -> RtcTime {
let month = read_register(0x08);
let year = read_register(0x09);
- trace!("RTC time: {}/{}/{} {}:{}:{}", year, month, day, hour, minute, second);
-
RtcTime {
seconds: second,
minutes: minute,
