tm1637_embedded_hal/options/
clock.rs1use crate::formatters::clock_to_4digits;
2
3use super::DisplayOptions;
4
5#[derive(Debug)]
35#[cfg_attr(feature = "defmt", derive(defmt::Format))]
36pub struct ClockDisplayOptions<'d, const N: usize, T, CLK, DIO, DELAY, I, M> {
37 options: DisplayOptions<'d, N, T, CLK, DIO, DELAY, I, M>,
38 hour: u8,
39 minute: u8,
40}
41
42impl<'d, const N: usize, T, CLK, DIO, DELAY, I, M>
43 ClockDisplayOptions<'d, N, T, CLK, DIO, DELAY, I, M>
44{
45 pub const fn new(options: DisplayOptions<'d, N, T, CLK, DIO, DELAY, I, M>) -> Self {
47 Self {
48 options,
49 hour: 0,
50 minute: 0,
51 }
52 }
53
54 pub const fn hour(mut self, hour: u8) -> Self {
56 self.hour = hour;
57 self
58 }
59
60 pub const fn minute(mut self, minute: u8) -> Self {
62 self.minute = minute;
63 self
64 }
65
66 pub fn finish(
68 self,
69 ) -> DisplayOptions<
70 'd,
71 N,
72 T,
73 CLK,
74 DIO,
75 DELAY,
76 impl DoubleEndedIterator<Item = u8> + ExactSizeIterator,
77 M,
78 >
79 where
80 I: DoubleEndedIterator<Item = u8> + ExactSizeIterator,
81 {
82 self.options
83 .iter(clock_to_4digits(self.hour, self.minute, false).into_iter())
84 }
85}