Merge pull request #4064 from bugadani/hz
Hand-roll defmt::Format for Hertz
This commit is contained in:
commit
5158482eb9
@ -5,7 +5,6 @@ use core::ops::{Div, Mul};
|
|||||||
|
|
||||||
/// Hertz
|
/// Hertz
|
||||||
#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Debug)]
|
#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Debug)]
|
||||||
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
|
||||||
pub struct Hertz(pub u32);
|
pub struct Hertz(pub u32);
|
||||||
|
|
||||||
impl Display for Hertz {
|
impl Display for Hertz {
|
||||||
@ -14,6 +13,13 @@ impl Display for Hertz {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "defmt")]
|
||||||
|
impl defmt::Format for Hertz {
|
||||||
|
fn format(&self, f: defmt::Formatter) {
|
||||||
|
defmt::write!(f, "{=u32} Hz", self.0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Hertz {
|
impl Hertz {
|
||||||
/// Create a `Hertz` from the given hertz.
|
/// Create a `Hertz` from the given hertz.
|
||||||
pub const fn hz(hertz: u32) -> Self {
|
pub const fn hz(hertz: u32) -> Self {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user