pub fn clock_to_4digits(hour: u8, minute: u8, colon: bool) -> [u8; 4]
Expand description
Formats two u8
s between 0
and 99
, with an optional colon between them.
This will only work for 4-digit displays
where there’s a physical colon,
and that colon acts as the decimal dot between the 2nd and 3rd digit.
§Example
Let’s create a clock displaying 12:34
with a blinking colon:
use tm1637_embedded_hal::{formatters::clock_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 hour in 12..24 {
for minute in 34..60 {
for second in 0..120 {
let blink = second % 2 == 0;
let segs = clock_to_4digits(hour, minute, blink);
tm.display_slice(0, &segs).ok();
delay.delay_ms(500);
}
}
}