mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-21 09:14:34 +00:00
turn off time init check after it returns true
this reduces a bit of message chatter for a call that may be called quite frequently.
This commit is contained in:
parent
a7912b6296
commit
ee695d0181
1 changed files with 22 additions and 15 deletions
|
|
@ -16,6 +16,7 @@ static TIME_REFCOUNT: AtomicU32 = AtomicU32::new(0);
|
|||
pub struct LocalTime {
|
||||
conn: xous::CID,
|
||||
warn_count: u32,
|
||||
time_init: bool,
|
||||
}
|
||||
impl LocalTime {
|
||||
pub fn new() -> LocalTime {
|
||||
|
|
@ -24,11 +25,13 @@ impl LocalTime {
|
|||
LocalTime {
|
||||
conn,
|
||||
warn_count: 0,
|
||||
time_init: false,
|
||||
}
|
||||
}
|
||||
/// Returns the local time as milliseconds since EPOCH, assuming the time zone is set
|
||||
/// This is provided because we don't have a `libc` to do time zone lookups with `Chrono`.
|
||||
pub fn get_local_time_ms(&mut self) -> Option<u64> {
|
||||
if !self.time_init {
|
||||
match xous::send_message(self.conn,
|
||||
xous::Message::new_blocking_scalar(
|
||||
6, // WallClockTimeInit -- this should not change because it's a libstd mapping
|
||||
|
|
@ -49,6 +52,10 @@ impl LocalTime {
|
|||
return None;
|
||||
}
|
||||
}
|
||||
}
|
||||
// if we got here, time was initialized. Set a flag so we don't check again in the future.
|
||||
// this reduces the chatter of messages that may routinely happen, e.g. for getting seconds updates on the RTC.
|
||||
self.time_init = true;
|
||||
match xous::send_message(self.conn,
|
||||
xous::Message::new_blocking_scalar(
|
||||
4,
|
||||
|
|
|
|||
Loading…
Reference in a new issue