pub fn i16_to_4digits(n: i16) -> [u8; 4]
Expand description
Formats a i16
clamped between -999
and 9999
, for a 4-digit display
.
ยงExample
A counter that goes from -100
to 100
:
use tm1637_embedded_hal::{formatters::i16_to_4digits, mock::Noop, TM1637Builder};
use embedded_hal::delay::DelayNs;
let mut delay = Noop;
let mut tm = TM1637Builder::new(Noop, Noop, Noop).build_blocking::<4>();
tm.init().ok();
for i in -100..100 {
let segs = i16_to_4digits(i);
tm.display_slice(0, &segs).ok();
delay.delay_ms(100);
}