tm1637_embedded_hal

Struct TM1637

Source
pub struct TM1637<const N: usize, T, CLK, DIO, DELAY> { /* private fields */ }
Expand description

TM1637 7-segment display driver.

§Type parameters

  • N: Number of positions on the display. 4 or 6.
  • T: Operating mode. Async or Blocking.
  • CLK: Clock.
  • DIO: Data input/output.
  • DELAY: Delay provider.

Implementations§

Source§

impl<const N: usize, CLK, DIO, DELAY, ERR> TM1637<N, Async, CLK, DIO, DELAY>
where CLK: OutputPin<Error = ERR>, DIO: OutputPin<Error = ERR> + ConditionalInputPin<ERR>, DELAY: DelayNs,

Source

pub async fn init(&mut self) -> Result<(), Error<ERR>>

Initialize the display.

Clear the display and set the brightness level.

Source

pub async fn on(&mut self) -> Result<(), Error<ERR>>

Turn the display on.

Source

pub async fn off(&mut self) -> Result<(), Error<ERR>>

Turn the display off.

Source

pub async fn clear(&mut self) -> Result<(), Error<ERR>>

Clear the display.

Source

pub async fn set_brightness( &mut self, brightness: Brightness, ) -> Result<(), Error<ERR>>

Set TM1637::brightness and write the brightness level to the display.

Source

pub async fn display( &mut self, position: usize, bytes: impl Iterator<Item = u8>, ) -> Result<(), Error<ERR>>

Write the given bytes to the display starting from position.

Brightness level will not be written to the device on each call. Make sure to call TM1637::set_brightness or TM1637::init to set the brightness level.

Source

pub async fn display_slice( &mut self, position: usize, bytes: &[u8], ) -> Result<(), Error<ERR>>

Write the given bytes slice to the display starting from position.

See TM1637::display.

Source

pub fn options( &mut self, ) -> DisplayOptions<'_, N, Async, CLK, DIO, DELAY, impl DoubleEndedIterator<Item = u8> + ExactSizeIterator, NotFlipped>

High-level API for static or animated display operations.

§Example

Scroll the text “Error” with a dot on the first position from right to left with a delay of 700ms.

use tm1637_embedded_hal::{mock::Noop, options::{ScrollDirection, ScrollStyle}, TM1637Builder};

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

tm.options()
    .str("Error")
    .dot(1)
    .scroll()
    .delay_ms(700)
    .direction(ScrollDirection::RightToLeft)
    .style(ScrollStyle::Circular)
    .finish()
    .run();
Source

pub fn circles( &mut self, ) -> CirclesDisplayOptions<'_, N, Async, CLK, DIO, DELAY>

High-level API for animated circles (loading spinner).

Source§

impl<const N: usize, CLK, DIO, DELAY, ERR> TM1637<N, Blocking, CLK, DIO, DELAY>
where CLK: OutputPin<Error = ERR>, DIO: OutputPin<Error = ERR> + ConditionalInputPin<ERR>, DELAY: DelayNs,

Source

pub fn init(&mut self) -> Result<(), Error<ERR>>

Initialize the display.

Clear the display and set the brightness level.

Source

pub fn on(&mut self) -> Result<(), Error<ERR>>

Turn the display on.

Source

pub fn off(&mut self) -> Result<(), Error<ERR>>

Turn the display off.

Source

pub fn clear(&mut self) -> Result<(), Error<ERR>>

Clear the display.

Source

pub fn set_brightness( &mut self, brightness: Brightness, ) -> Result<(), Error<ERR>>

Set TM1637::brightness and write the brightness level to the display.

Source

pub fn display( &mut self, position: usize, bytes: impl Iterator<Item = u8>, ) -> Result<(), Error<ERR>>

Write the given bytes to the display starting from position.

Brightness level will not be written to the device on each call. Make sure to call TM1637::set_brightness or TM1637::init to set the brightness level.

Source

pub fn display_slice( &mut self, position: usize, bytes: &[u8], ) -> Result<(), Error<ERR>>

Write the given bytes slice to the display starting from position.

See TM1637::display.

Source

pub fn options( &mut self, ) -> DisplayOptions<'_, N, Blocking, CLK, DIO, DELAY, impl DoubleEndedIterator<Item = u8> + ExactSizeIterator, NotFlipped>

High-level API for static or animated display operations.

§Example

Scroll the text “Error” with a dot on the first position from right to left with a delay of 700ms.

use tm1637_embedded_hal::{mock::Noop, options::{ScrollDirection, ScrollStyle}, TM1637Builder};

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

tm.options()
    .str("Error")
    .dot(1)
    .scroll()
    .delay_ms(700)
    .direction(ScrollDirection::RightToLeft)
    .style(ScrollStyle::Circular)
    .finish()
    .run();
Source

pub fn circles( &mut self, ) -> CirclesDisplayOptions<'_, N, Blocking, CLK, DIO, DELAY>

High-level API for animated circles (loading spinner).

Source§

impl<const N: usize, T, CLK, DIO, DELAY> TM1637<N, T, CLK, DIO, DELAY>

Source

pub const fn new( clk: CLK, dio: DIO, delay: DELAY, brightness: Brightness, delay_us: u32, ) -> Self

Create a new TM1637 instance.

Source

pub const fn builder( clk: CLK, dio: DIO, delay: DELAY, ) -> TM1637Builder<CLK, DIO, DELAY>

Create a new TM1637Builder instance.

See TM1637Builder::new for default values.

Source

pub const fn num_positions(&self) -> usize

Get the number of positions on the display.

Source

pub const fn brightness(&self) -> Brightness

Get the brightness level.

Source

pub const fn delay_us(&self) -> u32

Get the delay in microseconds.

Source

pub const fn clk(&self) -> &CLK

Get a reference to the clock pin.

Source

pub fn clk_mut(&mut self) -> &mut CLK

Get a mutable reference to the clock pin.

Source

pub const fn dio(&self) -> &DIO

Get a reference to the data input/output pin.

Source

pub fn dio_mut(&mut self) -> &mut DIO

Get a mutable reference to the data input/output pin.

Source

pub const fn delay(&self) -> &DELAY

Get a reference to the delay provider.

Source

pub fn delay_mut(&mut self) -> &mut DELAY

Get a mutable reference to the delay provider.

Source

pub fn into_parts(self) -> (CLK, DIO, DELAY)

Split the TM1637 instance into its parts.

Trait Implementations§

Source§

impl<const N: usize, T: Clone, CLK: Clone, DIO: Clone, DELAY: Clone> Clone for TM1637<N, T, CLK, DIO, DELAY>

Source§

fn clone(&self) -> TM1637<N, T, CLK, DIO, DELAY>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<const N: usize, T: Debug, CLK: Debug, DIO: Debug, DELAY: Debug> Debug for TM1637<N, T, CLK, DIO, DELAY>

Source§

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

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

impl<const N: usize, T, CLK, DIO, DELAY> Format for TM1637<N, T, CLK, DIO, DELAY>
where CLK: Format, DIO: Format, DELAY: Format, Brightness: Format, PhantomData<T>: Format,

Source§

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

Writes the defmt representation of self to fmt.

Auto Trait Implementations§

§

impl<const N: usize, T, CLK, DIO, DELAY> Freeze for TM1637<N, T, CLK, DIO, DELAY>
where CLK: Freeze, DIO: Freeze, DELAY: Freeze,

§

impl<const N: usize, T, CLK, DIO, DELAY> RefUnwindSafe for TM1637<N, T, CLK, DIO, DELAY>

§

impl<const N: usize, T, CLK, DIO, DELAY> Send for TM1637<N, T, CLK, DIO, DELAY>
where CLK: Send, DIO: Send, DELAY: Send, T: Send,

§

impl<const N: usize, T, CLK, DIO, DELAY> Sync for TM1637<N, T, CLK, DIO, DELAY>
where CLK: Sync, DIO: Sync, DELAY: Sync, T: Sync,

§

impl<const N: usize, T, CLK, DIO, DELAY> Unpin for TM1637<N, T, CLK, DIO, DELAY>
where CLK: Unpin, DIO: Unpin, DELAY: Unpin, T: Unpin,

§

impl<const N: usize, T, CLK, DIO, DELAY> UnwindSafe for TM1637<N, T, CLK, DIO, DELAY>
where CLK: UnwindSafe, DIO: UnwindSafe, DELAY: UnwindSafe, T: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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.