tm1637_embedded_hal::options

Struct DisplayOptions

Source
pub struct DisplayOptions<'d, const N: usize, T, CLK, DIO, DELAY, I, M> { /* private fields */ }
Expand description

High-level API for display operations.

Implementations§

Source§

impl<CLK, DIO, DELAY, ERR, I, M> DisplayOptions<'_, 4, Async, CLK, DIO, DELAY, I, M>
where CLK: OutputPin<Error = ERR>, DIO: OutputPin<Error = ERR> + ConditionalInputPin<ERR>, DELAY: DelayNs, I: DoubleEndedIterator<Item = u8> + ExactSizeIterator, M: MaybeFlipped<4>,

Source

pub fn calculate(self) -> (usize, impl Iterator<Item = u8>)

Release the device and return the calculated position and bytes.

Source

pub async fn display(self) -> Result<(), Error<ERR>>

Display the bytes on a flipped or non-flipped display.

Source§

impl<CLK, DIO, DELAY, ERR, I, M> DisplayOptions<'_, 6, Async, CLK, DIO, DELAY, I, M>
where CLK: OutputPin<Error = ERR>, DIO: OutputPin<Error = ERR> + ConditionalInputPin<ERR>, DELAY: DelayNs, I: DoubleEndedIterator<Item = u8> + ExactSizeIterator, M: MaybeFlipped<6>,

Source

pub fn calculate(self) -> (usize, impl Iterator<Item = u8>)

Release the device and return the calculated position and bytes.

Source

pub async fn display(self) -> Result<(), Error<ERR>>

Display the bytes on a flipped or non-flipped display.

Source§

impl<CLK, DIO, DELAY, ERR, I, M> DisplayOptions<'_, 4, Blocking, CLK, DIO, DELAY, I, M>
where CLK: OutputPin<Error = ERR>, DIO: OutputPin<Error = ERR> + ConditionalInputPin<ERR>, DELAY: DelayNs, I: DoubleEndedIterator<Item = u8> + ExactSizeIterator, M: MaybeFlipped<4>,

Source

pub fn calculate(self) -> (usize, impl Iterator<Item = u8>)

Release the device and return the calculated position and bytes.

Source

pub fn display(self) -> Result<(), Error<ERR>>

Display the bytes on a flipped or non-flipped display.

Source§

impl<CLK, DIO, DELAY, ERR, I, M> DisplayOptions<'_, 6, Blocking, CLK, DIO, DELAY, I, M>
where CLK: OutputPin<Error = ERR>, DIO: OutputPin<Error = ERR> + ConditionalInputPin<ERR>, DELAY: DelayNs, I: DoubleEndedIterator<Item = u8> + ExactSizeIterator, M: MaybeFlipped<6>,

Source

pub fn calculate(self) -> (usize, impl Iterator<Item = u8>)

Release the device and return the calculated position and bytes.

Source

pub fn display(self) -> Result<(), Error<ERR>>

Display the bytes on a flipped or non-flipped display.

Source§

impl<'d, 'b, const N: usize, T, CLK, DIO, DELAY, I, M> DisplayOptions<'d, N, T, CLK, DIO, DELAY, I, M>

Source

pub fn new( device: &'d mut TM1637<N, T, CLK, DIO, DELAY>, ) -> DisplayOptions<'d, N, T, CLK, DIO, DELAY, Empty<u8>, NotFlipped>

Create a new DisplayOptions instance.

Source

pub const fn position(self, position: usize) -> Self

Set the position on the display from which to start displaying the bytes.

Source

pub fn slice( self, bytes: &'b [u8], ) -> DisplayOptions<'d, N, T, CLK, DIO, DELAY, impl DoubleEndedIterator<Item = u8> + ExactSizeIterator + 'b, M>
where I: DoubleEndedIterator<Item = u8> + ExactSizeIterator + 'b,

Add a slice of bytes.

Source

pub fn str( self, str: &'b str, ) -> DisplayOptions<'d, N, T, CLK, DIO, DELAY, impl DoubleEndedIterator<Item = u8> + ExactSizeIterator + 'b, M>
where I: DoubleEndedIterator<Item = u8> + ExactSizeIterator + 'b,

Add a string.

Source

pub fn iter<It>( self, iter: It, ) -> DisplayOptions<'d, N, T, CLK, DIO, DELAY, impl DoubleEndedIterator<Item = u8> + ExactSizeIterator, M>

Add an iterator of bytes.

§Example

Manually map each byte in a slice into a human readable character and set the dot at the 2nd position.

use tm1637_embedded_hal::{mappings::SegmentBits, mock::Noop, str::StrParser, TM1637Builder};

let mut tm = TM1637Builder::new(Noop, Noop, Noop).build_blocking::<4>();

tm.options()
    .iter(StrParser::new("HELLO").enumerate().map(move |(i, b)| {
        if i == 1 {
            b | SegmentBits::Dot as u8
        } else {
            b
        }
    }))
    .display()
    .ok();

// Equivalent to

tm.options()
   .str("HELLO")
   .dot(1)
   .display()
   .ok();
Source

pub fn clock(self) -> ClockDisplayOptions<'d, N, T, CLK, DIO, DELAY, I, M>

Prepare to display a digital clock.

See ClockDisplayOptions.

Source

pub fn scroll(self) -> ScrollDisplayOptions<'d, N, T, CLK, DIO, DELAY, I, M>

Use scroll animation options.

Source

pub fn repeat(self) -> RepeatDisplayOptions<'d, N, T, CLK, DIO, DELAY, I, M>

Use repeat animation options.

Display all bytes of the given iterator on the same position.

See RepeatDisplayOptions.

Source

pub fn dot( self, position: usize, ) -> DisplayOptions<'d, N, T, CLK, DIO, DELAY, impl DoubleEndedIterator<Item = u8> + ExactSizeIterator, M>

Add a dynamic dot to the display at the specified position.

§Dynamic

The dot is tied to the byte at the specified position and will move with it.

Source

pub fn remove_dot( self, position: usize, ) -> DisplayOptions<'d, N, T, CLK, DIO, DELAY, impl DoubleEndedIterator<Item = u8> + ExactSizeIterator, M>

Remove the dot from the display at the specified position.

Source

pub fn set_dot( self, position: usize, dot: bool, ) -> DisplayOptions<'d, N, T, CLK, DIO, DELAY, impl DoubleEndedIterator<Item = u8> + ExactSizeIterator, M>

Set the dot at the specified position.

Source

pub fn dots( self, ) -> DisplayOptions<'d, N, T, CLK, DIO, DELAY, impl DoubleEndedIterator<Item = u8> + ExactSizeIterator, M>

Add dots to all positions in the display.

Source

pub fn remove_dots( self, ) -> DisplayOptions<'d, N, T, CLK, DIO, DELAY, impl DoubleEndedIterator<Item = u8> + ExactSizeIterator, M>

Remove dots from all positions in the display.

Source

pub fn map<F: FnMut(u8) -> u8>( self, f: F, ) -> DisplayOptions<'d, N, T, CLK, DIO, DELAY, impl DoubleEndedIterator<Item = u8> + ExactSizeIterator, M>

Map the bytes using the provided function.

§Example

Manually map each byte in a slice into a human readable character.

use tm1637_embedded_hal::{mappings::from_ascii_byte, mock::Noop, TM1637Builder};

let mut tm = TM1637Builder::new(Noop, Noop, Noop).build_blocking::<4>();

tm.options()
    .slice(b"HELLO")
    .map(from_ascii_byte)
    .display()
    .ok();

// Equivalent** to

tm.options()
   .str("HELLO")
   .display()
   .ok();

** The DisplayOptions::str method uses StrParser internally.

Source

pub fn flip( self, ) -> DisplayOptions<'d, N, T, CLK, DIO, DELAY, impl DoubleEndedIterator<Item = u8> + ExactSizeIterator, impl MaybeFlipped<N>>
where I: DoubleEndedIterator<Item = u8> + ExactSizeIterator, M: MaybeFlipped<N>,

Flip the display.

Source§

impl<'d, const N: usize, T, CLK, DIO, DELAY, I, M> DisplayOptions<'d, N, T, CLK, DIO, DELAY, I, M>

Source

pub fn u8( self, n: u8, ) -> DisplayOptions<'d, N, T, CLK, DIO, DELAY, impl DoubleEndedIterator<Item = u8> + ExactSizeIterator, M>

See u8

Source§

impl<'d, const N: usize, T, CLK, DIO, DELAY, I, M> DisplayOptions<'d, N, T, CLK, DIO, DELAY, I, M>

Source

pub fn u8_2( self, n: u8, ) -> DisplayOptions<'d, N, T, CLK, DIO, DELAY, impl DoubleEndedIterator<Item = u8> + ExactSizeIterator, M>

See u8_2

Source§

impl<'d, const N: usize, T, CLK, DIO, DELAY, I, M> DisplayOptions<'d, N, T, CLK, DIO, DELAY, I, M>

Source

pub fn r_u8_2( self, n: u8, ) -> DisplayOptions<'d, N, T, CLK, DIO, DELAY, impl DoubleEndedIterator<Item = u8> + ExactSizeIterator, M>

See r_u8_2

Source§

impl<'d, const N: usize, T, CLK, DIO, DELAY, I, M> DisplayOptions<'d, N, T, CLK, DIO, DELAY, I, M>

Source

pub fn u16_3( self, n: u16, ) -> DisplayOptions<'d, N, T, CLK, DIO, DELAY, impl DoubleEndedIterator<Item = u8> + ExactSizeIterator, M>

See u16_3

Source§

impl<'d, const N: usize, T, CLK, DIO, DELAY, I, M> DisplayOptions<'d, N, T, CLK, DIO, DELAY, I, M>

Source

pub fn r_u16_3( self, n: u16, ) -> DisplayOptions<'d, N, T, CLK, DIO, DELAY, impl DoubleEndedIterator<Item = u8> + ExactSizeIterator, M>

See r_u16_3

Source§

impl<'d, const N: usize, T, CLK, DIO, DELAY, I, M> DisplayOptions<'d, N, T, CLK, DIO, DELAY, I, M>

Source

pub fn u16_4( self, n: u16, ) -> DisplayOptions<'d, N, T, CLK, DIO, DELAY, impl DoubleEndedIterator<Item = u8> + ExactSizeIterator, M>

See u16_4

Source§

impl<'d, const N: usize, T, CLK, DIO, DELAY, I, M> DisplayOptions<'d, N, T, CLK, DIO, DELAY, I, M>

Source

pub fn r_u16_4( self, n: u16, ) -> DisplayOptions<'d, N, T, CLK, DIO, DELAY, impl DoubleEndedIterator<Item = u8> + ExactSizeIterator, M>

See r_u16_4

Source§

impl<'d, const N: usize, T, CLK, DIO, DELAY, I, M> DisplayOptions<'d, N, T, CLK, DIO, DELAY, I, M>

Source

pub fn u32_5( self, n: u32, ) -> DisplayOptions<'d, N, T, CLK, DIO, DELAY, impl DoubleEndedIterator<Item = u8> + ExactSizeIterator, M>

See u32_5

Source§

impl<'d, const N: usize, T, CLK, DIO, DELAY, I, M> DisplayOptions<'d, N, T, CLK, DIO, DELAY, I, M>

Source

pub fn r_u32_5( self, n: u32, ) -> DisplayOptions<'d, N, T, CLK, DIO, DELAY, impl DoubleEndedIterator<Item = u8> + ExactSizeIterator, M>

See r_u32_5

Source§

impl<'d, const N: usize, T, CLK, DIO, DELAY, I, M> DisplayOptions<'d, N, T, CLK, DIO, DELAY, I, M>

Source

pub fn u32_6( self, n: u32, ) -> DisplayOptions<'d, N, T, CLK, DIO, DELAY, impl DoubleEndedIterator<Item = u8> + ExactSizeIterator, M>

See u32_6

Source§

impl<'d, const N: usize, T, CLK, DIO, DELAY, I, M> DisplayOptions<'d, N, T, CLK, DIO, DELAY, I, M>

Source

pub fn r_u32_6( self, n: u32, ) -> DisplayOptions<'d, N, T, CLK, DIO, DELAY, impl DoubleEndedIterator<Item = u8> + ExactSizeIterator, M>

See r_u32_6

Source§

impl<'d, const N: usize, T, CLK, DIO, DELAY, I, M> DisplayOptions<'d, N, T, CLK, DIO, DELAY, I, M>

Source

pub fn i8_2( self, n: i8, ) -> DisplayOptions<'d, N, T, CLK, DIO, DELAY, impl DoubleEndedIterator<Item = u8> + ExactSizeIterator, M>

See i8_2

Source§

impl<'d, const N: usize, T, CLK, DIO, DELAY, I, M> DisplayOptions<'d, N, T, CLK, DIO, DELAY, I, M>

Source

pub fn i16_3( self, n: i16, ) -> DisplayOptions<'d, N, T, CLK, DIO, DELAY, impl DoubleEndedIterator<Item = u8> + ExactSizeIterator, M>

See i16_3

Source§

impl<'d, const N: usize, T, CLK, DIO, DELAY, I, M> DisplayOptions<'d, N, T, CLK, DIO, DELAY, I, M>

Source

pub fn r_i16_3( self, n: i16, ) -> DisplayOptions<'d, N, T, CLK, DIO, DELAY, impl DoubleEndedIterator<Item = u8> + ExactSizeIterator, M>

See r_i16_3

Source§

impl<'d, const N: usize, T, CLK, DIO, DELAY, I, M> DisplayOptions<'d, N, T, CLK, DIO, DELAY, I, M>

Source

pub fn i16_4( self, n: i16, ) -> DisplayOptions<'d, N, T, CLK, DIO, DELAY, impl DoubleEndedIterator<Item = u8> + ExactSizeIterator, M>

See i16_4

Source§

impl<'d, const N: usize, T, CLK, DIO, DELAY, I, M> DisplayOptions<'d, N, T, CLK, DIO, DELAY, I, M>

Source

pub fn r_i16_4( self, n: i16, ) -> DisplayOptions<'d, N, T, CLK, DIO, DELAY, impl DoubleEndedIterator<Item = u8> + ExactSizeIterator, M>

See r_i16_4

Source§

impl<'d, const N: usize, T, CLK, DIO, DELAY, I, M> DisplayOptions<'d, N, T, CLK, DIO, DELAY, I, M>

Source

pub fn i32_5( self, n: i32, ) -> DisplayOptions<'d, N, T, CLK, DIO, DELAY, impl DoubleEndedIterator<Item = u8> + ExactSizeIterator, M>

See i32_5

Source§

impl<'d, const N: usize, T, CLK, DIO, DELAY, I, M> DisplayOptions<'d, N, T, CLK, DIO, DELAY, I, M>

Source

pub fn r_i32_5( self, n: i32, ) -> DisplayOptions<'d, N, T, CLK, DIO, DELAY, impl DoubleEndedIterator<Item = u8> + ExactSizeIterator, M>

See r_i32_5

Source§

impl<'d, const N: usize, T, CLK, DIO, DELAY, I, M> DisplayOptions<'d, N, T, CLK, DIO, DELAY, I, M>

Source

pub fn i32_6( self, n: i32, ) -> DisplayOptions<'d, N, T, CLK, DIO, DELAY, impl DoubleEndedIterator<Item = u8> + ExactSizeIterator, M>

See i32_6

Source§

impl<'d, const N: usize, T, CLK, DIO, DELAY, I, M> DisplayOptions<'d, N, T, CLK, DIO, DELAY, I, M>

Source

pub fn r_i32_6( self, n: i32, ) -> DisplayOptions<'d, N, T, CLK, DIO, DELAY, impl DoubleEndedIterator<Item = u8> + ExactSizeIterator, M>

See r_i32_6

Trait Implementations§

Source§

impl<'d, const N: usize, T: Debug, CLK: Debug, DIO: Debug, DELAY: Debug, I: Debug, M: Debug> Debug for DisplayOptions<'d, N, T, CLK, DIO, DELAY, I, M>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'d, const N: usize, T, CLK, DIO, DELAY, I, M> Format for DisplayOptions<'d, N, T, CLK, DIO, DELAY, I, M>
where &'d mut TM1637<N, T, CLK, DIO, DELAY>: Format, I: Format, M: Format,

Source§

fn format(&self, f: Formatter<'_>)

Writes the defmt representation of self to fmt.

Auto Trait Implementations§

§

impl<'d, const N: usize, T, CLK, DIO, DELAY, I, M> Freeze for DisplayOptions<'d, N, T, CLK, DIO, DELAY, I, M>
where I: Freeze, M: Freeze,

§

impl<'d, const N: usize, T, CLK, DIO, DELAY, I, M> RefUnwindSafe for DisplayOptions<'d, N, T, CLK, DIO, DELAY, I, M>

§

impl<'d, const N: usize, T, CLK, DIO, DELAY, I, M> Send for DisplayOptions<'d, N, T, CLK, DIO, DELAY, I, M>
where I: Send, M: Send, CLK: Send, DIO: Send, DELAY: Send, T: Send,

§

impl<'d, const N: usize, T, CLK, DIO, DELAY, I, M> Sync for DisplayOptions<'d, N, T, CLK, DIO, DELAY, I, M>
where I: Sync, M: Sync, CLK: Sync, DIO: Sync, DELAY: Sync, T: Sync,

§

impl<'d, const N: usize, T, CLK, DIO, DELAY, I, M> Unpin for DisplayOptions<'d, N, T, CLK, DIO, DELAY, I, M>
where I: Unpin, M: Unpin,

§

impl<'d, const N: usize, T, CLK, DIO, DELAY, I, M> !UnwindSafe for DisplayOptions<'d, N, T, CLK, DIO, DELAY, I, M>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.