From 0161d3f733a8b67d6aedd63aba6fc7beae229890 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 28 Oct 2018 03:05:17 -0500 Subject: [PATCH] Move Custom User Menu to its own file --- Marlin/src/lcd/menu/menu.cpp | 57 ------------------- Marlin/src/lcd/menu/menu_custom.cpp | 87 +++++++++++++++++++++++++++++ Marlin/src/lcd/menu/menu_main.cpp | 4 +- 3 files changed, 89 insertions(+), 59 deletions(-) create mode 100644 Marlin/src/lcd/menu/menu_custom.cpp diff --git a/Marlin/src/lcd/menu/menu.cpp b/Marlin/src/lcd/menu/menu.cpp index 55209ed3c0..b95b7b9836 100644 --- a/Marlin/src/lcd/menu/menu.cpp +++ b/Marlin/src/lcd/menu/menu.cpp @@ -388,63 +388,6 @@ void line_to_z(const float &z) { line_to_current_z(); } -#if ENABLED(CUSTOM_USER_MENUS) - - #ifdef USER_SCRIPT_DONE - #define _DONE_SCRIPT "\n" USER_SCRIPT_DONE - #else - #define _DONE_SCRIPT "" - #endif - - void _lcd_user_gcode(PGM_P const cmd) { - enqueue_and_echo_commands_P(cmd); - #if ENABLED(USER_SCRIPT_AUDIBLE_FEEDBACK) - lcd_completion_feedback(); - #endif - #if ENABLED(USER_SCRIPT_RETURN) - lcd_return_to_status(); - #endif - } - - #if defined(USER_DESC_1) && defined(USER_GCODE_1) - void lcd_user_gcode_1() { _lcd_user_gcode(PSTR(USER_GCODE_1 _DONE_SCRIPT)); } - #endif - #if defined(USER_DESC_2) && defined(USER_GCODE_2) - void lcd_user_gcode_2() { _lcd_user_gcode(PSTR(USER_GCODE_2 _DONE_SCRIPT)); } - #endif - #if defined(USER_DESC_3) && defined(USER_GCODE_3) - void lcd_user_gcode_3() { _lcd_user_gcode(PSTR(USER_GCODE_3 _DONE_SCRIPT)); } - #endif - #if defined(USER_DESC_4) && defined(USER_GCODE_4) - void lcd_user_gcode_4() { _lcd_user_gcode(PSTR(USER_GCODE_4 _DONE_SCRIPT)); } - #endif - #if defined(USER_DESC_5) && defined(USER_GCODE_5) - void lcd_user_gcode_5() { _lcd_user_gcode(PSTR(USER_GCODE_5 _DONE_SCRIPT)); } - #endif - - void _menu_user() { - START_MENU(); - MENU_BACK(MSG_MAIN); - #if defined(USER_DESC_1) && defined(USER_GCODE_1) - MENU_ITEM(function, USER_DESC_1, lcd_user_gcode_1); - #endif - #if defined(USER_DESC_2) && defined(USER_GCODE_2) - MENU_ITEM(function, USER_DESC_2, lcd_user_gcode_2); - #endif - #if defined(USER_DESC_3) && defined(USER_GCODE_3) - MENU_ITEM(function, USER_DESC_3, lcd_user_gcode_3); - #endif - #if defined(USER_DESC_4) && defined(USER_GCODE_4) - MENU_ITEM(function, USER_DESC_4, lcd_user_gcode_4); - #endif - #if defined(USER_DESC_5) && defined(USER_GCODE_5) - MENU_ITEM(function, USER_DESC_5, lcd_user_gcode_5); - #endif - END_MENU(); - } - -#endif - #if ENABLED(BABYSTEP_ZPROBE_OFFSET) void lcd_babystep_zoffset() { diff --git a/Marlin/src/lcd/menu/menu_custom.cpp b/Marlin/src/lcd/menu/menu_custom.cpp new file mode 100644 index 0000000000..f823a1049f --- /dev/null +++ b/Marlin/src/lcd/menu/menu_custom.cpp @@ -0,0 +1,87 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +// +// Custom User Menu +// + +#include "../../inc/MarlinConfigPre.h" + +#if HAS_LCD_MENU && ENABLED(CUSTOM_USER_MENUS) + +#include "menu.h" +#include "../../gcode/queue.h" + +#ifdef USER_SCRIPT_DONE + #define _DONE_SCRIPT "\n" USER_SCRIPT_DONE +#else + #define _DONE_SCRIPT "" +#endif + +void _lcd_user_gcode(PGM_P const cmd) { + enqueue_and_echo_commands_P(cmd); + #if ENABLED(USER_SCRIPT_AUDIBLE_FEEDBACK) + lcd_completion_feedback(); + #endif + #if ENABLED(USER_SCRIPT_RETURN) + lcd_return_to_status(); + #endif +} + +#if defined(USER_DESC_1) && defined(USER_GCODE_1) + void lcd_user_gcode_1() { _lcd_user_gcode(PSTR(USER_GCODE_1 _DONE_SCRIPT)); } +#endif +#if defined(USER_DESC_2) && defined(USER_GCODE_2) + void lcd_user_gcode_2() { _lcd_user_gcode(PSTR(USER_GCODE_2 _DONE_SCRIPT)); } +#endif +#if defined(USER_DESC_3) && defined(USER_GCODE_3) + void lcd_user_gcode_3() { _lcd_user_gcode(PSTR(USER_GCODE_3 _DONE_SCRIPT)); } +#endif +#if defined(USER_DESC_4) && defined(USER_GCODE_4) + void lcd_user_gcode_4() { _lcd_user_gcode(PSTR(USER_GCODE_4 _DONE_SCRIPT)); } +#endif +#if defined(USER_DESC_5) && defined(USER_GCODE_5) + void lcd_user_gcode_5() { _lcd_user_gcode(PSTR(USER_GCODE_5 _DONE_SCRIPT)); } +#endif + +void menu_user() { + START_MENU(); + MENU_BACK(MSG_MAIN); + #if defined(USER_DESC_1) && defined(USER_GCODE_1) + MENU_ITEM(function, USER_DESC_1, lcd_user_gcode_1); + #endif + #if defined(USER_DESC_2) && defined(USER_GCODE_2) + MENU_ITEM(function, USER_DESC_2, lcd_user_gcode_2); + #endif + #if defined(USER_DESC_3) && defined(USER_GCODE_3) + MENU_ITEM(function, USER_DESC_3, lcd_user_gcode_3); + #endif + #if defined(USER_DESC_4) && defined(USER_GCODE_4) + MENU_ITEM(function, USER_DESC_4, lcd_user_gcode_4); + #endif + #if defined(USER_DESC_5) && defined(USER_GCODE_5) + MENU_ITEM(function, USER_DESC_5, lcd_user_gcode_5); + #endif + END_MENU(); +} + +#endif // HAS_LCD_MENU && CUSTOM_USER_MENUS diff --git a/Marlin/src/lcd/menu/menu_main.cpp b/Marlin/src/lcd/menu/menu_main.cpp index 79d84adc67..2d227b34f0 100644 --- a/Marlin/src/lcd/menu/menu_main.cpp +++ b/Marlin/src/lcd/menu/menu_main.cpp @@ -75,7 +75,7 @@ void menu_tune(); void menu_motion(); void menu_temperature(); void menu_configuration(); -void _menu_user(); +void menu_user(); void menu_temp_e0_filament_change(); void menu_change_filament(); void menu_info(); @@ -120,7 +120,7 @@ void menu_main() { MENU_ITEM(submenu, MSG_CONFIGURATION, menu_configuration); #if ENABLED(CUSTOM_USER_MENUS) - MENU_ITEM(submenu, MSG_USER_MENU, _menu_user); + MENU_ITEM(submenu, MSG_USER_MENU, menu_user); #endif #if ENABLED(ADVANCED_PAUSE_FEATURE)