[][src]Struct blinq::Pattern

pub struct Pattern { /* fields omitted */ }

A blinking pattern encoded as a u32

These patterns are used with a Blinq

Implementations

impl Pattern[src]

pub const fn from_u32(pattern: u32, used: u8) -> Self[src]

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);

pub const fn append(&self, other: &Pattern) -> Pattern[src]

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);

pub const fn reverse(&self) -> Pattern[src]

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

impl Clone for Pattern[src]

Auto Trait Implementations

impl Send for Pattern

impl Sync for Pattern

impl Unpin for Pattern

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.