Expand description
Clock API for nros
This module provides clock abstraction for different time sources:
- SystemTime: Wall clock time (affected by system time changes)
- SteadyTime: Monotonic time (not affected by system time changes)
- RosTime: Simulation time (can be paused/scaled)
§Example
use nros::clock::{Clock, ClockType};
// Create a system clock
let clock = Clock::system();
let now = clock.now();
println!("Current time: {} sec", now.sec);
// Create a steady clock for measuring durations
let clock = Clock::steady();
let start = clock.now();
// ... do work ...
let elapsed = clock.now() - start;§Where the time comes from
With a platform port linked (the platform-clock feature), every clock
reads the PORT: nros_platform_time_now_ns for the wall, and
nros_platform_clock_ns for the monotonic. Without one there is no clock
to read, and all three types fall back to an internal counter the caller
advances with update_steady_time() — suitable for a bare-metal RTIC or
polling loop, which is the only build where that counter has an owner.
Structs§
- Clock
- A clock for querying time
- Wall
Clock State - What the wall-clock stamps mean right now: the answer to
nros_platform_wall_clock_state(), field for field.
Enums§
- Clock
Type - Type of clock to use for time queries
- Wall
Clock Source - Which source answers the wall clock (
WallClockState::source); the values ofNROS_WALL_CLOCK_SOURCE_*innros/platform.h.
Functions§
- wall_
clock_ state - The wall clock’s state from the linked port, or
Nonewhen this build has no port to ask (noplatform-clock), the same condition under whichClock::systemfalls back to its counter.