mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-22 06:42:32 +00:00
Merge pull request #3025 from andresovela/timestamp-uptime-features
embassy-time: add timestamp features
This commit is contained in:
commit
4452a06e76
@ -27,9 +27,17 @@ features = ["defmt", "std"]
|
||||
std = ["tick-hz-1_000_000", "critical-section/std"]
|
||||
wasm = ["dep:wasm-bindgen", "dep:js-sys", "dep:wasm-timer", "tick-hz-1_000_000"]
|
||||
|
||||
## Display a timestamp of the number of seconds since startup next to defmt log messages
|
||||
## Display the time since startup next to defmt log messages.
|
||||
## At most 1 `defmt-timestamp-uptime-*` feature can be used.
|
||||
## `defmt-timestamp-uptime` is provided for backwards compatibility (provides the same format as `uptime-us`).
|
||||
## To use this you must have a time driver provided.
|
||||
defmt-timestamp-uptime = ["defmt"]
|
||||
defmt-timestamp-uptime-s = ["defmt"]
|
||||
defmt-timestamp-uptime-ms = ["defmt"]
|
||||
defmt-timestamp-uptime-us = ["defmt"]
|
||||
defmt-timestamp-uptime-ts = ["defmt"]
|
||||
defmt-timestamp-uptime-tms = ["defmt"]
|
||||
defmt-timestamp-uptime-tus = ["defmt"]
|
||||
|
||||
## Create a `MockDriver` that can be manually advanced for testing purposes.
|
||||
mock-driver = ["tick-hz-1_000_000"]
|
||||
|
@ -46,5 +46,20 @@ pub(crate) const GCD_1K: u64 = gcd(TICK_HZ, 1_000);
|
||||
pub(crate) const GCD_1M: u64 = gcd(TICK_HZ, 1_000_000);
|
||||
pub(crate) const GCD_1G: u64 = gcd(TICK_HZ, 1_000_000_000);
|
||||
|
||||
#[cfg(feature = "defmt-timestamp-uptime")]
|
||||
#[cfg(feature = "defmt-timestamp-uptime-s")]
|
||||
defmt::timestamp! {"{=u64}", Instant::now().as_secs() }
|
||||
|
||||
#[cfg(feature = "defmt-timestamp-uptime-ms")]
|
||||
defmt::timestamp! {"{=u64:ms}", Instant::now().as_millis() }
|
||||
|
||||
#[cfg(any(feature = "defmt-timestamp-uptime", feature = "defmt-timestamp-uptime-us"))]
|
||||
defmt::timestamp! {"{=u64:us}", Instant::now().as_micros() }
|
||||
|
||||
#[cfg(feature = "defmt-timestamp-uptime-ts")]
|
||||
defmt::timestamp! {"{=u64:ts}", Instant::now().as_secs() }
|
||||
|
||||
#[cfg(feature = "defmt-timestamp-uptime-tms")]
|
||||
defmt::timestamp! {"{=u64:tms}", Instant::now().as_millis() }
|
||||
|
||||
#[cfg(feature = "defmt-timestamp-uptime-tus")]
|
||||
defmt::timestamp! {"{=u64:tus}", Instant::now().as_micros() }
|
||||
|
Loading…
Reference in New Issue
Block a user