From d82c350de741b6f20a3d4860c9cdc30dae20f746 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 14 Nov 2018 13:13:51 -0600 Subject: [PATCH] Miscellaneous LCD code renaming, reordering (#12430) * Move special characters to language.h * Apply some naming standards * Clean up menu item draw functions * Rename some Temperature methods * UI => ExtUI --- Marlin/src/core/language.h | 38 +++++ Marlin/src/feature/runout.h | 2 +- Marlin/src/gcode/eeprom/M500-M504.cpp | 6 +- Marlin/src/gcode/stats/M75-M78.cpp | 6 +- Marlin/src/inc/Conditionals_LCD.h | 38 +---- Marlin/src/lcd/HD44780/ultralcd_HD44780.cpp | 53 +++---- Marlin/src/lcd/dogm/ultralcd_DOGM.cpp | 18 +-- Marlin/src/lcd/extensible_ui/lib/example.cpp | 4 +- Marlin/src/lcd/extensible_ui/ui_api.cpp | 30 ++-- Marlin/src/lcd/extensible_ui/ui_api.h | 6 +- Marlin/src/lcd/menu/menu.cpp | 16 +- Marlin/src/lcd/menu/menu.h | 152 +++++++++---------- Marlin/src/lcd/menu/menu_sdcard.cpp | 4 +- Marlin/src/lcd/ultralcd.cpp | 2 +- Marlin/src/libs/buzzer.cpp | 2 +- Marlin/src/module/temperature.cpp | 26 ++-- Marlin/src/module/temperature.h | 8 +- 17 files changed, 199 insertions(+), 212 deletions(-) diff --git a/Marlin/src/core/language.h b/Marlin/src/core/language.h index 563202a8e..fbd19bc0c 100644 --- a/Marlin/src/core/language.h +++ b/Marlin/src/core/language.h @@ -94,6 +94,44 @@ #define WEBSITE_URL DEFAULT_WEBSITE_URL #endif +#if HAS_GRAPHICAL_LCD + // + // Custom characters from Marlin_symbols.fon which was merged into ISO10646-0-3.bdf + // \x00 intentionally skipped to avoid problems in strings + // + #define LCD_STR_REFRESH "\x01" + #define LCD_STR_FOLDER "\x02" + #define LCD_STR_ARROW_RIGHT "\x03" + #define LCD_STR_UPLEVEL "\x04" + #define LCD_STR_CLOCK "\x05" + #define LCD_STR_FEEDRATE "\x06" + #define LCD_STR_BEDTEMP "\x07" + #define LCD_STR_THERMOMETER "\x08" + #define LCD_STR_DEGREE "\x09" + + #define LCD_STR_SPECIAL_MAX '\x09' + // Maximum here is 0x1F because 0x20 is ' ' (space) and the normal charsets begin. + // Better stay below 0x10 because DISPLAY_CHARSET_HD44780_WESTERN begins here. + + // Symbol characters + #define LCD_STR_FILAM_DIA "\xF8" + #define LCD_STR_FILAM_MUL "\xA4" + +#elif HAS_CHARACTER_LCD + + // Custom characters defined in the first 8 characters of the LCD + #define LCD_STR_BEDTEMP "\x00" // Print only as a char. This will have 'unexpected' results when used in a string! + #define LCD_STR_DEGREE "\x01" + #define LCD_STR_THERMOMETER "\x02" // Still used with string concatenation + #define LCD_STR_UPLEVEL "\x03" + #define LCD_STR_REFRESH "\x04" + #define LCD_STR_FOLDER "\x05" + #define LCD_STR_FEEDRATE "\x06" + #define LCD_STR_CLOCK "\x07" + #define LCD_STR_ARROW_RIGHT ">" /* from the default character set */ + +#endif + // Common LCD messages /* nothing here yet */ diff --git a/Marlin/src/feature/runout.h b/Marlin/src/feature/runout.h index e7c424234..3594c5231 100644 --- a/Marlin/src/feature/runout.h +++ b/Marlin/src/feature/runout.h @@ -95,7 +95,7 @@ class TFilamentMonitor : public FilamentMonitorBase { if (ran_out) { filament_ran_out = true; #if ENABLED(EXTENSIBLE_UI) - UI::onFilamentRunout(); + ExtUI::onFilamentRunout(); #endif enqueue_and_echo_commands_P(PSTR(FILAMENT_RUNOUT_SCRIPT)); planner.synchronize(); diff --git a/Marlin/src/gcode/eeprom/M500-M504.cpp b/Marlin/src/gcode/eeprom/M500-M504.cpp index e37b4d47d..caa139b17 100644 --- a/Marlin/src/gcode/eeprom/M500-M504.cpp +++ b/Marlin/src/gcode/eeprom/M500-M504.cpp @@ -45,7 +45,7 @@ void GcodeSuite::M500() { (void)settings.save(CHAT_PORT); #if ENABLED(EXTENSIBLE_UI) - UI::onStoreSettings(); + ExtUI::onStoreSettings(); #endif } @@ -59,7 +59,7 @@ void GcodeSuite::M501() { #endif ); #if ENABLED(EXTENSIBLE_UI) - UI::onLoadSettings(); + ExtUI::onLoadSettings(); #endif } @@ -69,7 +69,7 @@ void GcodeSuite::M501() { void GcodeSuite::M502() { (void)settings.reset(CHAT_PORT); #if ENABLED(EXTENSIBLE_UI) - UI::onFactoryReset(); + ExtUI::onFactoryReset(); #endif } diff --git a/Marlin/src/gcode/stats/M75-M78.cpp b/Marlin/src/gcode/stats/M75-M78.cpp index 742bd3f2e..0f06b8a6d 100644 --- a/Marlin/src/gcode/stats/M75-M78.cpp +++ b/Marlin/src/gcode/stats/M75-M78.cpp @@ -33,7 +33,7 @@ void GcodeSuite::M75() { print_job_timer.start(); #if ENABLED(EXTENSIBLE_UI) - UI::onPrintTimerStarted(); + ExtUI::onPrintTimerStarted(); #endif } @@ -43,7 +43,7 @@ void GcodeSuite::M75() { void GcodeSuite::M76() { print_job_timer.pause(); #if ENABLED(EXTENSIBLE_UI) - UI::onPrintTimerPaused(); + ExtUI::onPrintTimerPaused(); #endif } @@ -53,7 +53,7 @@ void GcodeSuite::M76() { void GcodeSuite::M77() { print_job_timer.stop(); #if ENABLED(EXTENSIBLE_UI) - UI::onPrintTimerStopped(); + ExtUI::onPrintTimerStopped(); #endif } diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index b73370c78..7cd2fe632 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -309,30 +309,8 @@ #define HAS_DIGITAL_ENCODER ENABLED(NEWPANEL) #if HAS_GRAPHICAL_LCD - // - // Custom characters from Marlin_symbols.fon which was merged into ISO10646-0-3.bdf - // \x00 intentionally skipped to avoid problems in strings - // - #define LCD_STR_REFRESH "\x01" - #define LCD_STR_FOLDER "\x02" - #define LCD_STR_ARROW_RIGHT "\x03" - #define LCD_STR_UPLEVEL "\x04" - #define LCD_STR_CLOCK "\x05" - #define LCD_STR_FEEDRATE "\x06" - #define LCD_STR_BEDTEMP "\x07" - #define LCD_STR_THERMOMETER "\x08" - #define LCD_STR_DEGREE "\x09" - - #define LCD_STR_SPECIAL_MAX '\x09' - // Maximum here is 0x1F because 0x20 is ' ' (space) and the normal charsets begin. - // Better stay below 0x10 because DISPLAY_CHARSET_HD44780_WESTERN begins here. - - // Symbol characters - #define LCD_STR_FILAM_DIA "\xf8" - #define LCD_STR_FILAM_MUL "\xa4" - /** - * Default LCD contrast for dogm-like LCD displays + * Default LCD contrast for Graphical LCD displays */ #define HAS_LCD_CONTRAST ( \ ENABLED(MAKRPANEL) \ @@ -353,20 +331,6 @@ #define DEFAULT_LCD_CONTRAST 32 #endif #endif - -#else - - // Custom characters defined in the first 8 characters of the LCD - #define LCD_BEDTEMP_CHAR 0x00 // Print only as a char. This will have 'unexpected' results when used in a string! - #define LCD_DEGREE_CHAR 0x01 - #define LCD_STR_THERMOMETER "\x02" // Still used with string concatenation - #define LCD_UPLEVEL_CHAR 0x03 - #define LCD_STR_REFRESH "\x04" - #define LCD_STR_FOLDER "\x05" - #define LCD_FEEDRATE_CHAR 0x06 - #define LCD_CLOCK_CHAR 0x07 - #define LCD_STR_ARROW_RIGHT ">" /* from the default character set */ - #endif // Boot screens diff --git a/Marlin/src/lcd/HD44780/ultralcd_HD44780.cpp b/Marlin/src/lcd/HD44780/ultralcd_HD44780.cpp index 1c5c9832a..1a1e7b175 100644 --- a/Marlin/src/lcd/HD44780/ultralcd_HD44780.cpp +++ b/Marlin/src/lcd/HD44780/ultralcd_HD44780.cpp @@ -290,11 +290,11 @@ void MarlinUI::set_custom_characters( else #endif { // Info Screen uses 5 special characters - createChar_P(LCD_BEDTEMP_CHAR, bedTemp); - createChar_P(LCD_DEGREE_CHAR, degree); + createChar_P(LCD_STR_BEDTEMP[0], bedTemp); + createChar_P(LCD_STR_DEGREE[0], degree); createChar_P(LCD_STR_THERMOMETER[0], thermometer); - createChar_P(LCD_FEEDRATE_CHAR, feedrate); - createChar_P(LCD_CLOCK_CHAR, clock); + createChar_P(LCD_STR_FEEDRATE[0], feedrate); + createChar_P(LCD_STR_CLOCK[0], clock); #if ENABLED(LCD_PROGRESS_BAR) if (screen_charset == CHARSET_INFO) { // 3 Progress bar characters for info screen @@ -304,7 +304,7 @@ void MarlinUI::set_custom_characters( else #endif { - createChar_P(LCD_UPLEVEL_CHAR, uplevel); + createChar_P(LCD_STR_UPLEVEL[0], uplevel); #if ENABLED(SDSUPPORT) // SD Card sub-menu special characters createChar_P(LCD_STR_REFRESH[0], refresh); @@ -553,7 +553,7 @@ FORCE_INLINE void _draw_heater_status(const int8_t heater, const char prefix, co lcd_put_u8str(itostr3left(t2 + 0.5)); if (prefix >= 0) { - lcd_put_wchar(LCD_DEGREE_CHAR); + lcd_put_wchar(LCD_STR_DEGREE[0]); lcd_put_wchar(' '); if (t2 < 10) lcd_put_wchar(' '); } @@ -564,7 +564,7 @@ FORCE_INLINE void _draw_bed_status(const bool blink) { #if HAS_LEVELING planner.leveling_active && blink ? '_' : #endif - LCD_BEDTEMP_CHAR + LCD_STR_BEDTEMP[0] ), blink); } @@ -769,11 +769,11 @@ void MarlinUI::draw_status_screen() { // #if HOTENDS > 1 lcd_moveto(8, 0); - lcd_put_wchar((char)LCD_STR_THERMOMETER[0]); + lcd_put_wchar(LCD_STR_THERMOMETER[0]); _draw_heater_status(1, -1, blink); #elif HAS_HEATED_BED lcd_moveto(8, 0); - lcd_put_wchar((char)LCD_BEDTEMP_CHAR); + lcd_put_wchar(LCD_STR_BEDTEMP[0]); _draw_heater_status(-1, -1, blink); #endif @@ -850,7 +850,7 @@ void MarlinUI::draw_status_screen() { #if LCD_HEIGHT > 3 lcd_moveto(0, 2); - lcd_put_wchar(LCD_FEEDRATE_CHAR); + lcd_put_wchar(LCD_STR_FEEDRATE[0]); lcd_put_u8str(itostr3(feedrate_percentage)); lcd_put_wchar('%'); @@ -859,7 +859,7 @@ void MarlinUI::draw_status_screen() { const uint8_t len = elapsed.toDigital(buffer), timepos = LCD_WIDTH - len - 1; lcd_moveto(timepos, 2); - lcd_put_wchar(LCD_CLOCK_CHAR); + lcd_put_wchar(LCD_STR_CLOCK[0]); lcd_put_u8str(buffer); #if LCD_WIDTH >= 20 @@ -921,7 +921,7 @@ void MarlinUI::draw_status_screen() { #endif lcd_moveto(LCD_WIDTH - 9, 1); - lcd_put_wchar(LCD_FEEDRATE_CHAR); + lcd_put_wchar(LCD_STR_FEEDRATE[0]); lcd_put_u8str(itostr3(feedrate_percentage)); lcd_put_wchar('%'); @@ -950,7 +950,7 @@ void MarlinUI::draw_status_screen() { duration_t elapsed = print_job_timer.duration(); char buffer[14]; (void)elapsed.toDigital(buffer); - lcd_put_wchar(LCD_CLOCK_CHAR); + lcd_put_wchar(LCD_STR_CLOCK[0]); lcd_put_u8str(buffer); #endif @@ -990,32 +990,23 @@ void MarlinUI::draw_status_screen() { for (; n > 0; --n) lcd_put_wchar(' '); } - void draw_menu_item_generic(const bool isSelected, const uint8_t row, PGM_P pstr, const char pre_char, const char post_char) { + void draw_menu_item(const bool sel, const uint8_t row, PGM_P pstr, const char pre_char, const char post_char) { uint8_t n = LCD_WIDTH - 2; lcd_moveto(0, row); - lcd_put_wchar(isSelected ? pre_char : ' '); + lcd_put_wchar(sel ? pre_char : ' '); n -= lcd_put_u8str_max_P(pstr, n); while (n--) lcd_put_wchar(' '); lcd_put_wchar(post_char); } - void draw_menu_item_setting_edit_generic(const bool isSelected, const uint8_t row, PGM_P pstr, const char pre_char, const char* const data) { - uint8_t n = LCD_WIDTH - 2 - utf8_strlen(data); + void _draw_menu_item_edit(const bool sel, const uint8_t row, PGM_P pstr, const char* const data, const bool pgm) { + uint8_t n = LCD_WIDTH - 2 - (pgm ? utf8_strlen_P(data) : utf8_strlen(data)); lcd_moveto(0, row); - lcd_put_wchar(isSelected ? pre_char : ' '); + lcd_put_wchar(sel ? LCD_STR_ARROW_RIGHT[0] : ' '); n -= lcd_put_u8str_max_P(pstr, n); lcd_put_wchar(':'); while (n--) lcd_put_wchar(' '); - lcd_put_u8str(data); - } - void draw_menu_item_setting_edit_generic_P(const bool isSelected, const uint8_t row, PGM_P pstr, const char pre_char, const char* const data) { - uint8_t n = LCD_WIDTH - 2 - utf8_strlen_P(data); - lcd_moveto(0, row); - lcd_put_wchar(isSelected ? pre_char : ' '); - n -= lcd_put_u8str_max_P(pstr, n); - lcd_put_wchar(':'); - while (n--) lcd_put_wchar(' '); - lcd_put_u8str_P(data); + if (pgm) lcd_put_u8str_P(data); else lcd_put_u8str(data); } void draw_edit_screen(PGM_P const pstr, const char* const value/*=NULL*/) { @@ -1033,9 +1024,9 @@ void MarlinUI::draw_status_screen() { #if ENABLED(SDSUPPORT) - void draw_sd_menu_item(const bool isSelected, const uint8_t row, PGM_P const pstr, CardReader &theCard, const bool isDir) { + void draw_sd_menu_item(const bool sel, const uint8_t row, PGM_P const pstr, CardReader &theCard, const bool isDir) { const char post_char = isDir ? LCD_STR_FOLDER[0] : ' ', - sel_char = isSelected ? '>' : ' '; + sel_char = sel ? LCD_STR_ARROW_RIGHT[0] : ' '; UNUSED(pstr); lcd_moveto(0, row); lcd_put_wchar(sel_char); @@ -1045,7 +1036,7 @@ void MarlinUI::draw_status_screen() { if (theCard.longFilename[0]) { #if ENABLED(SCROLL_LONG_FILENAMES) static uint8_t filename_scroll_hash; - if (isSelected) { + if (sel) { uint8_t name_hash = row; for (uint8_t l = FILENAME_LENGTH; l--;) name_hash = ((name_hash << 1) | (name_hash >> 7)) ^ theCard.filename[l]; // rotate, xor diff --git a/Marlin/src/lcd/dogm/ultralcd_DOGM.cpp b/Marlin/src/lcd/dogm/ultralcd_DOGM.cpp index 80e53fd13..645a4b6b3 100644 --- a/Marlin/src/lcd/dogm/ultralcd_DOGM.cpp +++ b/Marlin/src/lcd/dogm/ultralcd_DOGM.cpp @@ -265,13 +265,13 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop #endif // ADVANCED_PAUSE_FEATURE // Set the colors for a menu item based on whether it is selected - static bool mark_as_selected(const uint8_t row, const bool isSelected) { + static bool mark_as_selected(const uint8_t row, const bool sel) { row_y1 = row * (MENU_FONT_HEIGHT) + 1; row_y2 = row_y1 + MENU_FONT_HEIGHT - 1; if (!PAGE_CONTAINS(row_y1 + 1, row_y2 + 2)) return false; - if (isSelected) { + if (sel) { #if ENABLED(MENU_HOLLOW_FRAME) u8g.drawHLine(0, row_y1 + 1, LCD_PIXEL_WIDTH); u8g.drawHLine(0, row_y2 + 2, LCD_PIXEL_WIDTH); @@ -314,10 +314,10 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop } // Draw a generic menu item - void draw_menu_item_generic(const bool isSelected, const uint8_t row, PGM_P const pstr, const char pre_char, const char post_char) { + void draw_menu_item(const bool sel, const uint8_t row, PGM_P const pstr, const char pre_char, const char post_char) { UNUSED(pre_char); - if (mark_as_selected(row, isSelected)) { + if (mark_as_selected(row, sel)) { uint8_t n = LCD_WIDTH - 2; n *= MENU_FONT_WIDTH; n -= lcd_put_u8str_max_P(pstr, n); @@ -329,8 +329,8 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop } // Draw a menu item with an editable value - void _drawmenu_setting_edit_generic(const bool isSelected, const uint8_t row, PGM_P const pstr, const char* const data, const bool pgm) { - if (mark_as_selected(row, isSelected)) { + void _draw_menu_item_edit(const bool sel, const uint8_t row, PGM_P const pstr, const char* const data, const bool pgm) { + if (mark_as_selected(row, sel)) { const uint8_t vallen = (pgm ? utf8_strlen_P(data) : utf8_strlen((char*)data)); uint8_t n = LCD_WIDTH - 2 - vallen; n *= MENU_FONT_WIDTH; @@ -396,10 +396,10 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop #if ENABLED(SDSUPPORT) - void draw_sd_menu_item(const bool isSelected, const uint8_t row, PGM_P const pstr, CardReader &theCard, const bool isDir) { + void draw_sd_menu_item(const bool sel, const uint8_t row, PGM_P const pstr, CardReader &theCard, const bool isDir) { UNUSED(pstr); - mark_as_selected(row, isSelected); + mark_as_selected(row, sel); if (!PAGE_CONTAINS(row_y1, row_y2)) return; @@ -408,7 +408,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop if (theCard.longFilename[0]) { #if ENABLED(SCROLL_LONG_FILENAMES) static uint8_t filename_scroll_hash; - if (isSelected) { + if (sel) { uint8_t name_hash = row; for (uint8_t l = FILENAME_LENGTH; l--;) name_hash = ((name_hash << 1) | (name_hash >> 7)) ^ theCard.filename[l]; // rotate, xor diff --git a/Marlin/src/lcd/extensible_ui/lib/example.cpp b/Marlin/src/lcd/extensible_ui/lib/example.cpp index 6b8a27db6..d12e3489f 100644 --- a/Marlin/src/lcd/extensible_ui/lib/example.cpp +++ b/Marlin/src/lcd/extensible_ui/lib/example.cpp @@ -27,13 +27,13 @@ // To implement a new UI, complete the functions below and // read or update Marlin's state using the methods in the -// UI methods in "../ui_api.h" +// ExtUI methods in "../ui_api.h" // // Although it may be possible to access other state // variables from Marlin, using the API here possibly // helps ensure future compatibility. -namespace UI { +namespace ExtUI { void onStartup() { /* Initialize the display module here. The following * routines are available for access to the GPIO pins: diff --git a/Marlin/src/lcd/extensible_ui/ui_api.cpp b/Marlin/src/lcd/extensible_ui/ui_api.cpp index 8d045a2a7..932a276af 100644 --- a/Marlin/src/lcd/extensible_ui/ui_api.cpp +++ b/Marlin/src/lcd/extensible_ui/ui_api.cpp @@ -93,7 +93,7 @@ static struct { uint8_t manual_motion : 1; } flags; -namespace UI { +namespace ExtUI { #ifdef __SAM3X8E__ /** * Implement a special millis() to allow time measurement @@ -593,7 +593,7 @@ namespace UI { #if ENABLED(PARK_HEAD_ON_PAUSE) enqueue_and_echo_commands_P(PSTR("M125")); #endif - UI::onStatusChanged(PSTR(MSG_PRINT_PAUSED)); + ExtUI::onStatusChanged(PSTR(MSG_PRINT_PAUSED)); #endif } @@ -605,7 +605,7 @@ namespace UI { card.startFileprint(); print_job_timer.start(); #endif - UI::onStatusChanged(PSTR(MSG_PRINTING)); + ExtUI::onStatusChanged(PSTR(MSG_PRINTING)); #endif } @@ -613,7 +613,7 @@ namespace UI { #if ENABLED(SDSUPPORT) wait_for_heatup = wait_for_user = false; card.abort_sd_printing = true; - UI::onStatusChanged(PSTR(MSG_PRINT_ABORTED)); + ExtUI::onStatusChanged(PSTR(MSG_PRINT_ABORTED)); #endif } @@ -678,7 +678,7 @@ namespace UI { #endif } -} // namespace UI +} // namespace ExtUI // At the moment, we piggy-back off the ultralcd calls, but this could be cleaned up in the future @@ -686,7 +686,7 @@ void MarlinUI::init() { #if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT) SET_INPUT_PULLUP(SD_DETECT_PIN); #endif - UI::onStartup(); + ExtUI::onStartup(); } void MarlinUI::update() { @@ -698,23 +698,23 @@ void MarlinUI::update() { if (sd_status) { card.initsd(); if (card.cardOK) - UI::onMediaInserted(); + ExtUI::onMediaInserted(); else - UI::onMediaError(); + ExtUI::onMediaError(); } else { const bool ok = card.cardOK; card.release(); - if (ok) UI::onMediaRemoved(); + if (ok) ExtUI::onMediaRemoved(); } } #endif // SDSUPPORT - UI::_processManualMoveToDestination(); - UI::onIdle(); + ExtUI::_processManualMoveToDestination(); + ExtUI::onIdle(); } -void MarlinUI::setstatus(const char * const message, const bool persist/*=false*/) { UI::onStatusChanged(message); } -void MarlinUI::setstatusPGM(PGM_P const message, int8_t level/*=0*/) { UI::onStatusChanged((progmem_str)message); } +void MarlinUI::setstatus(const char * const message, const bool persist/*=false*/) { ExtUI::onStatusChanged(message); } +void MarlinUI::setstatusPGM(PGM_P const message, int8_t level/*=0*/) { ExtUI::onStatusChanged((progmem_str)message); } void MarlinUI::setalertstatusPGM(PGM_P const message) { setstatusPGM(message, 0); } void MarlinUI::status_printf_P(const uint8_t level, const char * const fmt, ...) { @@ -724,13 +724,13 @@ void MarlinUI::status_printf_P(const uint8_t level, const char * const fmt, ...) vsnprintf_P(buff, sizeof(buff), fmt, args); va_end(args); buff[63] = '\0'; - UI::onStatusChanged(buff); + ExtUI::onStatusChanged(buff); } void MarlinUI::kill_screen(PGM_P const msg) { if (!flags.printer_killed) { flags.printer_killed = true; - UI::onPrinterKilled(msg); + ExtUI::onPrinterKilled(msg); } } diff --git a/Marlin/src/lcd/extensible_ui/ui_api.h b/Marlin/src/lcd/extensible_ui/ui_api.h index 806d1a3f0..1c8ffe53a 100644 --- a/Marlin/src/lcd/extensible_ui/ui_api.h +++ b/Marlin/src/lcd/extensible_ui/ui_api.h @@ -47,7 +47,7 @@ typedef const __FlashStringHelper *progmem_str; -namespace UI { +namespace ExtUI { enum axis_t : uint8_t { X, Y, Z }; enum extruder_t : uint8_t { E0, E1, E2, E3, E4, E5 }; @@ -257,8 +257,8 @@ namespace UI { * UI_INCREMENT(TargetTemp_celsius, E0) * */ -#define UI_INCREMENT_BY(method, inc, ...) UI::set ## method(UI::get ## method (__VA_ARGS__) + inc, ##__VA_ARGS__) -#define UI_DECREMENT_BY(method, inc, ...) UI::set ## method(UI::get ## method (__VA_ARGS__) - inc, ##__VA_ARGS__) +#define UI_INCREMENT_BY(method, inc, ...) ExtUI::set ## method(ExtUI::get ## method (__VA_ARGS__) + inc, ##__VA_ARGS__) +#define UI_DECREMENT_BY(method, inc, ...) ExtUI::set ## method(ExtUI::get ## method (__VA_ARGS__) - inc, ##__VA_ARGS__) #define UI_INCREMENT(method, ...) UI_INCREMENT_BY(method, increment, ##__VA_ARGS__) #define UI_DECREMENT(method, ...) UI_DECREMENT_BY(method, increment, ##__VA_ARGS__) diff --git a/Marlin/src/lcd/menu/menu.cpp b/Marlin/src/lcd/menu/menu.cpp index c67dbdb48..352eed24d 100644 --- a/Marlin/src/lcd/menu/menu.cpp +++ b/Marlin/src/lcd/menu/menu.cpp @@ -102,7 +102,7 @@ void MarlinUI::goto_previous_screen() { /////////// Common Menu Actions //////////// //////////////////////////////////////////// -void menu_item_gcode::action(PGM_P pgcode) { enqueue_and_echo_commands_P(pgcode); } +void MenuItem_gcode::action(PGM_P pgcode) { enqueue_and_echo_commands_P(pgcode); } //////////////////////////////////////////// /////////// Menu Editing Actions /////////// @@ -119,18 +119,18 @@ void menu_item_gcode::action(PGM_P pgcode) { enqueue_and_echo_commands_P(pgcode) * * For example, DEFINE_MENU_EDIT_ITEM(int3) expands into these functions: * - * bool menu_item_int3::_edit(); - * void menu_item_int3::edit(); // edit int16_t (interactively) - * void menu_item_int3::action_setting_edit(PGM_P const pstr, int16_t * const ptr, const int16_t minValue, const int16_t maxValue, const screenFunc_t callback = null, const bool live = false); + * bool MenuItem_int3::_edit(); + * void MenuItem_int3::edit(); // edit int16_t (interactively) + * void MenuItem_int3::action_edit(PGM_P const pstr, int16_t * const ptr, const int16_t minValue, const int16_t maxValue, const screenFunc_t callback = null, const bool live = false); * * You can then use one of the menu macros to present the edit interface: * MENU_ITEM_EDIT(int3, MSG_SPEED, &feedrate_percentage, 10, 999) * * This expands into a more primitive menu item: - * MENU_ITEM_VARIANT(int3, _setting_edit, MSG_SPEED, PSTR(MSG_SPEED), &feedrate_percentage, 10, 999) + * MENU_ITEM_VARIANT(int3, _edit, MSG_SPEED, PSTR(MSG_SPEED), &feedrate_percentage, 10, 999) * * ...which calls: - * menu_item_int3::action_setting_edit(PSTR(MSG_SPEED), &feedrate_percentage, 10, 999) + * MenuItem_int3::action_edit(PSTR(MSG_SPEED), &feedrate_percentage, 10, 999) */ void MenuItemBase::edit(strfunc_t strfunc, loadfunc_t loadfunc) { ui.encoder_direction_normal(); @@ -158,7 +158,7 @@ void MenuItemBase::init(PGM_P const el, void * const ev, const int32_t minv, con liveEdit = le; } -#define DEFINE_MENU_EDIT_ITEM(NAME) template class TMenuItem; +#define DEFINE_MENU_EDIT_ITEM(NAME) template class TMenuItem; DEFINE_MENU_EDIT_ITEM(int3); DEFINE_MENU_EDIT_ITEM(int4); @@ -172,7 +172,7 @@ DEFINE_MENU_EDIT_ITEM(float52sign); DEFINE_MENU_EDIT_ITEM(float62); DEFINE_MENU_EDIT_ITEM(long5); -void menu_item_bool::action_setting_edit(PGM_P pstr, bool *ptr, screenFunc_t callback) { +void MenuItem_bool::action_edit(PGM_P pstr, bool *ptr, screenFunc_t callback) { UNUSED(pstr); *ptr ^= true; ui.refresh(); if (callback) (*callback)(); } diff --git a/Marlin/src/lcd/menu/menu.h b/Marlin/src/lcd/menu/menu.h index cc3d54e8b..7044bd22c 100644 --- a/Marlin/src/lcd/menu/menu.h +++ b/Marlin/src/lcd/menu/menu.h @@ -37,109 +37,103 @@ bool printer_busy(); //////////////////////////////////////////// #define DECLARE_MENU_EDIT_TYPE(TYPE, NAME, STRFUNC, SCALE) \ - struct NAME ## _item_info { \ + struct MenuItemInfo_##NAME { \ typedef TYPE type_t; \ static constexpr float scale = SCALE; \ static inline char* strfunc(const float value) { return STRFUNC((TYPE) value); } \ }; -DECLARE_MENU_EDIT_TYPE(int16_t, int3, itostr3, 1); -DECLARE_MENU_EDIT_TYPE(int16_t, int4, itostr4sign, 1); -DECLARE_MENU_EDIT_TYPE(uint8_t, int8, i8tostr3, 1); -DECLARE_MENU_EDIT_TYPE(float, float3, ftostr3, 1); -DECLARE_MENU_EDIT_TYPE(float, float52, ftostr52, 100); -DECLARE_MENU_EDIT_TYPE(float, float43, ftostr43sign, 1000); -DECLARE_MENU_EDIT_TYPE(float, float5, ftostr5rj, 0.01f); -DECLARE_MENU_EDIT_TYPE(float, float51, ftostr51sign, 10); -DECLARE_MENU_EDIT_TYPE(float, float52sign, ftostr52sign, 100); -DECLARE_MENU_EDIT_TYPE(float, float62, ftostr62rj, 100); -DECLARE_MENU_EDIT_TYPE(uint32_t, long5, ftostr5rj, 0.01f); +DECLARE_MENU_EDIT_TYPE(int16_t, int3, itostr3, 1 ); +DECLARE_MENU_EDIT_TYPE(int16_t, int4, itostr4sign, 1 ); +DECLARE_MENU_EDIT_TYPE(uint8_t, int8, i8tostr3, 1 ); +DECLARE_MENU_EDIT_TYPE(float, float3, ftostr3, 1 ); +DECLARE_MENU_EDIT_TYPE(float, float52, ftostr52, 100 ); +DECLARE_MENU_EDIT_TYPE(float, float43, ftostr43sign, 1000 ); +DECLARE_MENU_EDIT_TYPE(float, float5, ftostr5rj, 0.01f ); +DECLARE_MENU_EDIT_TYPE(float, float51, ftostr51sign, 10 ); +DECLARE_MENU_EDIT_TYPE(float, float52sign, ftostr52sign, 100 ); +DECLARE_MENU_EDIT_TYPE(float, float62, ftostr62rj, 100 ); +DECLARE_MENU_EDIT_TYPE(uint32_t, long5, ftostr5rj, 0.01f ); //////////////////////////////////////////// ///////// Menu Item Draw Functions ///////// //////////////////////////////////////////// -void draw_menu_item_generic(const bool isSelected, const uint8_t row, PGM_P const pstr, const char pre_char, const char post_char); -void draw_menu_item_static(const uint8_t row, PGM_P const pstr, const bool center=true, const bool invert=false, const char *valstr=NULL); void draw_edit_screen(PGM_P const pstr, const char* const value=NULL); +void draw_menu_item(const bool sel, const uint8_t row, PGM_P const pstr, const char pre_char, const char post_char); +void draw_menu_item_static(const uint8_t row, PGM_P const pstr, const bool center=true, const bool invert=false, const char *valstr=NULL); +void _draw_menu_item_edit(const bool sel, const uint8_t row, PGM_P const pstr, const char* const data, const bool pgm); +FORCE_INLINE void draw_menu_item_back(const bool sel, const uint8_t row, PGM_P const pstr) { draw_menu_item(sel, row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0]); } +FORCE_INLINE void draw_menu_item_edit(const bool sel, const uint8_t row, PGM_P const pstr, const char* const data) { _draw_menu_item_edit(sel, row, pstr, data, false); } +FORCE_INLINE void draw_menu_item_edit_P(const bool sel, const uint8_t row, PGM_P const pstr, const char* const data) { _draw_menu_item_edit(sel, row, pstr, data, true); } +#define draw_menu_item_submenu(sel, row, pstr, data) draw_menu_item(sel, row, pstr, '>', LCD_STR_ARROW_RIGHT[0]) +#define draw_menu_item_gcode(sel, row, pstr, gcode) draw_menu_item(sel, row, pstr, '>', ' ') +#define draw_menu_item_function(sel, row, pstr, data) draw_menu_item(sel, row, pstr, '>', ' ') +#define DRAW_MENU_ITEM_SETTING_EDIT_GENERIC(VAL) draw_menu_item_edit(sel, row, pstr, VAL) +#define DRAW_BOOL_SETTING(sel, row, pstr, data) draw_menu_item_edit_P(sel, row, pstr, (*(data))?PSTR(MSG_LCD_ON):PSTR(MSG_LCD_OFF)) + #if ENABLED(SDSUPPORT) class CardReader; - void draw_sd_menu_item(const bool isSelected, const uint8_t row, PGM_P const pstr, CardReader &theCard, const bool isDir); - inline void draw_menu_item_sdfile(const bool sel, const uint8_t row, PGM_P const pstr, CardReader &theCard) { draw_sd_menu_item(sel, row, pstr, theCard, false); } - inline void draw_menu_item_sdfolder(const bool sel, const uint8_t row, PGM_P const pstr, CardReader &theCard) { draw_sd_menu_item(sel, row, pstr, theCard, true); } + void draw_sd_menu_item(const bool sel, const uint8_t row, PGM_P const pstr, CardReader &theCard, const bool isDir); + FORCE_INLINE void draw_menu_item_sdfile(const bool sel, const uint8_t row, PGM_P const pstr, CardReader &theCard) { draw_sd_menu_item(sel, row, pstr, theCard, false); } + FORCE_INLINE void draw_menu_item_sdfolder(const bool sel, const uint8_t row, PGM_P const pstr, CardReader &theCard) { draw_sd_menu_item(sel, row, pstr, theCard, true); } #endif -#if HAS_GRAPHICAL_LCD - void _drawmenu_setting_edit_generic(const bool isSelected, const uint8_t row, const char* pstr, const char* const data, const bool pgm); - #define draw_menu_item_back(sel, row, pstr) draw_menu_item_generic(sel, row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0]) - #define draw_menu_item_setting_edit_generic(sel, row, pstr, data) _drawmenu_setting_edit_generic(sel, row, pstr, data, false) - #define draw_menu_item_setting_edit_generic_P(sel, row, pstr, data) _drawmenu_setting_edit_generic(sel, row, pstr, data, true) - #define DRAWMENU_SETTING_EDIT_GENERIC(SRC) draw_menu_item_setting_edit_generic(sel, row, pstr, SRC) - #define DRAW_BOOL_SETTING(sel, row, pstr, data) draw_menu_item_setting_edit_generic_P(sel, row, pstr, (*(data))?PSTR(MSG_LCD_ON):PSTR(MSG_LCD_OFF)) - #if ENABLED(BABYSTEP_ZPROBE_GFX_OVERLAY) || ENABLED(MESH_EDIT_GFX_OVERLAY) - void _lcd_zoffset_overlay_gfx(const float zvalue); - #endif -#else - #define draw_menu_item_back(sel, row, pstr) draw_menu_item_generic(sel, row, pstr, LCD_UPLEVEL_CHAR, LCD_UPLEVEL_CHAR) - void draw_menu_item_setting_edit_generic(const bool sel, const uint8_t row, const char* pstr, const char pre_char, const char* const data); - void draw_menu_item_setting_edit_generic_P(const bool sel, const uint8_t row, const char* pstr, const char pre_char, const char* const data); - #define DRAWMENU_SETTING_EDIT_GENERIC(SRC) draw_menu_item_setting_edit_generic(sel, row, pstr, '>', SRC) - #define DRAW_BOOL_SETTING(sel, row, pstr, data) draw_menu_item_setting_edit_generic_P(sel, row, pstr, '>', (*(data))?PSTR(MSG_LCD_ON):PSTR(MSG_LCD_OFF)) + +#if HAS_GRAPHICAL_LCD && (ENABLED(BABYSTEP_ZPROBE_GFX_OVERLAY) || ENABLED(MESH_EDIT_GFX_OVERLAY)) + void _lcd_zoffset_overlay_gfx(const float zvalue); #endif -#define draw_menu_item_submenu(sel, row, pstr, data) draw_menu_item_generic(sel, row, pstr, '>', LCD_STR_ARROW_RIGHT[0]) -#define draw_menu_item_gcode(sel, row, pstr, gcode) draw_menu_item_generic(sel, row, pstr, '>', ' ') -#define draw_menu_item_function(sel, row, pstr, data) draw_menu_item_generic(sel, row, pstr, '>', ' ') //////////////////////////////////////////// /////// Edit Setting Draw Functions //////// //////////////////////////////////////////// -#define _DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(TYPE, NAME, STRFUNC) \ - FORCE_INLINE void draw_menu_item_setting_edit_ ## NAME (const bool sel, const uint8_t row, PGM_P const pstr, PGM_P const pstr2, TYPE * const data, ...) { \ +#define _DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(TYPE, NAME, STRFUNC) \ + FORCE_INLINE void draw_menu_item_edit_##NAME (const bool sel, const uint8_t row, PGM_P const pstr, PGM_P const pstr2, TYPE * const data, ...) { \ UNUSED(pstr2); \ - DRAWMENU_SETTING_EDIT_GENERIC(STRFUNC(*(data))); \ + DRAW_MENU_ITEM_SETTING_EDIT_GENERIC(STRFUNC(*(data))); \ } \ - FORCE_INLINE void draw_menu_item_setting_edit_accessor_ ## NAME (const bool sel, const uint8_t row, PGM_P const pstr, PGM_P const pstr2, TYPE (*pget)(), void (*pset)(TYPE), ...) { \ + FORCE_INLINE void draw_menu_item_edit_accessor_##NAME (const bool sel, const uint8_t row, PGM_P const pstr, PGM_P const pstr2, TYPE (*pget)(), void (*pset)(TYPE), ...) { \ UNUSED(pstr2); UNUSED(pset); \ - DRAWMENU_SETTING_EDIT_GENERIC(STRFUNC(pget())); \ + DRAW_MENU_ITEM_SETTING_EDIT_GENERIC(STRFUNC(pget())); \ } \ typedef void NAME##_void -#define DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(NAME) _DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(NAME ## _item_info::type_t, NAME, NAME ## _item_info::strfunc) - -DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(int3); -DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(int4); -DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(int8); -DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(float3); -DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(float52); -DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(float43); -DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(float5); -DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(float51); -DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(float52sign); -DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(float62); -DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(long5); - -#define draw_menu_item_setting_edit_bool(sel, row, pstr, pstr2, data, ...) DRAW_BOOL_SETTING(sel, row, pstr, data) -#define draw_menu_item_setting_edit_accessor_bool(sel, row, pstr, pstr2, pget, pset) DRAW_BOOL_SETTING(sel, row, pstr, data) +#define DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(NAME) _DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(MenuItemInfo_##NAME::type_t, NAME, MenuItemInfo_##NAME::strfunc) + +DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(int3); +DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(int4); +DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(int8); +DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(float3); +DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(float52); +DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(float43); +DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(float5); +DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(float51); +DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(float52sign); +DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(float62); +DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(long5); + +#define draw_menu_item_edit_bool(sel, row, pstr, pstr2, data, ...) DRAW_BOOL_SETTING(sel, row, pstr, data) +#define draw_menu_item_edit_accessor_bool(sel, row, pstr, pstr2, pget, pset) DRAW_BOOL_SETTING(sel, row, pstr, data) //////////////////////////////////////////// /////////////// Menu Actions /////////////// //////////////////////////////////////////// -class menu_item_back { +class MenuItem_back { public: static inline void action() { ui.goto_previous_screen(); } }; -class menu_item_submenu { +class MenuItem_submenu { public: static inline void action(const screenFunc_t func) { ui.save_previous_screen(); ui.goto_screen(func); } }; -class menu_item_gcode { +class MenuItem_gcode { public: static void action(const char * const pgcode); }; -class menu_item_function { +class MenuItem_function { public: static inline void action(const menuAction_t func) { (*func)(); }; }; @@ -160,19 +154,19 @@ template class TMenuItem : MenuItemBase { private: typedef typename NAME::type_t type_t; - inline static float unscale(const float value) {return value * (1.0f / NAME::scale);} - inline static float scale(const float value) {return value * NAME::scale;} - static void load(void *ptr, const int32_t value) {*((type_t*)ptr) = unscale(value);} - static char* to_string(const int32_t value) {return NAME::strfunc(unscale(value));} + inline static float unscale(const float value) { return value * (1.0f / NAME::scale); } + inline static float scale(const float value) { return value * NAME::scale; } + static void load(void *ptr, const int32_t value) { *((type_t*)ptr) = unscale(value); } + static char* to_string(const int32_t value) { return NAME::strfunc(unscale(value)); } public: - static void action_setting_edit(PGM_P const pstr, type_t * const ptr, const type_t minValue, const type_t maxValue, const screenFunc_t callback=NULL, const bool live=false) { + static void action_edit(PGM_P const pstr, type_t * const ptr, const type_t minValue, const type_t maxValue, const screenFunc_t callback=NULL, const bool live=false) { const int32_t minv = scale(minValue); init(pstr, ptr, minv, int32_t(scale(maxValue)) - minv, int32_t(scale(*ptr)) - minv, edit, callback, live); } static void edit() { MenuItemBase::edit(to_string, load); } }; -#define DECLARE_MENU_EDIT_ITEM(NAME) typedef TMenuItem menu_item_ ## NAME; +#define DECLARE_MENU_EDIT_ITEM(NAME) typedef TMenuItem MenuItem_##NAME; DECLARE_MENU_EDIT_ITEM(int3); DECLARE_MENU_EDIT_ITEM(int4); @@ -186,9 +180,9 @@ DECLARE_MENU_EDIT_ITEM(float52sign); DECLARE_MENU_EDIT_ITEM(float62); DECLARE_MENU_EDIT_ITEM(long5); -class menu_item_bool { +class MenuItem_bool { public: - static void action_setting_edit(PGM_P const pstr, bool* ptr, const screenFunc_t callbackFunc=NULL); + static void action_edit(PGM_P const pstr, bool* ptr, const screenFunc_t callbackFunc=NULL); }; //////////////////////////////////////////// @@ -247,22 +241,22 @@ class menu_item_bool { * MENU_ITEM generates draw & handler code for a menu item, potentially calling: * * draw_menu_item_[_variant](sel, row, label, arg3...) - * menu_item_::action[_variant](arg3...) + * MenuItem_::action[_variant](arg3...) * * Examples: * MENU_ITEM(back, MSG_WATCH, 0 [dummy parameter] ) * or * MENU_BACK(MSG_WATCH) * draw_menu_item_back(sel, row, PSTR(MSG_WATCH)) - * menu_item_back::action() + * MenuItem_back::action() * * MENU_ITEM(function, MSG_PAUSE_PRINT, lcd_sdcard_pause) * draw_menu_item_function(sel, row, PSTR(MSG_PAUSE_PRINT), lcd_sdcard_pause) - * menu_item_function::action(lcd_sdcard_pause) + * MenuItem_function::action(lcd_sdcard_pause) * * MENU_ITEM_EDIT(int3, MSG_SPEED, &feedrate_percentage, 10, 999) - * draw_menu_item_setting_edit_int3(sel, row, PSTR(MSG_SPEED), PSTR(MSG_SPEED), &feedrate_percentage, 10, 999) - * menu_item_int3::action_setting_edit(PSTR(MSG_SPEED), &feedrate_percentage, 10, 999) + * draw_menu_item_edit_int3(sel, row, PSTR(MSG_SPEED), PSTR(MSG_SPEED), &feedrate_percentage, 10, 999) + * MenuItem_int3::action_edit(PSTR(MSG_SPEED), &feedrate_percentage, 10, 999) * */ #define _MENU_ITEM_VARIANT_P(TYPE, VARIANT, USE_MULTIPLIER, PLABEL, ...) do { \ @@ -270,7 +264,7 @@ class menu_item_bool { if (_menuLineNr == _thisItemNr) { \ if (encoderLine == _thisItemNr && ui.use_click()) { \ _MENU_ITEM_MULTIPLIER_CHECK(USE_MULTIPLIER); \ - menu_item_ ## TYPE ::action ## VARIANT(__VA_ARGS__); \ + MenuItem_##TYPE ::action ## VARIANT(__VA_ARGS__); \ if (screen_changed) return; \ } \ if (ui.should_draw()) \ @@ -305,10 +299,10 @@ class menu_item_bool { #define MENU_ITEM_DUMMY() do { _thisItemNr++; }while(0) #define MENU_ITEM_P(TYPE, PLABEL, ...) _MENU_ITEM_VARIANT_P(TYPE, , false, PLABEL, ## __VA_ARGS__) #define MENU_ITEM(TYPE, LABEL, ...) _MENU_ITEM_VARIANT_P(TYPE, , false, PSTR(LABEL), ## __VA_ARGS__) -#define MENU_ITEM_EDIT(TYPE, LABEL, ...) _MENU_ITEM_VARIANT_P(TYPE, _setting_edit, false, PSTR(LABEL), PSTR(LABEL), ## __VA_ARGS__) -#define MENU_ITEM_EDIT_CALLBACK(TYPE, LABEL, ...) _MENU_ITEM_VARIANT_P(TYPE, _setting_edit, false, PSTR(LABEL), PSTR(LABEL), ## __VA_ARGS__) -#define MENU_MULTIPLIER_ITEM_EDIT(TYPE, LABEL, ...) _MENU_ITEM_VARIANT_P(TYPE, _setting_edit, true, PSTR(LABEL), PSTR(LABEL), ## __VA_ARGS__) -#define MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(TYPE, LABEL, ...) _MENU_ITEM_VARIANT_P(TYPE, _setting_edit, true, PSTR(LABEL), PSTR(LABEL), ## __VA_ARGS__) +#define MENU_ITEM_EDIT(TYPE, LABEL, ...) _MENU_ITEM_VARIANT_P(TYPE, _edit, false, PSTR(LABEL), PSTR(LABEL), ## __VA_ARGS__) +#define MENU_ITEM_EDIT_CALLBACK(TYPE, LABEL, ...) _MENU_ITEM_VARIANT_P(TYPE, _edit, false, PSTR(LABEL), PSTR(LABEL), ## __VA_ARGS__) +#define MENU_MULTIPLIER_ITEM_EDIT(TYPE, LABEL, ...) _MENU_ITEM_VARIANT_P(TYPE, _edit, true, PSTR(LABEL), PSTR(LABEL), ## __VA_ARGS__) +#define MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(TYPE, LABEL, ...) _MENU_ITEM_VARIANT_P(TYPE, _edit, true, PSTR(LABEL), PSTR(LABEL), ## __VA_ARGS__) //////////////////////////////////////////// /////////////// Menu Screens /////////////// diff --git a/Marlin/src/lcd/menu/menu_sdcard.cpp b/Marlin/src/lcd/menu/menu_sdcard.cpp index 85caa17a2..7f4053003 100644 --- a/Marlin/src/lcd/menu/menu_sdcard.cpp +++ b/Marlin/src/lcd/menu/menu_sdcard.cpp @@ -72,7 +72,7 @@ void lcd_sd_updir() { } #endif -class menu_item_sdfile { +class MenuItem_sdfile { public: static void action(CardReader &theCard) { #if ENABLED(SD_REPRINT_LAST_SELECTED_FILE) @@ -84,7 +84,7 @@ class menu_item_sdfile { } }; -class menu_item_sdfolder { +class MenuItem_sdfolder { public: static void action(CardReader &theCard) { card.chdir(theCard.filename); diff --git a/Marlin/src/lcd/ultralcd.cpp b/Marlin/src/lcd/ultralcd.cpp index 9ee19730c..8baab7e91 100644 --- a/Marlin/src/lcd/ultralcd.cpp +++ b/Marlin/src/lcd/ultralcd.cpp @@ -269,7 +269,7 @@ bool MarlinUI::get_blink() { #if HAS_LCD_MENU if (RRK(EN_REPRAPWORLD_KEYPAD_DOWN)) encoderPosition -= ENCODER_STEPS_PER_MENU_ITEM; else if (RRK(EN_REPRAPWORLD_KEYPAD_UP)) encoderPosition += ENCODER_STEPS_PER_MENU_ITEM; - else if (RRK(EN_REPRAPWORLD_KEYPAD_LEFT)) { menu_item_back::action(); quick_feedback(); } + else if (RRK(EN_REPRAPWORLD_KEYPAD_LEFT)) { MenuItem_back::action(); quick_feedback(); } else if (RRK(EN_REPRAPWORLD_KEYPAD_RIGHT)) { return_to_status(); quick_feedback(); } #endif } diff --git a/Marlin/src/libs/buzzer.cpp b/Marlin/src/libs/buzzer.cpp index 6fb4d51a0..997c22643 100644 --- a/Marlin/src/libs/buzzer.cpp +++ b/Marlin/src/libs/buzzer.cpp @@ -64,7 +64,7 @@ void Buzzer::tick() { if (state.tone.frequency > 0) { #if ENABLED(EXTENSIBLE_UI) CRITICAL_SECTION_START; - UI::onPlayTone(state.tone.frequency, state.tone.duration); + ExtUI::onPlayTone(state.tone.frequency, state.tone.duration); CRITICAL_SECTION_END; #elif ENABLED(SPEAKER) CRITICAL_SECTION_START; diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 77ac6f7a7..475d38aad 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -943,7 +943,7 @@ void Temperature::manage_heater() { // Derived from RepRap FiveD extruder::getTemperature() // For hot end temperature measurement. -float Temperature::analog2temp(const int raw, const uint8_t e) { +float Temperature::analog_to_celsius_hotend(const int raw, const uint8_t e) { #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) if (e > HOTENDS) #else @@ -1015,7 +1015,7 @@ float Temperature::analog2temp(const int raw, const uint8_t e) { #if HAS_HEATED_BED // Derived from RepRap FiveD extruder::getTemperature() // For bed temperature measurement. - float Temperature::analog2tempBed(const int raw) { + float Temperature::analog_to_celsius_bed(const int raw) { #if ENABLED(HEATER_BED_USES_THERMISTOR) SCAN_THERMISTOR_TABLE(BEDTEMPTABLE, BEDTEMPTABLE_LEN); #elif ENABLED(HEATER_BED_USES_AD595) @@ -1031,7 +1031,7 @@ float Temperature::analog2temp(const int raw, const uint8_t e) { #if HAS_TEMP_CHAMBER // Derived from RepRap FiveD extruder::getTemperature() // For chamber temperature measurement. - float Temperature::analog2tempChamber(const int raw) { + float Temperature::analog_to_celsiusChamber(const int raw) { #if ENABLED(HEATER_CHAMBER_USES_THERMISTOR) SCAN_THERMISTOR_TABLE(CHAMBERTEMPTABLE, CHAMBERTEMPTABLE_LEN); #elif ENABLED(HEATER_CHAMBER_USES_AD595) @@ -1054,18 +1054,18 @@ void Temperature::updateTemperaturesFromRawValues() { #if ENABLED(HEATER_0_USES_MAX6675) current_temperature_raw[0] = read_max6675(); #endif - HOTEND_LOOP() current_temperature[e] = Temperature::analog2temp(current_temperature_raw[e], e); + HOTEND_LOOP() current_temperature[e] = analog_to_celsius_hotend(current_temperature_raw[e], e); #if HAS_HEATED_BED - current_temperature_bed = Temperature::analog2tempBed(current_temperature_bed_raw); + current_temperature_bed = analog_to_celsius_bed(current_temperature_bed_raw); #endif #if HAS_TEMP_CHAMBER - current_temperature_chamber = Temperature::analog2tempChamber(current_temperature_chamber_raw); + current_temperature_chamber = analog_to_celsiusChamber(current_temperature_chamber_raw); #endif #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) - redundant_temperature = Temperature::analog2temp(redundant_temperature_raw, 1); + redundant_temperature = analog_to_celsius_hotend(redundant_temperature_raw, 1); #endif #if ENABLED(FILAMENT_WIDTH_SENSOR) - filament_width_meas = analog2widthFil(); + filament_width_meas = analog_to_mm_fil_width(); #endif #if ENABLED(USE_WATCHDOG) @@ -1080,7 +1080,7 @@ void Temperature::updateTemperaturesFromRawValues() { #if ENABLED(FILAMENT_WIDTH_SENSOR) // Convert raw Filament Width to millimeters - float Temperature::analog2widthFil() { + float Temperature::analog_to_mm_fil_width() { return current_raw_filwidth * 5.0f * (1.0f / 16383.0f); } @@ -1299,7 +1299,7 @@ void Temperature::init() { #define TEMP_MIN_ROUTINE(NR) \ minttemp[NR] = HEATER_ ##NR## _MINTEMP; \ - while (analog2temp(minttemp_raw[NR], NR) < HEATER_ ##NR## _MINTEMP) { \ + while (analog_to_celsius_hotend(minttemp_raw[NR], NR) < HEATER_ ##NR## _MINTEMP) { \ if (HEATER_ ##NR## _RAW_LO_TEMP < HEATER_ ##NR## _RAW_HI_TEMP) \ minttemp_raw[NR] += OVERSAMPLENR; \ else \ @@ -1307,7 +1307,7 @@ void Temperature::init() { } #define TEMP_MAX_ROUTINE(NR) \ maxttemp[NR] = HEATER_ ##NR## _MAXTEMP; \ - while (analog2temp(maxttemp_raw[NR], NR) > HEATER_ ##NR## _MAXTEMP) { \ + while (analog_to_celsius_hotend(maxttemp_raw[NR], NR) > HEATER_ ##NR## _MAXTEMP) { \ if (HEATER_ ##NR## _RAW_LO_TEMP < HEATER_ ##NR## _RAW_HI_TEMP) \ maxttemp_raw[NR] -= OVERSAMPLENR; \ else \ @@ -1363,7 +1363,7 @@ void Temperature::init() { #if HAS_HEATED_BED #ifdef BED_MINTEMP - while (analog2tempBed(bed_minttemp_raw) < BED_MINTEMP) { + while (analog_to_celsius_bed(bed_minttemp_raw) < BED_MINTEMP) { #if HEATER_BED_RAW_LO_TEMP < HEATER_BED_RAW_HI_TEMP bed_minttemp_raw += OVERSAMPLENR; #else @@ -1372,7 +1372,7 @@ void Temperature::init() { } #endif // BED_MINTEMP #ifdef BED_MAXTEMP - while (analog2tempBed(bed_maxttemp_raw) > BED_MAXTEMP) { + while (analog_to_celsius_bed(bed_maxttemp_raw) > BED_MAXTEMP) { #if HEATER_BED_RAW_LO_TEMP < HEATER_BED_RAW_HI_TEMP bed_maxttemp_raw -= OVERSAMPLENR; #else diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index c7031fd46..9672707da 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -311,13 +311,13 @@ class Temperature { /** * Static (class) methods */ - static float analog2temp(const int raw, const uint8_t e); + static float analog_to_celsius_hotend(const int raw, const uint8_t e); #if HAS_HEATED_BED - static float analog2tempBed(const int raw); + static float analog_to_celsius_bed(const int raw); #endif #if HAS_TEMP_CHAMBER - static float analog2tempChamber(const int raw); + static float analog_to_celsiusChamber(const int raw); #endif /** @@ -358,7 +358,7 @@ class Temperature { #endif #if ENABLED(FILAMENT_WIDTH_SENSOR) - static float analog2widthFil(); // Convert raw Filament Width to millimeters + static float analog_to_mm_fil_width(); // Convert raw Filament Width to millimeters static int8_t widthFil_to_size_ratio(); // Convert Filament Width (mm) to an extrusion ratio #endif