diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 066215f72d..c4fcf65e62 100755 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -2250,7 +2250,7 @@ void kill_screen(const char* lcd_msg) { END_SCREEN(); } - void lcd_filament_change_show_message(FilamentChangeMessage message) { + void lcd_filament_change_show_message(const FilamentChangeMessage message) { switch (message) { case FILAMENT_CHANGE_MESSAGE_INIT: defer_return_to_status = true; @@ -2849,20 +2849,20 @@ void lcd_finishstatus(bool persist=false) { bool lcd_hasstatus() { return (lcd_status_message[0] != '\0'); } -void lcd_setstatus(const char* message, bool persist) { +void lcd_setstatus(const char* const message, bool persist) { if (lcd_status_message_level > 0) return; strncpy(lcd_status_message, message, 3 * (LCD_WIDTH)); lcd_finishstatus(persist); } -void lcd_setstatuspgm(const char* message, uint8_t level) { +void lcd_setstatuspgm(const char* const message, uint8_t level) { if (level < lcd_status_message_level) return; lcd_status_message_level = level; strncpy_P(lcd_status_message, message, 3 * (LCD_WIDTH)); lcd_finishstatus(level > 0); } -void lcd_setalertstatuspgm(const char* message) { +void lcd_setalertstatuspgm(const char* const message) { lcd_setstatuspgm(message, 1); #if ENABLED(ULTIPANEL) lcd_return_to_status(); @@ -2872,7 +2872,7 @@ void lcd_setalertstatuspgm(const char* message) { void lcd_reset_alert_level() { lcd_status_message_level = 0; } #if HAS_LCD_CONTRAST - void set_lcd_contrast(int value) { + void set_lcd_contrast(const int value) { lcd_contrast = constrain(value, LCD_CONTRAST_MIN, LCD_CONTRAST_MAX); u8g.setContrast(lcd_contrast); } diff --git a/Marlin/ultralcd.h b/Marlin/ultralcd.h index 3cd0711142..f0d0a42844 100644 --- a/Marlin/ultralcd.h +++ b/Marlin/ultralcd.h @@ -88,7 +88,7 @@ void lcd_quick_feedback(); // Audible feedback for a button click - could also be visual #if ENABLED(FILAMENT_CHANGE_FEATURE) - void lcd_filament_change_show_message(FilamentChangeMessage message); + void lcd_filament_change_show_message(const FilamentChangeMessage message); #endif // FILAMENT_CHANGE_FEATURE #else @@ -156,8 +156,8 @@ inline void lcd_update() {} inline void lcd_init() {} inline bool lcd_hasstatus() { return false; } - inline void lcd_setstatus(const char* message, const bool persist=false) { UNUSED(message); UNUSED(persist); } - inline void lcd_setstatuspgm(const char* message, const uint8_t level=0) { UNUSED(message); UNUSED(level); } + inline void lcd_setstatus(const char* const message, const bool persist=false) { UNUSED(message); UNUSED(persist); } + inline void lcd_setstatuspgm(const char* const message, const uint8_t level=0) { UNUSED(message); UNUSED(level); } inline void lcd_buttons_update() {} inline void lcd_reset_alert_level() {} inline bool lcd_detected() { return true; } diff --git a/Marlin/ultralcd_impl_DOGM.h b/Marlin/ultralcd_impl_DOGM.h index 7aaae6970b..ffbcb3c160 100644 --- a/Marlin/ultralcd_impl_DOGM.h +++ b/Marlin/ultralcd_impl_DOGM.h @@ -191,8 +191,8 @@ u8g_page_t &page = ((u8g_pb_t *)((u8g.getU8g())->dev->dev_mem))->p; #define PAGE_UNDER(yb) (u8g.getU8g()->current_page.y0 <= (yb)) #define PAGE_CONTAINS(ya, yb) (PAGE_UNDER(yb) && u8g.getU8g()->current_page.y1 >= (ya)) -static void lcd_setFont(char font_nr) { - switch(font_nr) { +static void lcd_setFont(const char font_nr) { + switch (font_nr) { case FONT_STATUSMENU : {u8g.setFont(FONT_STATUSMENU_NAME); currentfont = FONT_STATUSMENU;}; break; case FONT_MENU : {u8g.setFont(FONT_MENU_NAME); currentfont = FONT_MENU;}; break; case FONT_SPECIAL : {u8g.setFont(FONT_SPECIAL_NAME); currentfont = FONT_SPECIAL;}; break; @@ -201,7 +201,7 @@ static void lcd_setFont(char font_nr) { } } -void lcd_print(char c) { +void lcd_print(const char c) { if ((c > 0) && (c <= LCD_STR_SPECIAL_MAX)) { u8g.setFont(FONT_SPECIAL_NAME); u8g.print(c); @@ -210,7 +210,7 @@ void lcd_print(char c) { else charset_mapper(c); } -char lcd_print_and_count(char c) { +char lcd_print_and_count(const char c) { if ((c > 0) && (c <= LCD_STR_SPECIAL_MAX)) { u8g.setFont(FONT_SPECIAL_NAME); u8g.print(c); @@ -220,7 +220,7 @@ char lcd_print_and_count(char c) { else return charset_mapper(c); } -void lcd_print(const char* str) { +void lcd_print(const char* const str) { for (uint8_t i = 0; char c = str[i]; ++i) lcd_print(c); } @@ -268,15 +268,15 @@ static void lcd_implementation_init() { } #endif // SHOW_CUSTOM_BOOTSCREEN - int offx = (u8g.getWidth() - (START_BMPWIDTH)) / 2; + const uint8_t offx = (u8g.getWidth() - (START_BMPWIDTH)) / 2; #if ENABLED(START_BMPHIGH) - int offy = 0; + constexpr uint8_t offy = 0; #else - int offy = DOG_CHAR_HEIGHT; + constexpr uint8_t offy = DOG_CHAR_HEIGHT; #endif - int txt1X = (u8g.getWidth() - (sizeof(STRING_SPLASH_LINE1) - 1) * (DOG_CHAR_WIDTH)) / 2; + const uint8_t txt1X = (u8g.getWidth() - (sizeof(STRING_SPLASH_LINE1) - 1) * (DOG_CHAR_WIDTH)) / 2; if (show_bootscreen) { u8g.firstPage(); @@ -286,7 +286,7 @@ static void lcd_implementation_init() { #ifndef STRING_SPLASH_LINE2 u8g.drawStr(txt1X, u8g.getHeight() - (DOG_CHAR_HEIGHT), STRING_SPLASH_LINE1); #else - int txt2X = (u8g.getWidth() - (sizeof(STRING_SPLASH_LINE2) - 1) * (DOG_CHAR_WIDTH)) / 2; + const uint8_t txt2X = (u8g.getWidth() - (sizeof(STRING_SPLASH_LINE2) - 1) * (DOG_CHAR_WIDTH)) / 2; u8g.drawStr(txt1X, u8g.getHeight() - (DOG_CHAR_HEIGHT) * 3 / 2, STRING_SPLASH_LINE1); u8g.drawStr(txt2X, u8g.getHeight() - (DOG_CHAR_HEIGHT) * 1 / 2, STRING_SPLASH_LINE2); #endif @@ -315,14 +315,14 @@ static void lcd_implementation_clear() { } // Automatically cleared by Picture L // Status Screen // -FORCE_INLINE void _draw_centered_temp(int temp, int x, int y) { - int degsize = 6 * (temp >= 100 ? 3 : temp >= 10 ? 2 : 1); // number's pixel width +FORCE_INLINE void _draw_centered_temp(const int temp, const uint8_t x, const uint8_t y) { + const uint8_t degsize = 6 * (temp >= 100 ? 3 : temp >= 10 ? 2 : 1); // number's pixel width u8g.setPrintPos(x - (18 - degsize) / 2, y); // move left if shorter lcd_print(itostr3(temp)); lcd_printPGM(PSTR(LCD_STR_DEGREE " ")); } -FORCE_INLINE void _draw_heater_status(int x, int heater) { +FORCE_INLINE void _draw_heater_status(const uint8_t x, const int8_t heater) { #if HAS_TEMP_BED bool isBed = heater < 0; #else @@ -336,8 +336,8 @@ FORCE_INLINE void _draw_heater_status(int x, int heater) { _draw_centered_temp((isBed ? thermalManager.degBed() : thermalManager.degHotend(heater)) + 0.5, x, 28); if (PAGE_CONTAINS(17, 20)) { - uint8_t h = isBed ? 7 : 8, - y = isBed ? 18 : 17; + const uint8_t h = isBed ? 7 : 8, + y = isBed ? 18 : 17; if (isBed ? thermalManager.isHeatingBed() : thermalManager.isHeatingHotend(heater)) { u8g.setColorIndex(0); // white on black u8g.drawBox(x + h, y, 2, 2); @@ -349,7 +349,7 @@ FORCE_INLINE void _draw_heater_status(int x, int heater) { } } -FORCE_INLINE void _draw_axis_label(AxisEnum axis, const char *pstr, bool blink) { +FORCE_INLINE void _draw_axis_label(const AxisEnum axis, const char* const pstr, const bool blink) { if (blink) lcd_printPGM(pstr); else { @@ -611,7 +611,7 @@ static void lcd_implementation_status_screen() { uint8_t row_y1, row_y2; // Set the colors for a menu item based on whether it is selected - static void lcd_implementation_mark_as_selected(uint8_t row, bool isSelected) { + static void lcd_implementation_mark_as_selected(const uint8_t row, const bool isSelected) { row_y1 = row * (DOG_CHAR_HEIGHT) + 1; row_y2 = row_y1 + (DOG_CHAR_HEIGHT) - 1; @@ -632,7 +632,7 @@ static void lcd_implementation_status_screen() { #if ENABLED(LCD_INFO_MENU) || ENABLED(FILAMENT_CHANGE_FEATURE) // Draw a static line of text in the same idiom as a menu item - static void lcd_implementation_drawmenu_static(uint8_t row, const char* pstr, bool center=true, bool invert=false, const char* valstr=NULL) { + static void lcd_implementation_drawmenu_static(const uint8_t row, const char* pstr, const bool center=true, const bool invert=false, const char* valstr=NULL) { lcd_implementation_mark_as_selected(row, invert); @@ -659,7 +659,7 @@ static void lcd_implementation_status_screen() { #endif // LCD_INFO_MENU || FILAMENT_CHANGE_FEATURE // Draw a generic menu item - static void lcd_implementation_drawmenu_generic(bool isSelected, uint8_t row, const char* pstr, char pre_char, char post_char) { + static void lcd_implementation_drawmenu_generic(const bool isSelected, const uint8_t row, const char* pstr, const char pre_char, const char post_char) { UNUSED(pre_char); lcd_implementation_mark_as_selected(row, isSelected); @@ -684,7 +684,7 @@ static void lcd_implementation_status_screen() { #define lcd_implementation_drawmenu_function(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ') // Draw a menu item with an editable value - static void _drawmenu_setting_edit_generic(bool isSelected, uint8_t row, const char* pstr, const char* data, bool pgm) { + static void _drawmenu_setting_edit_generic(const bool isSelected, const uint8_t row, const char* pstr, const char* const data, const bool pgm) { lcd_implementation_mark_as_selected(row, isSelected); @@ -729,9 +729,9 @@ static void lcd_implementation_status_screen() { #define lcd_implementation_drawmenu_setting_edit_callback_long5(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr5rj(*(data))) #define lcd_implementation_drawmenu_setting_edit_callback_bool(sel, row, pstr, pstr2, data, callback) lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF)) - void lcd_implementation_drawedit(const char* pstr, const char* value=NULL) { + void lcd_implementation_drawedit(const char* const pstr, const char* const value=NULL) { + const uint8_t labellen = lcd_strlen_P(pstr), vallen = lcd_strlen(value); uint8_t lcd_width, char_width, - labellen = lcd_strlen_P(pstr), vallen = lcd_strlen(value), rows = (labellen > LCD_WIDTH - 2 - vallen) ? 2 : 1; #if ENABLED(USE_BIG_EDIT_FONT) @@ -752,8 +752,8 @@ static void lcd_implementation_status_screen() { #endif // Center either one or two rows - uint8_t segmentHeight = u8g.getHeight() / (rows + 1), // 1 / (rows+1) = 1/2 or 1/3 - baseline = segmentHeight + (DOG_CHAR_HEIGHT_EDIT + 1) / 2; + const uint8_t segmentHeight = u8g.getHeight() / (rows + 1); // 1 / (rows+1) = 1/2 or 1/3 + uint8_t baseline = segmentHeight + (DOG_CHAR_HEIGHT_EDIT + 1) / 2; if (PAGE_CONTAINS(baseline + 1 - (DOG_CHAR_HEIGHT_EDIT), baseline)) { u8g.setPrintPos(0, baseline); @@ -772,7 +772,7 @@ static void lcd_implementation_status_screen() { #if ENABLED(SDSUPPORT) - static void _drawmenu_sd(bool isSelected, uint8_t row, const char* pstr, const char* filename, char* const longFilename, bool isDir) { + static void _drawmenu_sd(const bool isSelected, const uint8_t row, const char* const pstr, const char* filename, char* const longFilename, const bool isDir) { UNUSED(pstr); lcd_implementation_mark_as_selected(row, isSelected); diff --git a/Marlin/ultralcd_impl_HD44780.h b/Marlin/ultralcd_impl_HD44780.h index 87a595052a..8f97b28cfb 100644 --- a/Marlin/ultralcd_impl_HD44780.h +++ b/Marlin/ultralcd_impl_HD44780.h @@ -195,7 +195,7 @@ extern volatile uint8_t buttons; //an extended version of the last checked butt static void lcd_set_custom_characters( #if ENABLED(LCD_PROGRESS_BAR) - bool info_screen_charset = true + const bool info_screen_charset = true #endif ) { static byte bedTemp[8] = { @@ -341,7 +341,7 @@ static void lcd_set_custom_characters( static void lcd_implementation_init( #if ENABLED(LCD_PROGRESS_BAR) - bool info_screen_charset = true + const bool info_screen_charset = true #endif ) { @@ -385,7 +385,7 @@ void lcd_printPGM(const char *str) { for (; char c = pgm_read_byte(str); ++str) charset_mapper(c); } -void lcd_print(const char* str) { +void lcd_print(const char* const str) { for (uint8_t i = 0; char c = str[i]; ++i) charset_mapper(c); } @@ -393,14 +393,14 @@ void lcd_print(char c) { charset_mapper(c); } #if ENABLED(SHOW_BOOTSCREEN) - void lcd_erase_line(int line) { + void lcd_erase_line(const int line) { lcd.setCursor(0, line); - for (int i = 0; i < LCD_WIDTH; i++) + for (uint8_t i = LCD_WIDTH + 1; --i;) lcd_print(' '); } // Scroll the PSTR 'text' in a 'len' wide field for 'time' milliseconds at position col,line - void lcd_scroll(int col, int line, const char* text, int len, int time) { + void lcd_scroll(const int col, const int line, const char* const text, const int len, const int time) { char tmp[LCD_WIDTH + 1] = {0}; int n = max(lcd_strlen_P(text) - len, 0); for (int i = 0; i <= n; i++) { @@ -411,7 +411,7 @@ void lcd_print(char c) { charset_mapper(c); } } } - static void logo_lines(const char *extra) { + static void logo_lines(const char* const extra) { int indent = (LCD_WIDTH - 8 - lcd_strlen_P(extra)) / 2; lcd.setCursor(indent, 0); lcd.print('\x00'); lcd_printPGM(PSTR( "------" )); lcd.print('\x01'); lcd.setCursor(indent, 1); lcd_printPGM(PSTR("|Marlin|")); lcd_printPGM(extra); @@ -552,7 +552,7 @@ void lcd_kill_screen() { lcd_printPGM(PSTR(MSG_PLEASE_RESET)); } -FORCE_INLINE void _draw_axis_label(AxisEnum axis, const char *pstr, bool blink) { +FORCE_INLINE void _draw_axis_label(const AxisEnum axis, const char* const pstr, const bool blink) { if (blink) lcd_printPGM(pstr); else { @@ -794,7 +794,7 @@ static void lcd_implementation_status_screen() { #if ENABLED(LCD_INFO_MENU) || ENABLED(FILAMENT_CHANGE_FEATURE) - static void lcd_implementation_drawmenu_static(uint8_t row, const char* pstr, bool center=true, bool invert=false, const char *valstr=NULL) { + static void lcd_implementation_drawmenu_static(const uint8_t row, const char* pstr, const bool center=true, const bool invert=false, const char *valstr=NULL) { UNUSED(invert); char c; int8_t n = LCD_WIDTH; @@ -816,7 +816,7 @@ static void lcd_implementation_status_screen() { #endif // LCD_INFO_MENU || FILAMENT_CHANGE_FEATURE - static void lcd_implementation_drawmenu_generic(bool sel, uint8_t row, const char* pstr, char pre_char, char post_char) { + static void lcd_implementation_drawmenu_generic(const bool sel, const uint8_t row, const char* pstr, const char pre_char, const char post_char) { char c; uint8_t n = LCD_WIDTH - 2; lcd.setCursor(0, row); @@ -829,7 +829,7 @@ static void lcd_implementation_status_screen() { lcd.print(post_char); } - static void lcd_implementation_drawmenu_setting_edit_generic(bool sel, uint8_t row, const char* pstr, char pre_char, char* data) { + static void lcd_implementation_drawmenu_setting_edit_generic(const bool sel, const uint8_t row, const char* pstr, const char pre_char, const char* const data) { char c; uint8_t n = LCD_WIDTH - 2 - lcd_strlen(data); lcd.setCursor(0, row); @@ -842,7 +842,7 @@ static void lcd_implementation_status_screen() { while (n--) lcd.print(' '); lcd_print(data); } - static void lcd_implementation_drawmenu_setting_edit_generic_P(bool sel, uint8_t row, const char* pstr, char pre_char, const char* data) { + static void lcd_implementation_drawmenu_setting_edit_generic_P(const bool sel, const uint8_t row, const char* pstr, const char pre_char, const char* const data) { char c; uint8_t n = LCD_WIDTH - 2 - lcd_strlen_P(data); lcd.setCursor(0, row); @@ -879,7 +879,7 @@ static void lcd_implementation_status_screen() { #define lcd_implementation_drawmenu_setting_edit_callback_long5(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', ftostr5rj(*(data))) #define lcd_implementation_drawmenu_setting_edit_callback_bool(sel, row, pstr, pstr2, data, callback) lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, '>', (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF)) - void lcd_implementation_drawedit(const char* pstr, const char* value=NULL) { + void lcd_implementation_drawedit(const char* pstr, const char* const value=NULL) { lcd.setCursor(1, 1); lcd_printPGM(pstr); if (value != NULL) { @@ -891,7 +891,7 @@ static void lcd_implementation_status_screen() { #if ENABLED(SDSUPPORT) - static void lcd_implementation_drawmenu_sd(bool sel, uint8_t row, const char* pstr, const char* filename, char* longFilename, uint8_t concat, char post_char) { + static void lcd_implementation_drawmenu_sd(const bool sel, const uint8_t row, const char* const pstr, const char* filename, char* const longFilename, const uint8_t concat, const char post_char) { UNUSED(pstr); char c; uint8_t n = LCD_WIDTH - concat; @@ -909,11 +909,11 @@ static void lcd_implementation_status_screen() { lcd.print(post_char); } - static void lcd_implementation_drawmenu_sdfile(bool sel, uint8_t row, const char* pstr, const char* filename, char* longFilename) { + static void lcd_implementation_drawmenu_sdfile(const bool sel, const uint8_t row, const char* pstr, const char* filename, char* const longFilename) { lcd_implementation_drawmenu_sd(sel, row, pstr, filename, longFilename, 2, ' '); } - static void lcd_implementation_drawmenu_sddirectory(bool sel, uint8_t row, const char* pstr, const char* filename, char* longFilename) { + static void lcd_implementation_drawmenu_sddirectory(const bool sel, const uint8_t row, const char* pstr, const char* filename, char* const longFilename) { lcd_implementation_drawmenu_sd(sel, row, pstr, filename, longFilename, 2, LCD_STR_FOLDER[0]); } diff --git a/Marlin/utf_mapper.h b/Marlin/utf_mapper.h index d814e46711..264fdf1b23 100644 --- a/Marlin/utf_mapper.h +++ b/Marlin/utf_mapper.h @@ -150,7 +150,7 @@ #if ENABLED(MAPPER_C2C3) - char charset_mapper(char c) { + char charset_mapper(const char c) { static uint8_t utf_hi_char; // UTF-8 high part static bool seen_c2 = false; uint8_t d = c; @@ -181,7 +181,7 @@ #elif ENABLED(MAPPER_CECF) - char charset_mapper(char c) { + char charset_mapper(const char c) { static uint8_t utf_hi_char; // UTF-8 high part static bool seen_ce = false; uint8_t d = c; @@ -212,7 +212,7 @@ #elif ENABLED(MAPPER_CECF) - char charset_mapper(char c) { + char charset_mapper(const char c) { static uint8_t utf_hi_char; // UTF-8 high part static bool seen_ce = false; uint8_t d = c; @@ -243,7 +243,7 @@ #elif ENABLED(MAPPER_D0D1_MOD) - char charset_mapper(char c) { + char charset_mapper(const char c) { // it is a Russian alphabet translation // except 0401 --> 0xa2 = Ё, 0451 --> 0xb5 = ё static uint8_t utf_hi_char; // UTF-8 high part @@ -280,7 +280,7 @@ #elif ENABLED(MAPPER_D0D1) - char charset_mapper(char c) { + char charset_mapper(const char c) { static uint8_t utf_hi_char; // UTF-8 high part static bool seen_d5 = false; uint8_t d = c; @@ -311,7 +311,7 @@ #elif ENABLED(MAPPER_E382E383) - char charset_mapper(char c) { + char charset_mapper(const char c) { static uint8_t utf_hi_char; // UTF-8 high part static bool seen_e3 = false; static bool seen_82_83 = false; @@ -350,7 +350,7 @@ #define MAPPER_NON - char charset_mapper(char c) { + char charset_mapper(const char c) { HARDWARE_CHAR_OUT( c ); return 1; }