mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2024-11-23 12:04:19 +00:00
✨ Shutdown Host Action (#22908)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
parent
8562f0ec44
commit
7b9e01eb2b
@ -3844,7 +3844,8 @@
|
||||
#if ENABLED(HOST_ACTION_COMMANDS)
|
||||
//#define HOST_PAUSE_M76
|
||||
//#define HOST_PROMPT_SUPPORT
|
||||
//#define HOST_START_MENU_ITEM // Add a menu item that tells the host to start
|
||||
//#define HOST_START_MENU_ITEM // Add a menu item that tells the host to start
|
||||
//#define HOST_SHUTDOWN_MENU_ITEM // Add a menu item that tells the host to shut down
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
@ -80,6 +80,10 @@ void HostUI::action(FSTR_P const fstr, const bool eol) {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef SHUTDOWN_ACTION
|
||||
void HostUI::shutdown() { action(F(SHUTDOWN_ACTION)); }
|
||||
#endif
|
||||
|
||||
#if ENABLED(HOST_PROMPT_SUPPORT)
|
||||
|
||||
PromptReason HostUI::host_prompt_reason = PROMPT_NOT_DEFINED;
|
||||
|
@ -71,6 +71,9 @@ class HostUI {
|
||||
#ifdef ACTION_ON_START
|
||||
static void start();
|
||||
#endif
|
||||
#ifdef SHUTDOWN_ACTION
|
||||
static void shutdown();
|
||||
#endif
|
||||
|
||||
#if ENABLED(G29_RETRY_AND_RECOVER)
|
||||
#ifdef ACTION_ON_G29_RECOVER
|
||||
|
@ -701,6 +701,9 @@
|
||||
#ifndef ACTION_ON_KILL
|
||||
#define ACTION_ON_KILL "poweroff"
|
||||
#endif
|
||||
#ifndef SHUTDOWN_ACTION
|
||||
#define SHUTDOWN_ACTION "shutdown"
|
||||
#endif
|
||||
#if HAS_FILAMENT_SENSOR
|
||||
#ifndef ACTION_ON_FILAMENT_RUNOUT
|
||||
#define ACTION_ON_FILAMENT_RUNOUT "filament_runout"
|
||||
|
@ -745,6 +745,8 @@ namespace Language_en {
|
||||
LSTR MSG_SD_CARD = _UxGT("SD Card");
|
||||
LSTR MSG_USB_DISK = _UxGT("USB Disk");
|
||||
|
||||
LSTR MSG_HOST_SHUTDOWN = _UxGT("Host Shutdown");
|
||||
|
||||
// These strings can be the same in all languages
|
||||
LSTR MSG_MARLIN = _UxGT("Marlin");
|
||||
LSTR MSG_SHORT_DAY = _UxGT("d"); // One character only
|
||||
|
@ -213,7 +213,7 @@ static void _lcd_level_bed_corners_get_next_position() {
|
||||
if (!ui.should_draw()) return;
|
||||
MenuItem_confirm::confirm_screen(
|
||||
[]{ queue.inject(TERN(HAS_LEVELING, F("G29N"), FPSTR(G28_STR))); ui.return_to_status(); }
|
||||
, []{ ui.goto_previous_screen_no_defer(); }
|
||||
, ui.goto_previous_screen_no_defer
|
||||
, GET_TEXT(MSG_BED_TRAMMING_IN_RANGE)
|
||||
, (const char*)nullptr, PSTR("?")
|
||||
);
|
||||
|
@ -47,7 +47,7 @@ static void lcd_cancel_object_confirm() {
|
||||
ui.completion_feedback();
|
||||
ui.goto_previous_screen();
|
||||
},
|
||||
ui.goto_previous_screen,
|
||||
nullptr,
|
||||
GET_TEXT(MSG_CANCEL_OBJECT), item_num, PSTR("?")
|
||||
);
|
||||
}
|
||||
|
@ -64,9 +64,7 @@ void menu_advanced_settings();
|
||||
static int8_t bar_percent = 0;
|
||||
if (ui.use_click()) {
|
||||
ui.goto_previous_screen();
|
||||
#if HAS_MARLINUI_HD44780
|
||||
ui.set_custom_characters(CHARSET_MENU);
|
||||
#endif
|
||||
TERN_(HAS_MARLINUI_HD44780, ui.set_custom_characters(CHARSET_MENU));
|
||||
return;
|
||||
}
|
||||
bar_percent += (int8_t)ui.encoderPosition;
|
||||
@ -79,9 +77,7 @@ void menu_advanced_settings();
|
||||
|
||||
void _progress_bar_test() {
|
||||
ui.goto_screen(progress_bar_test);
|
||||
#if HAS_MARLINUI_HD44780
|
||||
ui.set_custom_characters(CHARSET_INFO);
|
||||
#endif
|
||||
TERN_(HAS_MARLINUI_HD44780, ui.set_custom_characters(CHARSET_INFO));
|
||||
}
|
||||
|
||||
#endif // LCD_PROGRESS_BAR_TEST
|
||||
@ -363,8 +359,7 @@ void menu_advanced_settings();
|
||||
#define _CUSTOM_ITEM_CONF_CONFIRM(N) \
|
||||
SUBMENU_P(PSTR(CONFIG_MENU_ITEM_##N##_DESC), []{ \
|
||||
MenuItem_confirm::confirm_screen( \
|
||||
GCODE_LAMBDA_CONF(N), \
|
||||
ui.goto_previous_screen, \
|
||||
GCODE_LAMBDA_CONF(N), nullptr, \
|
||||
PSTR(CONFIG_MENU_ITEM_##N##_DESC "?") \
|
||||
); \
|
||||
})
|
||||
|
@ -58,7 +58,7 @@
|
||||
#include "../../feature/password/password.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(HOST_START_MENU_ITEM) && defined(ACTION_ON_START)
|
||||
#if (ENABLED(HOST_START_MENU_ITEM) && defined(ACTION_ON_START)) || (ENABLED(HOST_SHUTDOWN_MENU_ITEM) && defined(SHUTDOWN_ACTION))
|
||||
#include "../../feature/host_actions.h"
|
||||
#endif
|
||||
|
||||
@ -128,8 +128,7 @@ void menu_configuration();
|
||||
#define _CUSTOM_ITEM_MAIN_CONFIRM(N) \
|
||||
SUBMENU_P(PSTR(MAIN_MENU_ITEM_##N##_DESC), []{ \
|
||||
MenuItem_confirm::confirm_screen( \
|
||||
GCODE_LAMBDA_MAIN(N), \
|
||||
ui.goto_previous_screen, \
|
||||
GCODE_LAMBDA_MAIN(N), nullptr, \
|
||||
PSTR(MAIN_MENU_ITEM_##N##_DESC "?") \
|
||||
); \
|
||||
})
|
||||
@ -274,7 +273,7 @@ void menu_main() {
|
||||
SUBMENU(MSG_STOP_PRINT, []{
|
||||
MenuItem_confirm::select_screen(
|
||||
GET_TEXT(MSG_BUTTON_STOP), GET_TEXT(MSG_BACK),
|
||||
ui.abort_print, ui.goto_previous_screen,
|
||||
ui.abort_print, nullptr,
|
||||
GET_TEXT(MSG_STOP_PRINT), (const char *)nullptr, PSTR("?")
|
||||
);
|
||||
});
|
||||
@ -346,7 +345,7 @@ void menu_main() {
|
||||
#if ENABLED(ADVANCED_PAUSE_FEATURE)
|
||||
#if E_STEPPERS == 1 && DISABLED(FILAMENT_LOAD_UNLOAD_GCODES)
|
||||
YESNO_ITEM(MSG_FILAMENTCHANGE,
|
||||
menu_change_filament, ui.goto_previous_screen,
|
||||
menu_change_filament, nullptr,
|
||||
GET_TEXT(MSG_FILAMENTCHANGE), (const char *)nullptr, PSTR("?")
|
||||
);
|
||||
#else
|
||||
@ -370,7 +369,7 @@ void menu_main() {
|
||||
#if ENABLED(PS_OFF_CONFIRM)
|
||||
CONFIRM_ITEM(MSG_SWITCH_PS_OFF,
|
||||
MSG_YES, MSG_NO,
|
||||
ui.poweroff, ui.goto_previous_screen,
|
||||
ui.poweroff, nullptr,
|
||||
GET_TEXT(MSG_SWITCH_PS_OFF), (const char *)nullptr, PSTR("?")
|
||||
);
|
||||
#else
|
||||
@ -394,21 +393,21 @@ void menu_main() {
|
||||
#if SERVICE_INTERVAL_1 > 0
|
||||
CONFIRM_ITEM_P(PSTR(SERVICE_NAME_1),
|
||||
MSG_BUTTON_RESET, MSG_BUTTON_CANCEL,
|
||||
[]{ _service_reset(1); }, ui.goto_previous_screen,
|
||||
[]{ _service_reset(1); }, nullptr,
|
||||
GET_TEXT(MSG_SERVICE_RESET), F(SERVICE_NAME_1), PSTR("?")
|
||||
);
|
||||
#endif
|
||||
#if SERVICE_INTERVAL_2 > 0
|
||||
CONFIRM_ITEM_P(PSTR(SERVICE_NAME_2),
|
||||
MSG_BUTTON_RESET, MSG_BUTTON_CANCEL,
|
||||
[]{ _service_reset(2); }, ui.goto_previous_screen,
|
||||
[]{ _service_reset(2); }, nullptr,
|
||||
GET_TEXT(MSG_SERVICE_RESET), F(SERVICE_NAME_2), PSTR("?")
|
||||
);
|
||||
#endif
|
||||
#if SERVICE_INTERVAL_3 > 0
|
||||
CONFIRM_ITEM_P(PSTR(SERVICE_NAME_3),
|
||||
MSG_BUTTON_RESET, MSG_BUTTON_CANCEL,
|
||||
[]{ _service_reset(3); }, ui.goto_previous_screen,
|
||||
[]{ _service_reset(3); }, nullptr,
|
||||
GET_TEXT(MSG_SERVICE_RESET), F(SERVICE_NAME_3), PSTR("?")
|
||||
);
|
||||
#endif
|
||||
@ -442,6 +441,16 @@ void menu_main() {
|
||||
SUBMENU(LANGUAGE, menu_language);
|
||||
#endif
|
||||
|
||||
#if ENABLED(HOST_SHUTDOWN_MENU_ITEM) && defined(SHUTDOWN_ACTION)
|
||||
SUBMENU(MSG_HOST_SHUTDOWN, []{
|
||||
MenuItem_confirm::select_screen(
|
||||
GET_TEXT(MSG_BUTTON_PROCEED), GET_TEXT(MSG_BUTTON_CANCEL),
|
||||
[]{ ui.return_to_status(); hostui.shutdown(); }, nullptr,
|
||||
GET_TEXT(MSG_HOST_SHUTDOWN), (const char *)nullptr, PSTR("?")
|
||||
);
|
||||
});
|
||||
#endif
|
||||
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ class MenuItem_sdfile : public MenuItem_sdbase {
|
||||
strcpy(buffer + 1, longest);
|
||||
MenuItem_confirm::select_screen(
|
||||
GET_TEXT(MSG_BUTTON_PRINT), GET_TEXT(MSG_BUTTON_CANCEL),
|
||||
sdcard_start_selected_file, ui.goto_previous_screen,
|
||||
sdcard_start_selected_file, nullptr,
|
||||
GET_TEXT(MSG_START_PRINT), buffer, PSTR("?")
|
||||
);
|
||||
});
|
||||
|
@ -210,7 +210,7 @@ void _menu_move_distance(const AxisEnum axis, const screenFunc_t func, const int
|
||||
ui.goto_screen([]{
|
||||
MenuItem_confirm::select_screen(
|
||||
GET_TEXT(MSG_BUTTON_PROCEED), GET_TEXT(MSG_BACK),
|
||||
_goto_menu_move_distance_e, ui.goto_previous_screen,
|
||||
_goto_menu_move_distance_e, nullptr,
|
||||
GET_TEXT(MSG_HOTEND_TOO_COLD), (const char *)nullptr, PSTR("!")
|
||||
);
|
||||
});
|
||||
|
@ -66,7 +66,7 @@ static void _menu_single_probe() {
|
||||
STATIC_ITEM(MSG_BED_TRAMMING, SS_LEFT);
|
||||
STATIC_ITEM(MSG_LAST_VALUE_SP, SS_LEFT, z_isvalid[tram_index] ? ftostr42_52(z_measured[reference_index] - z_measured[tram_index]) : "---");
|
||||
ACTION_ITEM(MSG_UBL_BC_INSERT2, []{ if (probe_single_point()) ui.refresh(); });
|
||||
ACTION_ITEM(MSG_BUTTON_DONE, []{ ui.goto_previous_screen(); });
|
||||
ACTION_ITEM(MSG_BUTTON_DONE, ui.goto_previous_screen);
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user