pub struct Pattern { /* private fields */ }Expand description
A blinking pattern encoded as a u32
These patterns are used with a Blinq
Implementations§
Source§impl Pattern
impl Pattern
Sourcepub const fn from_u32(pattern: u32, used: u8) -> Self
pub const fn from_u32(pattern: u32, used: u8) -> Self
Create a new pattern from a u32
Note: if used is larger than 32, it will cause a compile time error.
In the future this will silently truncate to 32.
§Example
use blinq::Pattern;
// This is a blink with a 25% on, 75% off duty cycle
let on_off = Pattern::from_u32(0b1000, 4);Sourcepub const fn append(&self, other: &Pattern) -> Pattern
pub const fn append(&self, other: &Pattern) -> Pattern
Create new pattern by appending one to the other
Note: If self.used + other.used is greater than 32, the pattern will be truncated. If self.used is greater than 32, this will fail to compile. In the future, this will silently truncate to 32.
§Example
use blinq::Pattern;
// This is on for a single step
let on = Pattern::from_u32(0b1, 1);
// This is off for three steps
let off = Pattern::from_u32(0b000, 3);
// This is on for a single step, then off for 3
let on_off = on.append(&off);Sourcepub const fn reverse(&self) -> Pattern
pub const fn reverse(&self) -> Pattern
Reverse the bit pattern, keeping the same length
§Example
use blinq::Pattern;
// This is a blink with a 25% on, 75% off duty cycle
let on_off = Pattern::from_u32(0b1000, 4);
// This is a blink with a 75% off, 25% on duty cycle
let off_on = on_off.reverse();Trait Implementations§
Auto Trait Implementations§
impl Freeze for Pattern
impl RefUnwindSafe for Pattern
impl Send for Pattern
impl Sync for Pattern
impl Unpin for Pattern
impl UnwindSafe for Pattern
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more