Time Library
Stof time library ("Time").
The time library is a part of Stof, however, is separately organized because it is system-dependent and cannot be broadly implemented for all embedded environments.
Time.now(): ms
Returns the current time (in milliseconds) since the Unix epoch.
See Units and Primitive Types to better understand Stof unit types.
Time.nowNano(): ns
Returns the current time (in nanoseconds) since the Unix epoch. This is helpful for situations that require more granularity than milliseconds.
Time.diff(prev: ms): ms
Returns the current time (in milliseconds) minus a previous timestamp, or the elapsed time since a call to "Time.now()".
The argument may be in alternative time units to milliseconds (will get converted), however, if the value does not have units, it will be assumed to be milliseconds (float or int).
Time.diffNano(prev: ns): ns
Returns the current time (in nanoseconds) minus a previous timestamp, or the elapsed time since a call to "Time.now()" or "Time.nowNano()".
The argument may be in alternative time units to nanoseconds (will get converted), however, if the value does not have units, it will be assumed to be nanoseconds (float or int).
Time.sleep(duration: ms): void
Block the current thread for a duration (assumed to be milliseconds if no units).
Time.sleepNano(duration: ns): void
Block the current thread for a duration (assumed to be nanoseconds if no units). Use this function instead of "sleep" if you need a higher granularity than milliseconds.
Last updated
Was this helpful?