pub fn clock_to_4digits(hour: u8, minute: u8, colon: bool) -> [u8; 4]
Available on crate feature
formatters
only.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:
ⓘ
let mut tm = TM1637::builder(clk_pin, dio_pin, delay)
.brightness(Brightness::L3)
.build();
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.write_segments_raw(0, &segs).ok();
delay.delay_ms(500);
}
}
}