pub fn i16_to_4digits(n: i16) -> [u8; 4]
Available on crate feature
formatters
only.Expand description
Formats a i16
clamped between -999
and 9999
, for a 4-digit display
.
§Example
A counter that goes from -100
to 100
:
ⓘ
let mut tm = TM1637::builder(clk_pin, dio_pin, delay)
.brightness(Brightness::L3)
.build();
tm.init().ok();
for i in -100..100 {
let segs = i16_to_4digits(i);
tm.write_segments_raw(0, &segs).ok();
delay.delay_ms(100u16);
}