@@ -76,6 +76,8 @@ pub const SMALL_FONT: MonoTextStyle<'_, BinaryColor> = MonoTextStyle::new(
7676) ;
7777pub const TIMER_FONT : MonoTextStyle < ' _ , BinaryColor > =
7878 MonoTextStyle :: new ( & profont:: PROFONT_14_POINT , BinaryColor :: On ) ;
79+ pub const SMALL_TIMER_FONT : MonoTextStyle < ' _ , BinaryColor > =
80+ MonoTextStyle :: new ( & profont:: PROFONT_7_POINT , BinaryColor :: On ) ;
7981
8082pub const TEXT_CENTER : TextStyle = TextStyleBuilder :: new ( )
8183 . alignment ( Alignment :: Center )
@@ -675,7 +677,6 @@ async fn process_main(
675677 Scene :: Finished => {
676678 let solve_time = current_state. solve_time . unwrap_or ( 0 ) ;
677679 let time_str = ms_to_time_str ( solve_time) ;
678-
679680 let inspection_time =
680681 match ( current_state. inspection_start , current_state. inspection_end ) {
681682 ( Some ( start) , Some ( end) ) => {
@@ -684,15 +685,12 @@ async fn process_main(
684685 _ => None ,
685686 } ;
686687
687- let time_display = if current_state. use_inspection ( )
688- && inspection_time. unwrap_or ( 0 ) > INSPECTION_TIME_PLUS2
689- {
690- let inspection_seconds = inspection_time. unwrap_or ( 0 ) / 1000 ;
691- alloc:: format!( "{time_str}+{inspection_seconds}s" )
692- } else {
693- alloc:: format!( "{time_str}" )
694- } ;
688+ let show_inspection = current_state. use_inspection ( )
689+ && inspection_time. unwrap_or ( 0 ) > INSPECTION_TIME_PLUS2 ;
690+ let inspection_display =
691+ show_inspection. then ( || ms_to_time_str ( inspection_time. unwrap_or ( 0 ) ) ) ;
695692
693+ let time_display = alloc:: format!( "{time_str}" ) ;
696694 let penalty = current_state. penalty . unwrap_or ( 0 ) ;
697695 let penalty_str: alloc:: string:: String = match penalty {
698696 -2 => "DNS" . into ( ) ,
@@ -701,9 +699,64 @@ async fn process_main(
701699 _ => alloc:: string:: String :: new ( ) ,
702700 } ;
703701
704- if penalty_str. is_empty ( ) {
705- let time_text =
706- Text :: with_text_style ( & time_display, Point :: zero ( ) , TIMER_FONT , TEXT_CENTER ) ;
702+ let time_text =
703+ Text :: with_text_style ( & time_display, Point :: zero ( ) , TIMER_FONT , TEXT_CENTER ) ;
704+
705+ if let Some ( insp_str) = inspection_display {
706+ let insp_text =
707+ Text :: with_text_style ( & insp_str, Point :: zero ( ) , SMALL_TIMER_FONT , TEXT_CENTER ) ;
708+
709+ if penalty_str. is_empty ( ) {
710+ LinearLayout :: vertical (
711+ Chain :: new (
712+ LinearLayout :: horizontal ( Chain :: new ( time_text) )
713+ . with_alignment ( embedded_layout:: align:: vertical:: Center )
714+ . arrange ( ) ,
715+ )
716+ . append (
717+ LinearLayout :: horizontal ( Chain :: new ( insp_text) )
718+ . with_alignment ( embedded_layout:: align:: vertical:: Center )
719+ . arrange ( ) ,
720+ ) ,
721+ )
722+ . with_alignment ( embedded_layout:: align:: horizontal:: Center )
723+ . arrange ( )
724+ . align_to (
725+ & MAIN_RECT ,
726+ embedded_layout:: align:: horizontal:: Center ,
727+ embedded_layout:: align:: vertical:: Top ,
728+ )
729+ . translate ( Point :: new ( 0 , 2 ) )
730+ . draw ( & mut oled. fbuf ) ?;
731+ } else {
732+ let penalty_text =
733+ Text :: with_text_style ( & penalty_str, Point :: zero ( ) , TIMER_FONT , TEXT_CENTER ) ;
734+ LinearLayout :: vertical (
735+ Chain :: new (
736+ LinearLayout :: horizontal ( Chain :: new ( time_text) . append ( penalty_text) )
737+ . with_alignment ( embedded_layout:: align:: vertical:: Center )
738+ . with_spacing (
739+ embedded_layout:: layout:: linear:: spacing:: FixedMargin ( 4 ) ,
740+ )
741+ . arrange ( ) ,
742+ )
743+ . append (
744+ LinearLayout :: horizontal ( Chain :: new ( insp_text) )
745+ . with_alignment ( embedded_layout:: align:: vertical:: Center )
746+ . arrange ( ) ,
747+ ) ,
748+ )
749+ . with_alignment ( embedded_layout:: align:: horizontal:: Center )
750+ . arrange ( )
751+ . align_to (
752+ & MAIN_RECT ,
753+ embedded_layout:: align:: horizontal:: Center ,
754+ embedded_layout:: align:: vertical:: Top ,
755+ )
756+ . translate ( Point :: new ( 0 , 2 ) )
757+ . draw ( & mut oled. fbuf ) ?;
758+ }
759+ } else if penalty_str. is_empty ( ) {
707760 LinearLayout :: horizontal ( Chain :: new ( time_text) )
708761 . with_alignment ( embedded_layout:: align:: vertical:: Center )
709762 . arrange ( )
@@ -715,8 +768,6 @@ async fn process_main(
715768 . translate ( Point :: new ( 0 , 10 ) )
716769 . draw ( & mut oled. fbuf ) ?;
717770 } else {
718- let time_text =
719- Text :: with_text_style ( & time_display, Point :: zero ( ) , TIMER_FONT , TEXT_CENTER ) ;
720771 let penalty_text =
721772 Text :: with_text_style ( & penalty_str, Point :: zero ( ) , TIMER_FONT , TEXT_CENTER ) ;
722773 LinearLayout :: horizontal ( Chain :: new ( time_text) . append ( penalty_text) )
@@ -743,13 +794,11 @@ async fn process_main(
743794 } else {
744795 None
745796 } ;
746-
747797 if let Some ( status_str) = status {
748798 let textbox_style = TextBoxStyleBuilder :: new ( )
749799 . alignment ( HorizontalAlignment :: Center )
750800 . vertical_alignment ( VerticalAlignment :: Bottom )
751801 . build ( ) ;
752-
753802 TextBox :: with_textbox_style ( & status_str, MAIN_RECT , NORMAL_FONT , textbox_style)
754803 . draw ( & mut oled. fbuf ) ?;
755804 }
0 commit comments