pub struct TM1637<const N: usize, T, CLK, DIO, DELAY> { /* private fields */ }
Expand description
Implementations§
Source§impl<const N: usize, CLK, DIO, DELAY, ERR> TM1637<N, Async, CLK, DIO, DELAY>
impl<const N: usize, CLK, DIO, DELAY, ERR> TM1637<N, Async, CLK, DIO, DELAY>
Sourcepub async fn init(&mut self) -> Result<(), Error<ERR>>
pub async fn init(&mut self) -> Result<(), Error<ERR>>
Initialize the display.
Clear the display and set the brightness level.
Sourcepub async fn set_brightness(
&mut self,
brightness: Brightness,
) -> Result<(), Error<ERR>>
pub async fn set_brightness( &mut self, brightness: Brightness, ) -> Result<(), Error<ERR>>
Set TM1637::brightness
and write the brightness level to the display.
Sourcepub async fn display(
&mut self,
position: usize,
bytes: impl Iterator<Item = u8>,
) -> Result<(), Error<ERR>>
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.
Sourcepub async fn display_slice(
&mut self,
position: usize,
bytes: &[u8],
) -> Result<(), Error<ERR>>
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
.
Sourcepub fn options(
&mut self,
) -> DisplayOptions<'_, N, Async, CLK, DIO, DELAY, impl DoubleEndedIterator<Item = u8> + ExactSizeIterator, NotFlipped>
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();
Sourcepub fn circles(
&mut self,
) -> CirclesDisplayOptions<'_, N, Async, CLK, DIO, DELAY>
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>
impl<const N: usize, CLK, DIO, DELAY, ERR> TM1637<N, Blocking, CLK, DIO, DELAY>
Sourcepub fn init(&mut self) -> Result<(), Error<ERR>>
pub fn init(&mut self) -> Result<(), Error<ERR>>
Initialize the display.
Clear the display and set the brightness level.
Sourcepub fn set_brightness(
&mut self,
brightness: Brightness,
) -> Result<(), Error<ERR>>
pub fn set_brightness( &mut self, brightness: Brightness, ) -> Result<(), Error<ERR>>
Set TM1637::brightness
and write the brightness level to the display.
Sourcepub fn display(
&mut self,
position: usize,
bytes: impl Iterator<Item = u8>,
) -> Result<(), Error<ERR>>
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.
Sourcepub fn display_slice(
&mut self,
position: usize,
bytes: &[u8],
) -> Result<(), Error<ERR>>
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
.
Sourcepub fn options(
&mut self,
) -> DisplayOptions<'_, N, Blocking, CLK, DIO, DELAY, impl DoubleEndedIterator<Item = u8> + ExactSizeIterator, NotFlipped>
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();
Sourcepub fn circles(
&mut self,
) -> CirclesDisplayOptions<'_, N, Blocking, CLK, DIO, DELAY>
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>
impl<const N: usize, T, CLK, DIO, DELAY> TM1637<N, T, CLK, DIO, DELAY>
Sourcepub const fn new(
clk: CLK,
dio: DIO,
delay: DELAY,
brightness: Brightness,
delay_us: u32,
) -> Self
pub const fn new( clk: CLK, dio: DIO, delay: DELAY, brightness: Brightness, delay_us: u32, ) -> Self
Create a new TM1637
instance.
Sourcepub const fn builder(
clk: CLK,
dio: DIO,
delay: DELAY,
) -> TM1637Builder<CLK, DIO, DELAY>
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.
Sourcepub const fn num_positions(&self) -> usize
pub const fn num_positions(&self) -> usize
Get the number of positions on the display.
Sourcepub const fn brightness(&self) -> Brightness
pub const fn brightness(&self) -> Brightness
Get the brightness level.
Sourcepub fn delay_mut(&mut self) -> &mut DELAY
pub fn delay_mut(&mut self) -> &mut DELAY
Get a mutable reference to the delay provider.
Sourcepub fn into_parts(self) -> (CLK, DIO, DELAY)
pub fn into_parts(self) -> (CLK, DIO, DELAY)
Split the TM1637
instance into its parts.