Custom menu items confirm option (#21338)
Co-authored-by: Scott Lahteine <github@thinkyhead.com>
This commit is contained in:
parent
0c3eb04a37
commit
f36eb4646b
|
@ -3456,21 +3456,27 @@
|
|||
#define USER_SCRIPT_DONE "M117 User Script Done"
|
||||
#define USER_SCRIPT_AUDIBLE_FEEDBACK
|
||||
//#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_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_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_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_GCODE_4 "M140 S" STRINGIFY(PREHEAT_2_TEMP_BED) "\nG28\nG29"
|
||||
//#define USER_CONFIRM_4
|
||||
|
||||
#define USER_DESC_5 "Home & Info"
|
||||
#define USER_GCODE_5 "G28\nM503"
|
||||
//#define USER_CONFIRM_5
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
|
|
@ -46,7 +46,20 @@ void _lcd_user_gcode(PGM_P const cmd) {
|
|||
void menu_user() {
|
||||
START_MENU();
|
||||
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)
|
||||
USER_ITEM(1);
|
||||
#endif
|
||||
|
|
|
@ -211,11 +211,13 @@ void menu_main() {
|
|||
SUBMENU(MSG_CONFIGURATION, menu_configuration);
|
||||
|
||||
#if ENABLED(CUSTOM_USER_MENUS)
|
||||
if (TERN1(CUSTOM_MENU_ONLY_IDLE, !busy)) {
|
||||
#ifdef CUSTOM_USER_MENU_TITLE
|
||||
SUBMENU_P(PSTR(CUSTOM_USER_MENU_TITLE), menu_user);
|
||||
#else
|
||||
SUBMENU(MSG_USER_MENU, menu_user);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ENABLED(ADVANCED_PAUSE_FEATURE)
|
||||
|
|
Loading…
Reference in a new issue