@@ -662,39 +662,36 @@ bool ST7920_Lite_Status_Screen::indicators_changed() {
662662
663663// Process progress strings
664664#if HAS_PRINT_PROGRESS
665- static char screenstr[ 8 ] ;
665+ static MString< 8 > screenstr;
666666
667667 #if HAS_TIME_DISPLAY
668668 char * ST7920_Lite_Status_Screen::prepare_time_string (const duration_t &time, char prefix) {
669- static char str [6 ];
670- memset (&screenstr, ' ' , 8 ); // fill with spaces to avoid artifacts, not doing right-justification to save cycles
671- screenstr[ 0 ] = prefix;
672- TERN_ (HOTENDS == 1 , screenstr[ 1 ] = 0x07 ;) // add bullet • separator when there is space
673- int str_length = time. toDigital (str) ;
674- memcpy (& screenstr[ TERN (HOTENDS == 1 , 2 , 1 )], str, str_length); // memcpy because we can't have terminator
675- return screenstr;
669+ static char time_str [6 ];
670+ ( void )time. toDigital (time_str); // Up to 5 chars
671+ screenstr = prefix;
672+ if (HOTENDS == 1 ) screenstr += char ( 0x07 ); // Add bullet • separator when there is space
673+ screenstr += time_str ;
674+ screenstr += Spaces ( 3 );
675+ return & screenstr;
676676 }
677677 #endif
678678
679679 void ST7920_Lite_Status_Screen::draw_progress_string (uint8_t addr, const char *str) {
680680 set_ddram_address (addr);
681681 begin_data ();
682- write_str (str, TERN ( HOTENDS == 1 , 8 , 6 ) );
682+ write_str (str, HOTENDS == 1 ? 8 : 6 );
683683 }
684684
685- # define PPOS (DDRAM_LINE_3 + TERN (HOTENDS == 1 , 4 , 5 )) // progress string position, in 16-bit words
685+ constexpr uint8_t PPOS = (DDRAM_LINE_3 + (HOTENDS == 1 ? 4 : 5 )); // Progress string position, in 16-bit words
686686
687687 #if ENABLED(SHOW_PROGRESS_PERCENT)
688688 void MarlinUI::drawPercent () { lightUI.drawPercent (); }
689689 void ST7920_Lite_Status_Screen::drawPercent () {
690- #define LSHIFT TERN (HOTENDS == 1 , 0 , 1 )
691690 const uint8_t progress = ui.get_progress_percent ();
692- memset (&screenstr, ' ' , 8 ); // fill with spaces to avoid artifacts
693- if (progress){
694- memcpy (&screenstr[2 - LSHIFT], \
695- TERN (PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4 (ui.get_progress_permyriad ()), ui8tostr3rj (progress)), \
696- TERN (PRINT_PROGRESS_SHOW_DECIMALS, 4 , 3 ));
697- screenstr[(TERN (PRINT_PROGRESS_SHOW_DECIMALS, 6 , 5 ) - LSHIFT)] = ' %' ;
691+ if (progress) {
692+ screenstr += Spaces (1 + (HOTENDS == 1 ));
693+ screenstr += TERN (PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4 (ui.get_progress_permyriad ()), ui8tostr3rj (progress));
694+ screenstr += " % " ;
698695 draw_progress_string (PPOS, screenstr);
699696 }
700697 }
0 commit comments