pub fn display_current_time_in_loop(adapter: &mut TM1637Adapter,
                            tick_fn: &dyn Fn(),
                            time_fn: &dyn Fn() -> (String, String)) {
    adapter.set_display_state(DisplayState::ON);
    adapter.set_brightness(Brightness::L7);

    let mut show_dots = false;
    loop {
        // could be hh:mm or mm::ss
        let (l, r): (String, String) = (time_fn)();
        let mut data: [u8; DISPLAY_COUNT] = [
            TM1637Adapter::encode_char(l.chars().nth(0).unwrap()),
            TM1637Adapter::encode_char(l.chars().nth(1).unwrap()),
            TM1637Adapter::encode_char(r.chars().nth(0).unwrap()),
            TM1637Adapter::encode_char(r.chars().nth(1).unwrap()),
        ];

        if show_dots {
            data[1] = data[1] | SegmentBits::SegPoint as u8;
        }

        adapter.write_segments_raw(&data, 0);

        (tick_fn)();

        show_dots = !show_dots;
    }
}
/// Displays "hh:mm" with blinking double point on the display.
/// Blocks the calling thread because this is an infinite loop.
Displays "hh:mm" with blinking double point on the display.
Blocks the calling thread because this is an infinite loop.
Displays " hh : mm " with blinking double point on the display . Blocks the calling thread because this is an infinite loop .
pub fn display_current_time_in_loop(adapter: &mut TM1637Adapter,
                            tick_fn: &dyn Fn(),
                            time_fn: &dyn Fn() -> (String, String)) {
    adapter.set_display_state(DisplayState::ON);
    adapter.set_brightness(Brightness::L7);
    let mut show_dots = false;
    loop {
        // could be hh:mm or mm::ss
        let (l, r): (String, String) = (time_fn)();
        let mut data: [u8; DISPLAY_COUNT] = [
            TM1637Adapter::encode_char(l.chars().nth(0).unwrap()),
            TM1637Adapter::encode_char(l.chars().nth(1).unwrap()),
            TM1637Adapter::encode_char(r.chars().nth(0).unwrap()),
            TM1637Adapter::encode_char(r.chars().nth(1).unwrap()),
        ];
        if show_dots {
            data[1] = data[1] | SegmentBits::SegPoint as u8;
        }
        adapter.write_segments_raw(&data, 0);
        (tick_fn)();
        show_dots = !show_dots;
    }
}
pub fn display_current_time_in_loop ( adapter : & mut TM1637Adapter , tick_fn : & dyn Fn ( ) , time_fn : & dyn Fn ( ) -> ( String , String ) ) { adapter . set_display_state ( DisplayState :: ON ) ; adapter . set_brightness ( Brightness :: L7 ) ; let mut show_dots = false ; loop { // could be hh:mm or mm::ss let ( l , r ) : ( String , String ) = ( time_fn ) ( ) ; let mut data : [ u8 ; DISPLAY_COUNT ] = [ TM1637Adapter :: encode_char ( l . chars ( ) . nth ( 0 ) . unwrap ( ) ) , TM1637Adapter :: encode_char ( l . chars ( ) . nth ( 1 ) . unwrap ( ) ) , TM1637Adapter :: encode_char ( r . chars ( ) . nth ( 0 ) . unwrap ( ) ) , TM1637Adapter :: encode_char ( r . chars ( ) . nth ( 1 ) . unwrap ( ) ) , ] ; if show_dots { data [ 1 ] = data [ 1 ] | SegmentBits :: SegPoint as u8 ; } adapter . write_segments_raw ( & data , 0 ) ; ( tick_fn ) ( ) ; show_dots = ! show_dots ; } }
Displays "hh:mm" with blinking double point on the display.
Displays " hh : mm " with blinking double point on the display .
adapter
&mut TM1637Adapter
tick_fn
&dyn Fn()
time_fn
&dyn Fn() -> (String, String)