Browse Source

Custom menu items confirm option (#21338)

Co-authored-by: Scott Lahteine <github@thinkyhead.com>
vanilla_fb_2.0.x
InsanityAutomation 4 years ago
committed by Scott Lahteine
parent
commit
f36eb4646b
  1. 8
      Marlin/Configuration_adv.h
  2. 15
      Marlin/src/lcd/menu/menu_custom.cpp
  3. 12
      Marlin/src/lcd/menu/menu_main.cpp

8
Marlin/Configuration_adv.h

@ -3455,22 +3455,28 @@
//#define CUSTOM_USER_MENU_TITLE "Custom Commands" //#define CUSTOM_USER_MENU_TITLE "Custom Commands"
#define USER_SCRIPT_DONE "M117 User Script Done" #define USER_SCRIPT_DONE "M117 User Script Done"
#define USER_SCRIPT_AUDIBLE_FEEDBACK #define USER_SCRIPT_AUDIBLE_FEEDBACK
//#define USER_SCRIPT_RETURN // Return to status screen after a script //#define USER_SCRIPT_RETURN // Return to status screen after a script
#define CUSTOM_MENU_ONLY_IDLE // Only show custom menu when the machine is idle
#define USER_DESC_1 "Home & UBL Info" #define USER_DESC_1 "Home & UBL Info"
#define USER_GCODE_1 "G28\nG29W" #define USER_GCODE_1 "G28\nG29W"
//#define USER_CONFIRM_1 // Show a confirmation dialog before this action
#define USER_DESC_2 "Preheat for " PREHEAT_1_LABEL #define USER_DESC_2 "Preheat for " PREHEAT_1_LABEL
#define USER_GCODE_2 "M140 S" STRINGIFY(PREHEAT_1_TEMP_BED) "\nM104 S" STRINGIFY(PREHEAT_1_TEMP_HOTEND) #define USER_GCODE_2 "M140 S" STRINGIFY(PREHEAT_1_TEMP_BED) "\nM104 S" STRINGIFY(PREHEAT_1_TEMP_HOTEND)
//#define USER_CONFIRM_2
#define USER_DESC_3 "Preheat for " PREHEAT_2_LABEL #define USER_DESC_3 "Preheat for " PREHEAT_2_LABEL
#define USER_GCODE_3 "M140 S" STRINGIFY(PREHEAT_2_TEMP_BED) "\nM104 S" STRINGIFY(PREHEAT_2_TEMP_HOTEND) #define USER_GCODE_3 "M140 S" STRINGIFY(PREHEAT_2_TEMP_BED) "\nM104 S" STRINGIFY(PREHEAT_2_TEMP_HOTEND)
//#define USER_CONFIRM_3
#define USER_DESC_4 "Heat Bed/Home/Level" #define USER_DESC_4 "Heat Bed/Home/Level"
#define USER_GCODE_4 "M140 S" STRINGIFY(PREHEAT_2_TEMP_BED) "\nG28\nG29" #define USER_GCODE_4 "M140 S" STRINGIFY(PREHEAT_2_TEMP_BED) "\nG28\nG29"
//#define USER_CONFIRM_4
#define USER_DESC_5 "Home & Info" #define USER_DESC_5 "Home & Info"
#define USER_GCODE_5 "G28\nM503" #define USER_GCODE_5 "G28\nM503"
//#define USER_CONFIRM_5
#endif #endif
/** /**

15
Marlin/src/lcd/menu/menu_custom.cpp

@ -46,7 +46,20 @@ void _lcd_user_gcode(PGM_P const cmd) {
void menu_user() { void menu_user() {
START_MENU(); START_MENU();
BACK_ITEM(MSG_MAIN); BACK_ITEM(MSG_MAIN);
#define USER_ITEM(N) ACTION_ITEM_P(PSTR(USER_DESC_##N), []{ _lcd_user_gcode(PSTR(USER_GCODE_##N _DONE_SCRIPT)); });
#define GCODE_LAMBDA(N) []{ _lcd_user_gcode(PSTR(USER_GCODE_##N _DONE_SCRIPT)); }
#define _USER_ITEM(N) ACTION_ITEM_P(PSTR(USER_DESC_##N), GCODE_LAMBDA(N));
#define _USER_ITEM_CONFIRM(N) \
SUBMENU_P(PSTR(USER_DESC_##N), []{ \
MenuItem_confirm::confirm_screen( \
GCODE_LAMBDA(N), \
ui.goto_previous_screen, \
PSTR(USER_DESC_##N "?") \
); \
})
#define USER_ITEM(N) do{ if (ENABLED(USER_CONFIRM_##N)) _USER_ITEM_CONFIRM(N); else _USER_ITEM(N); }while(0)
#if HAS_USER_ITEM(1) #if HAS_USER_ITEM(1)
USER_ITEM(1); USER_ITEM(1);
#endif #endif

12
Marlin/src/lcd/menu/menu_main.cpp

@ -211,11 +211,13 @@ void menu_main() {
SUBMENU(MSG_CONFIGURATION, menu_configuration); SUBMENU(MSG_CONFIGURATION, menu_configuration);
#if ENABLED(CUSTOM_USER_MENUS) #if ENABLED(CUSTOM_USER_MENUS)
#ifdef CUSTOM_USER_MENU_TITLE if (TERN1(CUSTOM_MENU_ONLY_IDLE, !busy)) {
SUBMENU_P(PSTR(CUSTOM_USER_MENU_TITLE), menu_user); #ifdef CUSTOM_USER_MENU_TITLE
#else SUBMENU_P(PSTR(CUSTOM_USER_MENU_TITLE), menu_user);
SUBMENU(MSG_USER_MENU, menu_user); #else
#endif SUBMENU(MSG_USER_MENU, menu_user);
#endif
}
#endif #endif
#if ENABLED(ADVANCED_PAUSE_FEATURE) #if ENABLED(ADVANCED_PAUSE_FEATURE)

Loading…
Cancel
Save