diff --git a/Marlin/Conditionals_LCD.h b/Marlin/Conditionals_LCD.h index 5ea664bb8..2ec73eb7c 100644 --- a/Marlin/Conditionals_LCD.h +++ b/Marlin/Conditionals_LCD.h @@ -101,12 +101,15 @@ #if ENABLED(ULTIMAKERCONTROLLER) \ || ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) \ || ENABLED(G3D_PANEL) \ - || ENABLED(RIGIDBOT_PANEL) \ - || ENABLED(REPRAPWORLD_KEYPAD) + || ENABLED(RIGIDBOT_PANEL) #define ULTIPANEL #define NEWPANEL #endif + #if ENABLED(REPRAPWORLD_KEYPAD) + #define NEWPANEL + #endif + #if ENABLED(RA_CONTROL_PANEL) #define LCD_I2C_TYPE_PCA8574 #define LCD_I2C_ADDRESS 0x27 // I2C Address of the port expander diff --git a/Marlin/Conditionals_post.h b/Marlin/Conditionals_post.h index b0c281f1f..040885fc2 100644 --- a/Marlin/Conditionals_post.h +++ b/Marlin/Conditionals_post.h @@ -847,4 +847,9 @@ // Add commands that need sub-codes to this list #define USE_GCODE_SUBCODES ENABLED(G38_PROBE_TARGET) + // MESH_BED_LEVELING overrides PROBE_MANUALLY + #if ENABLED(MESH_BED_LEVELING) + #undef PROBE_MANUALLY + #endif + #endif // CONDITIONALS_POST_H diff --git a/Marlin/SanityCheck.h b/Marlin/SanityCheck.h index f631e0d06..db36517bb 100644 --- a/Marlin/SanityCheck.h +++ b/Marlin/SanityCheck.h @@ -319,11 +319,11 @@ * Advanced Pause */ #if ENABLED(ADVANCED_PAUSE_FEATURE) - #if DISABLED(ULTIPANEL) + #if DISABLED(NEWPANEL) #error "ADVANCED_PAUSE_FEATURE currently requires an LCD controller." #elif ENABLED(EXTRUDER_RUNOUT_PREVENT) #error "EXTRUDER_RUNOUT_PREVENT is incompatible with ADVANCED_PAUSE_FEATURE." - #elif ENABLED(PARK_HEAD_ON_PAUSE) && DISABLED(SDSUPPORT) && DISABLED(ULTIPANEL) && DISABLED(EMERGENCY_PARSER) + #elif ENABLED(PARK_HEAD_ON_PAUSE) && DISABLED(SDSUPPORT) && DISABLED(NEWPANEL) && DISABLED(EMERGENCY_PARSER) #error "PARK_HEAD_ON_PAUSE requires SDSUPPORT, EMERGENCY_PARSER, or an LCD controller." #endif #endif @@ -598,8 +598,12 @@ static_assert(1 >= 0 /** * LCD_BED_LEVELING requirements */ -#if ENABLED(LCD_BED_LEVELING) && DISABLED(MESH_BED_LEVELING) && !(HAS_ABL && ENABLED(PROBE_MANUALLY)) - #error "LCD_BED_LEVELING requires MESH_BED_LEVELING or PROBE_MANUALLY." +#if ENABLED(LCD_BED_LEVELING) + #if DISABLED(ULTIPANEL) + #error "LCD_BED_LEVELING requires an LCD controller." + #elif DISABLED(MESH_BED_LEVELING) && !(HAS_ABL && ENABLED(PROBE_MANUALLY)) + #error "LCD_BED_LEVELING requires MESH_BED_LEVELING or PROBE_MANUALLY." + #endif #endif /** diff --git a/Marlin/macros.h b/Marlin/macros.h index c37416b47..0fb057441 100644 --- a/Marlin/macros.h +++ b/Marlin/macros.h @@ -127,7 +127,6 @@ #define DECIMAL(a) (NUMERIC(a) || a == '.') #define NUMERIC_SIGNED(a) (NUMERIC(a) || (a) == '-' || (a) == '+') #define DECIMAL_SIGNED(a) (DECIMAL(a) || (a) == '-' || (a) == '+') -#define PRINTABLE(C) (((C) & 0xC0u) != 0x80u) #define COUNT(a) (sizeof(a)/sizeof(*a)) #define ZERO(a) memset(a,0,sizeof(a)) #define COPY(a,b) memcpy(a,b,min(sizeof(a),sizeof(b))) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 990e4f4c5..dc98d6570 100755 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -3885,11 +3885,7 @@ void lcd_init() { int lcd_strlen(const char* s) { int i = 0, j = 0; while (s[i]) { - #if ENABLED(MAPPER_NON) - j++; - #else - if (PRINTABLE(s[i])) j++; - #endif + if (PRINTABLE(s[i])) j++; i++; } return j; @@ -3898,11 +3894,7 @@ int lcd_strlen(const char* s) { int lcd_strlen_P(const char* s) { int j = 0; while (pgm_read_byte(s)) { - #if ENABLED(MAPPER_NON) - j++; - #else - if (PRINTABLE(pgm_read_byte(s))) j++; - #endif + if (PRINTABLE(pgm_read_byte(s))) j++; s++; } return j; @@ -4162,28 +4154,28 @@ void lcd_update() { } // ELAPSED(ms, next_lcd_update_ms) } -#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 (PRINTABLE(s[i])) j++; - #endif - i++; - } - while (j++ < n) s[i++] = ' '; - s[i] = '\0'; +void pad_message_string() { + uint8_t i = 0, j = 0; + char c; + while ((c = lcd_status_message[i]) && j < LCD_WIDTH) { + if (PRINTABLE(c)) j++; + i++; } - -#endif // !STATUS_MESSAGE_SCROLLING + if (true + #if ENABLED(STATUS_MESSAGE_SCROLLING) + && j < LCD_WIDTH + #endif + ) { + // pad with spaces to fill up the line + while (j++ < LCD_WIDTH) lcd_status_message[i++] = ' '; + // chop off at the edge + lcd_status_message[i] = '\0'; + } +} void lcd_finishstatus(bool persist=false) { - #if DISABLED(STATUS_MESSAGE_SCROLLING) - set_utf_strlen(lcd_status_message, LCD_WIDTH); - #endif + + pad_message_string(); #if !(ENABLED(LCD_PROGRESS_BAR) && (PROGRESS_MSG_EXPIRE > 0)) UNUSED(persist); diff --git a/Marlin/ultralcd_impl_DOGM.h b/Marlin/ultralcd_impl_DOGM.h index c7c5eb309..57165c33f 100644 --- a/Marlin/ultralcd_impl_DOGM.h +++ b/Marlin/ultralcd_impl_DOGM.h @@ -239,19 +239,17 @@ char lcd_print_and_count(const char c) { * 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(const char *str) { while (*str) lcd_print(*str++); } +void lcd_printPGM(const char *str) { while (const char c = pgm_read_byte(str)) lcd_print(c), ++str; } -void lcd_print_utf(const char* const str, const uint8_t maxLength=LCD_WIDTH) { +void lcd_print_utf(const char *str, uint8_t n=LCD_WIDTH) { char c; - for (uint8_t i = 0, n = maxLength; n && (c = str[i]); ++i) - n -= charset_mapper(c); + while (n && (c = *str)) n -= charset_mapper(c), ++str; } -void lcd_printPGM_utf(const char* str, const uint8_t maxLength=LCD_WIDTH) { +void lcd_printPGM_utf(const char *str, uint8_t n=LCD_WIDTH) { char c; - for (uint8_t i = 0, n = maxLength; n && (c = str[i]); ++i) - n -= charset_mapper(c); + while (n && (c = pgm_read_byte(str))) n -= charset_mapper(c), ++str; } // Initialize or re-initialize the LCD diff --git a/Marlin/ultralcd_impl_HD44780.h b/Marlin/ultralcd_impl_HD44780.h index 909271d77..2dc93ef53 100644 --- a/Marlin/ultralcd_impl_HD44780.h +++ b/Marlin/ultralcd_impl_HD44780.h @@ -382,19 +382,17 @@ void lcd_implementation_clear() { lcd.clear(); } 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 *str) { while (*str) lcd.print(*str++); } +void lcd_printPGM(const char *str) { while (const char c = pgm_read_byte(str)) lcd.print(c), ++str; } -void lcd_print_utf(const char * const str, const uint8_t maxLength=LCD_WIDTH) { +void lcd_print_utf(const char *str, uint8_t n=LCD_WIDTH) { char c; - for (uint8_t i = 0, n = maxLength; n && (c = str[i]); ++i) - n -= charset_mapper(c); + while (n && (c = *str)) n -= charset_mapper(c), ++str; } -void lcd_printPGM_utf(const char* str, const uint8_t maxLength=LCD_WIDTH) { +void lcd_printPGM_utf(const char *str, uint8_t n=LCD_WIDTH) { char c; - for (uint8_t i = 0, n = maxLength; n && (c = str[i]); ++i) - n -= charset_mapper(c); + while (n && (c = pgm_read_byte(str))) n -= charset_mapper(c), ++str; } #if ENABLED(SHOW_BOOTSCREEN) diff --git a/Marlin/utf_mapper.h b/Marlin/utf_mapper.h index 4b7975a10..edf2a6ca1 100644 --- a/Marlin/utf_mapper.h +++ b/Marlin/utf_mapper.h @@ -23,7 +23,7 @@ #ifndef UTF_MAPPER_H #define UTF_MAPPER_H -#include "language.h" +#include "language.h" #if ENABLED(DOGLCD) #define HARDWARE_CHAR_OUT u8g.print @@ -144,6 +144,8 @@ #endif // DISPLAY_CHARSET_HD44780 #endif // SIMULATE_ROMFONT +#define PRINTABLE(C) (((C) & 0xC0u) != 0x80u) + #if ENABLED(MAPPER_C2C3) char charset_mapper(const char c) { @@ -466,8 +468,11 @@ #define MAPPER_NON + #undef PRINTABLE + #define PRINTABLE(C) true + char charset_mapper(const char c) { - HARDWARE_CHAR_OUT( c ); + HARDWARE_CHAR_OUT(c); return 1; }