diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 36291de0d3f334e07307e094e24eb2e959f65ef4..d593ed0957fb37ba25f5c40edee476247a426a23 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -442,6 +442,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// Scroll a longer status message into view +//#define STATUS_MESSAGE_SCROLLING + // On the Info Screen, display XY with one decimal place when possible //#define LCD_DECIMAL_SMALL_XY diff --git a/Marlin/example_configurations/Cartesio/Configuration_adv.h b/Marlin/example_configurations/Cartesio/Configuration_adv.h index 5a1184c930c809af2f57d99e3350f7877538c89f..a8f4c316651b630769aba99f889d8a4edaaf899f 100644 --- a/Marlin/example_configurations/Cartesio/Configuration_adv.h +++ b/Marlin/example_configurations/Cartesio/Configuration_adv.h @@ -442,6 +442,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// Scroll a longer status message into view +//#define STATUS_MESSAGE_SCROLLING + // On the Info Screen, display XY with one decimal place when possible //#define LCD_DECIMAL_SMALL_XY diff --git a/Marlin/example_configurations/Felix/Configuration_adv.h b/Marlin/example_configurations/Felix/Configuration_adv.h index a0daae4e64751163886bbd1820d85a4e4e7daabb..3132bf9ff55ea304bff0222fdef45566e57523de 100644 --- a/Marlin/example_configurations/Felix/Configuration_adv.h +++ b/Marlin/example_configurations/Felix/Configuration_adv.h @@ -442,6 +442,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// Scroll a longer status message into view +//#define STATUS_MESSAGE_SCROLLING + // On the Info Screen, display XY with one decimal place when possible //#define LCD_DECIMAL_SMALL_XY diff --git a/Marlin/example_configurations/FolgerTech-i3-2020/Configuration_adv.h b/Marlin/example_configurations/FolgerTech-i3-2020/Configuration_adv.h index 14488300c75fecd70f807b41ee0df0a298953d48..142cd1d241877ce961b4c439245410b8088388bf 100644 --- a/Marlin/example_configurations/FolgerTech-i3-2020/Configuration_adv.h +++ b/Marlin/example_configurations/FolgerTech-i3-2020/Configuration_adv.h @@ -442,6 +442,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// Scroll a longer status message into view +//#define STATUS_MESSAGE_SCROLLING + // On the Info Screen, display XY with one decimal place when possible //#define LCD_DECIMAL_SMALL_XY diff --git a/Marlin/example_configurations/Hephestos/Configuration_adv.h b/Marlin/example_configurations/Hephestos/Configuration_adv.h index e165a7fc3433776c15a03fb085ebe6506d88d986..171ab3e4d8d8b4890c0bbb33a6d052b870fbb66d 100644 --- a/Marlin/example_configurations/Hephestos/Configuration_adv.h +++ b/Marlin/example_configurations/Hephestos/Configuration_adv.h @@ -442,6 +442,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// Scroll a longer status message into view +//#define STATUS_MESSAGE_SCROLLING + // On the Info Screen, display XY with one decimal place when possible //#define LCD_DECIMAL_SMALL_XY diff --git a/Marlin/example_configurations/Hephestos_2/Configuration_adv.h b/Marlin/example_configurations/Hephestos_2/Configuration_adv.h index 7fe59aa6d12efa5d1ef935700d6d79707f6c7b77..fb7869435db5f06e0c301ef85f5083d3be081d76 100644 --- a/Marlin/example_configurations/Hephestos_2/Configuration_adv.h +++ b/Marlin/example_configurations/Hephestos_2/Configuration_adv.h @@ -443,6 +443,9 @@ // Include a page of printer information in the LCD Main Menu #define LCD_INFO_MENU +// Scroll a longer status message into view +//#define STATUS_MESSAGE_SCROLLING + // On the Info Screen, display XY with one decimal place when possible #define LCD_DECIMAL_SMALL_XY diff --git a/Marlin/example_configurations/K8200/Configuration_adv.h b/Marlin/example_configurations/K8200/Configuration_adv.h index 2311850eb0c8dbc6ec2f20918d612816c204fd2c..44aae82facc77675ad484bf73fe219047d7d6027 100644 --- a/Marlin/example_configurations/K8200/Configuration_adv.h +++ b/Marlin/example_configurations/K8200/Configuration_adv.h @@ -455,6 +455,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// Scroll a longer status message into view +//#define STATUS_MESSAGE_SCROLLING + // On the Info Screen, display XY with one decimal place when possible //#define LCD_DECIMAL_SMALL_XY diff --git a/Marlin/example_configurations/K8400/Configuration_adv.h b/Marlin/example_configurations/K8400/Configuration_adv.h index 538c121d8b85727c44cb3f43842ddce5b22808c3..a04d83baf8795ffc2239ff26e70a8cb2f92158bf 100644 --- a/Marlin/example_configurations/K8400/Configuration_adv.h +++ b/Marlin/example_configurations/K8400/Configuration_adv.h @@ -442,6 +442,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// Scroll a longer status message into view +//#define STATUS_MESSAGE_SCROLLING + // On the Info Screen, display XY with one decimal place when possible //#define LCD_DECIMAL_SMALL_XY diff --git a/Marlin/example_configurations/RigidBot/Configuration_adv.h b/Marlin/example_configurations/RigidBot/Configuration_adv.h index 0df6dfc187e0c116b1050ffd6d350ba24d17622a..3605da6a7446285ffa11c04bed41c9541e3d6d46 100644 --- a/Marlin/example_configurations/RigidBot/Configuration_adv.h +++ b/Marlin/example_configurations/RigidBot/Configuration_adv.h @@ -442,6 +442,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// Scroll a longer status message into view +//#define STATUS_MESSAGE_SCROLLING + // On the Info Screen, display XY with one decimal place when possible //#define LCD_DECIMAL_SMALL_XY diff --git a/Marlin/example_configurations/SCARA/Configuration_adv.h b/Marlin/example_configurations/SCARA/Configuration_adv.h index 60b47073cbdcfaaf754ab73251864ba0bfef669d..6bfee737ddfe1dba0cfca6c94e0c9a36e5654232 100644 --- a/Marlin/example_configurations/SCARA/Configuration_adv.h +++ b/Marlin/example_configurations/SCARA/Configuration_adv.h @@ -442,6 +442,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// Scroll a longer status message into view +//#define STATUS_MESSAGE_SCROLLING + // On the Info Screen, display XY with one decimal place when possible //#define LCD_DECIMAL_SMALL_XY diff --git a/Marlin/example_configurations/TAZ4/Configuration_adv.h b/Marlin/example_configurations/TAZ4/Configuration_adv.h index 7bc66c6d4d053c09964f0842b164dab7977cc08b..05caf958ef9edfc7c0bc3b02a52cb5d461e0eb92 100644 --- a/Marlin/example_configurations/TAZ4/Configuration_adv.h +++ b/Marlin/example_configurations/TAZ4/Configuration_adv.h @@ -442,6 +442,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// Scroll a longer status message into view +//#define STATUS_MESSAGE_SCROLLING + // On the Info Screen, display XY with one decimal place when possible //#define LCD_DECIMAL_SMALL_XY diff --git a/Marlin/example_configurations/TinyBoy2/Configuration_adv.h b/Marlin/example_configurations/TinyBoy2/Configuration_adv.h index 36623187da47f6e90c6c2d9e9c7105d16c8af564..488da0e2b2252fc981cd435b515ebd21a3b29490 100644 --- a/Marlin/example_configurations/TinyBoy2/Configuration_adv.h +++ b/Marlin/example_configurations/TinyBoy2/Configuration_adv.h @@ -442,6 +442,9 @@ // Include a page of printer information in the LCD Main Menu #define LCD_INFO_MENU +// Scroll a longer status message into view +//#define STATUS_MESSAGE_SCROLLING + // On the Info Screen, display XY with one decimal place when possible //#define LCD_DECIMAL_SMALL_XY diff --git a/Marlin/example_configurations/WITBOX/Configuration_adv.h b/Marlin/example_configurations/WITBOX/Configuration_adv.h index e165a7fc3433776c15a03fb085ebe6506d88d986..171ab3e4d8d8b4890c0bbb33a6d052b870fbb66d 100644 --- a/Marlin/example_configurations/WITBOX/Configuration_adv.h +++ b/Marlin/example_configurations/WITBOX/Configuration_adv.h @@ -442,6 +442,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// Scroll a longer status message into view +//#define STATUS_MESSAGE_SCROLLING + // On the Info Screen, display XY with one decimal place when possible //#define LCD_DECIMAL_SMALL_XY diff --git a/Marlin/example_configurations/delta/FLSUN/auto_calibrate/Configuration_adv.h b/Marlin/example_configurations/delta/FLSUN/auto_calibrate/Configuration_adv.h index 62eaf358bb64c0c7b425e835dedbb27004061ead..eb44f9e09fd6a2b404d0aa139c2b81bd77217d5e 100644 --- a/Marlin/example_configurations/delta/FLSUN/auto_calibrate/Configuration_adv.h +++ b/Marlin/example_configurations/delta/FLSUN/auto_calibrate/Configuration_adv.h @@ -444,6 +444,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// Scroll a longer status message into view +//#define STATUS_MESSAGE_SCROLLING + // On the Info Screen, display XY with one decimal place when possible //#define LCD_DECIMAL_SMALL_XY diff --git a/Marlin/example_configurations/delta/FLSUN/kossel_mini/Configuration_adv.h b/Marlin/example_configurations/delta/FLSUN/kossel_mini/Configuration_adv.h index 6ad9e985fa1e5a3ea3af07843c3643a5fd98132e..6eed64c6fa7ed673e4aadd0533ee567b1d08fc5b 100644 --- a/Marlin/example_configurations/delta/FLSUN/kossel_mini/Configuration_adv.h +++ b/Marlin/example_configurations/delta/FLSUN/kossel_mini/Configuration_adv.h @@ -444,6 +444,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// Scroll a longer status message into view +//#define STATUS_MESSAGE_SCROLLING + // On the Info Screen, display XY with one decimal place when possible //#define LCD_DECIMAL_SMALL_XY diff --git a/Marlin/example_configurations/delta/generic/Configuration_adv.h b/Marlin/example_configurations/delta/generic/Configuration_adv.h index 2664b31be006a6464a649dac6d1802d61695d52b..6f45736b65d86f74c258dd8994bbc04f4570fe8f 100644 --- a/Marlin/example_configurations/delta/generic/Configuration_adv.h +++ b/Marlin/example_configurations/delta/generic/Configuration_adv.h @@ -444,6 +444,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// Scroll a longer status message into view +//#define STATUS_MESSAGE_SCROLLING + // On the Info Screen, display XY with one decimal place when possible //#define LCD_DECIMAL_SMALL_XY diff --git a/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h b/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h index 2664b31be006a6464a649dac6d1802d61695d52b..6f45736b65d86f74c258dd8994bbc04f4570fe8f 100644 --- a/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h +++ b/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h @@ -444,6 +444,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// Scroll a longer status message into view +//#define STATUS_MESSAGE_SCROLLING + // On the Info Screen, display XY with one decimal place when possible //#define LCD_DECIMAL_SMALL_XY diff --git a/Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h b/Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h index e7142cf161ab4ad85dcba8b23cf12821ceac1f28..8f7ae5496cd83972cf200e655d036e11d1376705 100644 --- a/Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h +++ b/Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h @@ -449,6 +449,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// Scroll a longer status message into view +//#define STATUS_MESSAGE_SCROLLING + // On the Info Screen, display XY with one decimal place when possible //#define LCD_DECIMAL_SMALL_XY diff --git a/Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h b/Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h index e1fe86a0eda89a173a9f7f89b1d37cbecb2578c2..779dbe9a9152bd48c1cf8e63abc078b35b3aeb50 100644 --- a/Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h +++ b/Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h @@ -444,6 +444,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// Scroll a longer status message into view +//#define STATUS_MESSAGE_SCROLLING + // On the Info Screen, display XY with one decimal place when possible //#define LCD_DECIMAL_SMALL_XY diff --git a/Marlin/example_configurations/gCreate_gMax1.5+/Configuration_adv.h b/Marlin/example_configurations/gCreate_gMax1.5+/Configuration_adv.h index 59b43ccb6f96ac1c71af9b908900a33f23e45c46..71a3d90e046d00d3d4dad787d56b0443d647a2ec 100644 --- a/Marlin/example_configurations/gCreate_gMax1.5+/Configuration_adv.h +++ b/Marlin/example_configurations/gCreate_gMax1.5+/Configuration_adv.h @@ -442,6 +442,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// Scroll a longer status message into view +//#define STATUS_MESSAGE_SCROLLING + // On the Info Screen, display XY with one decimal place when possible //#define LCD_DECIMAL_SMALL_XY diff --git a/Marlin/example_configurations/makibox/Configuration_adv.h b/Marlin/example_configurations/makibox/Configuration_adv.h index 5483576d973e4cf539049269fbfc5aaa58a677eb..9aa5607940ee9e1d511c997fac4b65e08122de2a 100644 --- a/Marlin/example_configurations/makibox/Configuration_adv.h +++ b/Marlin/example_configurations/makibox/Configuration_adv.h @@ -442,6 +442,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// Scroll a longer status message into view +//#define STATUS_MESSAGE_SCROLLING + // On the Info Screen, display XY with one decimal place when possible //#define LCD_DECIMAL_SMALL_XY diff --git a/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h b/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h index 8dcc348ab2c29f8054b8ee92f69e508540b27bf2..660d479b52473d10445902d643c0b281a3414627 100644 --- a/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h +++ b/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h @@ -442,6 +442,9 @@ // Include a page of printer information in the LCD Main Menu //#define LCD_INFO_MENU +// Scroll a longer status message into view +//#define STATUS_MESSAGE_SCROLLING + // On the Info Screen, display XY with one decimal place when possible //#define LCD_DECIMAL_SMALL_XY diff --git a/Marlin/example_configurations/wt150/Configuration_adv.h b/Marlin/example_configurations/wt150/Configuration_adv.h index 700c5227fd4010ebc70bc0153c3fa32cec1df1af..bf586bdba02b2590981b5c9b38d5ad2c796774cf 100644 --- a/Marlin/example_configurations/wt150/Configuration_adv.h +++ b/Marlin/example_configurations/wt150/Configuration_adv.h @@ -442,6 +442,9 @@ // Include a page of printer information in the LCD Main Menu #define LCD_INFO_MENU +// Scroll a longer status message into view +//#define STATUS_MESSAGE_SCROLLING + // On the Info Screen, display XY with one decimal place when possible //#define LCD_DECIMAL_SMALL_XY diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 32d47419db3a5329f83552e27aa46e5b8473e282..6cacb3ae6ca37e6cff7851fab5a254c23a5fec70 100755 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -60,6 +60,9 @@ int lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2], lcd_preheat_fan_speed[2 uint8_t lcd_status_message_level; char lcd_status_message[3 * (LCD_WIDTH) + 1] = WELCOME_MSG; // worst case is kana with up to 3*LCD_WIDTH+1 +#if ENABLED(STATUS_MESSAGE_SCROLLING) + uint8_t status_scroll_pos = 0; +#endif #if ENABLED(DOGLCD) #include "ultralcd_impl_DOGM.h" @@ -3961,22 +3964,29 @@ void lcd_update() { } // ELAPSED(ms, next_lcd_update_ms) } -void set_utf_strlen(char* s, uint8_t n) { - uint8_t i = 0, j = 0; - while (s[i] && (j < n)) { - #if ENABLED(MAPPER_NON) - j++; - #else - if ((s[i] & 0xC0u) != 0x80u) j++; - #endif - i++; +#if DISABLED(STATUS_MESSAGE_SCROLLING) + + void set_utf_strlen(char* s, uint8_t n) { + uint8_t i = 0, j = 0; + while (s[i] && (j < n)) { + #if ENABLED(MAPPER_NON) + j++; + #else + if ((s[i] & 0xC0u) != 0x80u) j++; + #endif + i++; + } + while (j++ < n) s[i++] = ' '; + s[i] = '\0'; } - while (j++ < n) s[i++] = ' '; - s[i] = '\0'; -} + +#endif // !STATUS_MESSAGE_SCROLLING void lcd_finishstatus(bool persist=false) { - set_utf_strlen(lcd_status_message, LCD_WIDTH); + #if DISABLED(STATUS_MESSAGE_SCROLLING) + set_utf_strlen(lcd_status_message, LCD_WIDTH); + #endif + #if !(ENABLED(LCD_PROGRESS_BAR) && (PROGRESS_MSG_EXPIRE > 0)) UNUSED(persist); #endif @@ -3992,6 +4002,10 @@ void lcd_finishstatus(bool persist=false) { #if ENABLED(FILAMENT_LCD_DISPLAY) && ENABLED(SDSUPPORT) previous_lcd_status_ms = millis(); //get status message to show up for a while #endif + + #if ENABLED(STATUS_MESSAGE_SCROLLING) + status_scroll_pos = 0; + #endif } #if ENABLED(LCD_PROGRESS_BAR) && PROGRESS_MSG_EXPIRE > 0 diff --git a/Marlin/ultralcd_impl_DOGM.h b/Marlin/ultralcd_impl_DOGM.h index c0049a4c7558f761e2c62ac75d76e4e9948da805..ac6fedabba2a9174e574b6700ac525c51ba3efe8 100644 --- a/Marlin/ultralcd_impl_DOGM.h +++ b/Marlin/ultralcd_impl_DOGM.h @@ -234,13 +234,24 @@ char lcd_print_and_count(const char c) { else return charset_mapper(c); } -void lcd_print(const char* const str) { - for (uint8_t i = 0; char c = str[i]; ++i) lcd_print(c); +/** + * Core LCD printing functions + * On DOGM all strings go through a filter for utf + * But only use lcd_print_utf and lcd_printPGM_utf for translated text + */ +void lcd_print(const char* const str) { for (uint8_t i = 0; char c = str[i]; ++i) lcd_print(c); } +void lcd_printPGM(const char* str) { for (; char c = pgm_read_byte(str); ++str) lcd_print(c); } + +void lcd_print_utf(const char* const str, const uint8_t maxLength=LCD_WIDTH) { + char c; + for (uint8_t i = 0, n = maxLength; n && (c = str[i]); ++i) + n -= charset_mapper(c); } -/* Arduino < 1.0.0 is missing a function to print PROGMEM strings, so we need to implement our own */ -void lcd_printPGM(const char* str) { - for (; char c = pgm_read_byte(str); ++str) lcd_print(c); +void lcd_printPGM_utf(const char* str, const uint8_t maxLength=LCD_WIDTH) { + char c; + for (uint8_t i = 0, n = maxLength; n && (c = str[i]); ++i) + n -= charset_mapper(c); } // Initialize or re-initialize the LCD @@ -320,7 +331,7 @@ static void lcd_implementation_init() { void lcd_kill_screen() { lcd_setFont(FONT_MENU); u8g.setPrintPos(0, u8g.getHeight()/4*1); - lcd_print(lcd_status_message); + lcd_print_utf(lcd_status_message); u8g.setPrintPos(0, u8g.getHeight()/4*2); lcd_printPGM(PSTR(MSG_HALTED)); u8g.setPrintPos(0, u8g.getHeight()/4*3); @@ -395,6 +406,20 @@ FORCE_INLINE void _draw_axis_label(const AxisEnum axis, const char* const pstr, } } +inline void lcd_implementation_status_message() { + #if ENABLED(STATUS_MESSAGE_SCROLLING) + lcd_print_utf(lcd_status_message + status_scroll_pos); + const uint8_t slen = lcd_strlen(lcd_status_message); + if (slen > LCD_WIDTH) { + // Skip any non-printing bytes + while (!charset_mapper(lcd_status_message[status_scroll_pos])) ++status_scroll_pos; + if (++status_scroll_pos > slen - LCD_WIDTH) status_scroll_pos = 0; + } + #else + lcd_print_utf(lcd_status_message); + #endif +} + //#define DOGM_SD_PERCENT static void lcd_implementation_status_screen() { @@ -645,10 +670,7 @@ static void lcd_implementation_status_screen() { #if ENABLED(FILAMENT_LCD_DISPLAY) && ENABLED(SDSUPPORT) if (PENDING(millis(), previous_lcd_status_ms + 5000UL)) { //Display both Status message line and Filament display on the last line - const char *str = lcd_status_message; - uint8_t i = LCD_WIDTH; - char c; - while (i-- && (c = *str++)) lcd_print(c); + lcd_implementation_status_message(); } else { lcd_printPGM(PSTR(LCD_STR_FILAM_DIA)); @@ -660,10 +682,7 @@ static void lcd_implementation_status_screen() { u8g.print('%'); } #else - const char *str = lcd_status_message; - uint8_t i = LCD_WIDTH; - char c; - while (i-- && (c = *str++)) lcd_print(c); + lcd_implementation_status_message(); #endif } } diff --git a/Marlin/ultralcd_impl_HD44780.h b/Marlin/ultralcd_impl_HD44780.h index 1f7683387ecfe8de3fd830f6b7305f8c5a7105ec..b735baa8fcbac9830c66413bee63311f07c8f60a 100644 --- a/Marlin/ultralcd_impl_HD44780.h +++ b/Marlin/ultralcd_impl_HD44780.h @@ -380,16 +380,22 @@ static void lcd_implementation_init( void lcd_implementation_clear() { lcd.clear(); } -/* Arduino < 1.0.0 is missing a function to print PROGMEM strings, so we need to implement our own */ -void lcd_printPGM(const char *str) { - for (; char c = pgm_read_byte(str); ++str) charset_mapper(c); -} +void lcd_print(const char c) { charset_mapper(c); } + +void lcd_print(const char * const str) { for (uint8_t i = 0; char c = str[i]; ++i) lcd.print(c); } +void lcd_printPGM(const char* str) { for (; char c = pgm_read_byte(str); ++str) lcd.print(c); } -void lcd_print(const char* const str) { - for (uint8_t i = 0; const char c = str[i]; ++i) charset_mapper(c); +void lcd_print_utf(const char * const str, const uint8_t maxLength=LCD_WIDTH) { + char c; + for (uint8_t i = 0, n = maxLength; n && (c = str[i]); ++i) + n -= charset_mapper(c); } -void lcd_print(const char c) { charset_mapper(c); } +void lcd_printPGM_utf(const char* str, const uint8_t maxLength=LCD_WIDTH) { + char c; + for (uint8_t i = 0, n = maxLength; n && (c = str[i]); ++i) + n -= charset_mapper(c); +} #if ENABLED(SHOW_BOOTSCREEN) @@ -545,7 +551,7 @@ void lcd_print(const char c) { charset_mapper(c); } void lcd_kill_screen() { lcd.setCursor(0, 0); - lcd_print(lcd_status_message); + lcd_print_utf(lcd_status_message); #if LCD_HEIGHT < 4 lcd.setCursor(0, 2); #else @@ -818,10 +824,17 @@ static void lcd_implementation_status_screen() { #endif // FILAMENT_LCD_DISPLAY && SDSUPPORT - const char *str = lcd_status_message; - uint8_t i = LCD_WIDTH; - char c; - while (i-- && (c = *str++)) lcd_print(c); + #if ENABLED(STATUS_MESSAGE_SCROLLING) + lcd_print_utf(lcd_status_message + status_scroll_pos); + const uint8_t slen = lcd_strlen(lcd_status_message); + if (slen > LCD_WIDTH) { + // Skip any non-printing bytes + while (!charset_mapper(lcd_status_message[status_scroll_pos])) ++status_scroll_pos; + if (++status_scroll_pos > slen - LCD_WIDTH) status_scroll_pos = 0; + } + #else + lcd_print_utf(lcd_status_message); + #endif } #if ENABLED(ULTIPANEL)