Sfoglia il codice sorgente

✨ Shutdown Host Action (#22908)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
aalku 2 anni fa
parent
commit
75e0b7f8ff
Nessun account collegato all'indirizzo email del committer

+ 2
- 1
Marlin/Configuration_adv.h Vedi File

@@ -3844,7 +3844,8 @@
3844 3844
 #if ENABLED(HOST_ACTION_COMMANDS)
3845 3845
   //#define HOST_PAUSE_M76
3846 3846
   //#define HOST_PROMPT_SUPPORT
3847
-  //#define HOST_START_MENU_ITEM  // Add a menu item that tells the host to start
3847
+  //#define HOST_START_MENU_ITEM      // Add a menu item that tells the host to start
3848
+  //#define HOST_SHUTDOWN_MENU_ITEM   // Add a menu item that tells the host to shut down
3848 3849
 #endif
3849 3850
 
3850 3851
 /**

+ 4
- 0
Marlin/src/feature/host_actions.cpp Vedi File

@@ -80,6 +80,10 @@ void HostUI::action(FSTR_P const fstr, const bool eol) {
80 80
   #endif
81 81
 #endif
82 82
 
83
+#ifdef SHUTDOWN_ACTION
84
+  void HostUI::shutdown() { action(F(SHUTDOWN_ACTION)); }
85
+#endif
86
+
83 87
 #if ENABLED(HOST_PROMPT_SUPPORT)
84 88
 
85 89
   PromptReason HostUI::host_prompt_reason = PROMPT_NOT_DEFINED;

+ 3
- 0
Marlin/src/feature/host_actions.h Vedi File

@@ -71,6 +71,9 @@ class HostUI {
71 71
   #ifdef ACTION_ON_START
72 72
     static void start();
73 73
   #endif
74
+  #ifdef SHUTDOWN_ACTION
75
+    static void shutdown();
76
+  #endif
74 77
 
75 78
   #if ENABLED(G29_RETRY_AND_RECOVER)
76 79
     #ifdef ACTION_ON_G29_RECOVER

+ 3
- 0
Marlin/src/inc/Conditionals_adv.h Vedi File

@@ -701,6 +701,9 @@
701 701
   #ifndef ACTION_ON_KILL
702 702
     #define ACTION_ON_KILL    "poweroff"
703 703
   #endif
704
+  #ifndef SHUTDOWN_ACTION
705
+    #define SHUTDOWN_ACTION   "shutdown"
706
+  #endif
704 707
   #if HAS_FILAMENT_SENSOR
705 708
     #ifndef ACTION_ON_FILAMENT_RUNOUT
706 709
       #define ACTION_ON_FILAMENT_RUNOUT "filament_runout"

+ 2
- 0
Marlin/src/lcd/language/language_en.h Vedi File

@@ -745,6 +745,8 @@ namespace Language_en {
745 745
   LSTR MSG_SD_CARD                        = _UxGT("SD Card");
746 746
   LSTR MSG_USB_DISK                       = _UxGT("USB Disk");
747 747
 
748
+  LSTR MSG_HOST_SHUTDOWN                  = _UxGT("Host Shutdown");
749
+
748 750
   // These strings can be the same in all languages
749 751
   LSTR MSG_MARLIN                         = _UxGT("Marlin");
750 752
   LSTR MSG_SHORT_DAY                      = _UxGT("d"); // One character only

+ 1
- 1
Marlin/src/lcd/menu/menu_bed_corners.cpp Vedi File

@@ -213,7 +213,7 @@ static void _lcd_level_bed_corners_get_next_position() {
213 213
     if (!ui.should_draw()) return;
214 214
     MenuItem_confirm::confirm_screen(
215 215
         []{ queue.inject(TERN(HAS_LEVELING, F("G29N"), FPSTR(G28_STR))); ui.return_to_status(); }
216
-      , []{ ui.goto_previous_screen_no_defer(); }
216
+      , ui.goto_previous_screen_no_defer
217 217
       , GET_TEXT(MSG_BED_TRAMMING_IN_RANGE)
218 218
       , (const char*)nullptr, PSTR("?")
219 219
     );

+ 1
- 1
Marlin/src/lcd/menu/menu_cancelobject.cpp Vedi File

@@ -47,7 +47,7 @@ static void lcd_cancel_object_confirm() {
47 47
       ui.completion_feedback();
48 48
       ui.goto_previous_screen();
49 49
     },
50
-    ui.goto_previous_screen,
50
+    nullptr,
51 51
     GET_TEXT(MSG_CANCEL_OBJECT), item_num, PSTR("?")
52 52
   );
53 53
 }

+ 3
- 8
Marlin/src/lcd/menu/menu_configuration.cpp Vedi File

@@ -64,9 +64,7 @@ void menu_advanced_settings();
64 64
     static int8_t bar_percent = 0;
65 65
     if (ui.use_click()) {
66 66
       ui.goto_previous_screen();
67
-      #if HAS_MARLINUI_HD44780
68
-        ui.set_custom_characters(CHARSET_MENU);
69
-      #endif
67
+      TERN_(HAS_MARLINUI_HD44780, ui.set_custom_characters(CHARSET_MENU));
70 68
       return;
71 69
     }
72 70
     bar_percent += (int8_t)ui.encoderPosition;
@@ -79,9 +77,7 @@ void menu_advanced_settings();
79 77
 
80 78
   void _progress_bar_test() {
81 79
     ui.goto_screen(progress_bar_test);
82
-    #if HAS_MARLINUI_HD44780
83
-      ui.set_custom_characters(CHARSET_INFO);
84
-    #endif
80
+    TERN_(HAS_MARLINUI_HD44780, ui.set_custom_characters(CHARSET_INFO));
85 81
   }
86 82
 
87 83
 #endif // LCD_PROGRESS_BAR_TEST
@@ -363,8 +359,7 @@ void menu_advanced_settings();
363 359
     #define _CUSTOM_ITEM_CONF_CONFIRM(N)               \
364 360
       SUBMENU_P(PSTR(CONFIG_MENU_ITEM_##N##_DESC), []{ \
365 361
           MenuItem_confirm::confirm_screen(            \
366
-            GCODE_LAMBDA_CONF(N),                      \
367
-            ui.goto_previous_screen,                   \
362
+            GCODE_LAMBDA_CONF(N), nullptr,             \
368 363
             PSTR(CONFIG_MENU_ITEM_##N##_DESC "?")      \
369 364
           );                                           \
370 365
         })

+ 18
- 9
Marlin/src/lcd/menu/menu_main.cpp Vedi File

@@ -58,7 +58,7 @@
58 58
   #include "../../feature/password/password.h"
59 59
 #endif
60 60
 
61
-#if ENABLED(HOST_START_MENU_ITEM) && defined(ACTION_ON_START)
61
+#if (ENABLED(HOST_START_MENU_ITEM) && defined(ACTION_ON_START)) || (ENABLED(HOST_SHUTDOWN_MENU_ITEM) && defined(SHUTDOWN_ACTION))
62 62
   #include "../../feature/host_actions.h"
63 63
 #endif
64 64
 
@@ -128,8 +128,7 @@ void menu_configuration();
128 128
     #define _CUSTOM_ITEM_MAIN_CONFIRM(N)             \
129 129
       SUBMENU_P(PSTR(MAIN_MENU_ITEM_##N##_DESC), []{ \
130 130
           MenuItem_confirm::confirm_screen(          \
131
-            GCODE_LAMBDA_MAIN(N),                    \
132
-            ui.goto_previous_screen,                 \
131
+            GCODE_LAMBDA_MAIN(N), nullptr,           \
133 132
             PSTR(MAIN_MENU_ITEM_##N##_DESC "?")      \
134 133
           );                                         \
135 134
         })
@@ -274,7 +273,7 @@ void menu_main() {
274 273
       SUBMENU(MSG_STOP_PRINT, []{
275 274
         MenuItem_confirm::select_screen(
276 275
           GET_TEXT(MSG_BUTTON_STOP), GET_TEXT(MSG_BACK),
277
-          ui.abort_print, ui.goto_previous_screen,
276
+          ui.abort_print, nullptr,
278 277
           GET_TEXT(MSG_STOP_PRINT), (const char *)nullptr, PSTR("?")
279 278
         );
280 279
       });
@@ -346,7 +345,7 @@ void menu_main() {
346 345
   #if ENABLED(ADVANCED_PAUSE_FEATURE)
347 346
     #if E_STEPPERS == 1 && DISABLED(FILAMENT_LOAD_UNLOAD_GCODES)
348 347
       YESNO_ITEM(MSG_FILAMENTCHANGE,
349
-        menu_change_filament, ui.goto_previous_screen,
348
+        menu_change_filament, nullptr,
350 349
         GET_TEXT(MSG_FILAMENTCHANGE), (const char *)nullptr, PSTR("?")
351 350
       );
352 351
     #else
@@ -370,7 +369,7 @@ void menu_main() {
370 369
       #if ENABLED(PS_OFF_CONFIRM)
371 370
         CONFIRM_ITEM(MSG_SWITCH_PS_OFF,
372 371
           MSG_YES, MSG_NO,
373
-          ui.poweroff, ui.goto_previous_screen,
372
+          ui.poweroff, nullptr,
374 373
           GET_TEXT(MSG_SWITCH_PS_OFF), (const char *)nullptr, PSTR("?")
375 374
         );
376 375
       #else
@@ -394,21 +393,21 @@ void menu_main() {
394 393
     #if SERVICE_INTERVAL_1 > 0
395 394
       CONFIRM_ITEM_P(PSTR(SERVICE_NAME_1),
396 395
         MSG_BUTTON_RESET, MSG_BUTTON_CANCEL,
397
-        []{ _service_reset(1); }, ui.goto_previous_screen,
396
+        []{ _service_reset(1); }, nullptr,
398 397
         GET_TEXT(MSG_SERVICE_RESET), F(SERVICE_NAME_1), PSTR("?")
399 398
       );
400 399
     #endif
401 400
     #if SERVICE_INTERVAL_2 > 0
402 401
       CONFIRM_ITEM_P(PSTR(SERVICE_NAME_2),
403 402
         MSG_BUTTON_RESET, MSG_BUTTON_CANCEL,
404
-        []{ _service_reset(2); }, ui.goto_previous_screen,
403
+        []{ _service_reset(2); }, nullptr,
405 404
         GET_TEXT(MSG_SERVICE_RESET), F(SERVICE_NAME_2), PSTR("?")
406 405
       );
407 406
     #endif
408 407
     #if SERVICE_INTERVAL_3 > 0
409 408
       CONFIRM_ITEM_P(PSTR(SERVICE_NAME_3),
410 409
         MSG_BUTTON_RESET, MSG_BUTTON_CANCEL,
411
-        []{ _service_reset(3); }, ui.goto_previous_screen,
410
+        []{ _service_reset(3); }, nullptr,
412 411
         GET_TEXT(MSG_SERVICE_RESET), F(SERVICE_NAME_3), PSTR("?")
413 412
       );
414 413
     #endif
@@ -442,6 +441,16 @@ void menu_main() {
442 441
     SUBMENU(LANGUAGE, menu_language);
443 442
   #endif
444 443
 
444
+  #if ENABLED(HOST_SHUTDOWN_MENU_ITEM) && defined(SHUTDOWN_ACTION)
445
+    SUBMENU(MSG_HOST_SHUTDOWN, []{
446
+      MenuItem_confirm::select_screen(
447
+        GET_TEXT(MSG_BUTTON_PROCEED), GET_TEXT(MSG_BUTTON_CANCEL),
448
+        []{ ui.return_to_status(); hostui.shutdown(); }, nullptr,
449
+        GET_TEXT(MSG_HOST_SHUTDOWN), (const char *)nullptr, PSTR("?")
450
+      );
451
+    });
452
+  #endif
453
+
445 454
   END_MENU();
446 455
 }
447 456
 

+ 1
- 1
Marlin/src/lcd/menu/menu_media.cpp Vedi File

@@ -79,7 +79,7 @@ class MenuItem_sdfile : public MenuItem_sdbase {
79 79
           strcpy(buffer + 1, longest);
80 80
           MenuItem_confirm::select_screen(
81 81
             GET_TEXT(MSG_BUTTON_PRINT), GET_TEXT(MSG_BUTTON_CANCEL),
82
-            sdcard_start_selected_file, ui.goto_previous_screen,
82
+            sdcard_start_selected_file, nullptr,
83 83
             GET_TEXT(MSG_START_PRINT), buffer, PSTR("?")
84 84
           );
85 85
         });

+ 1
- 1
Marlin/src/lcd/menu/menu_motion.cpp Vedi File

@@ -210,7 +210,7 @@ void _menu_move_distance(const AxisEnum axis, const screenFunc_t func, const int
210 210
         ui.goto_screen([]{
211 211
           MenuItem_confirm::select_screen(
212 212
             GET_TEXT(MSG_BUTTON_PROCEED), GET_TEXT(MSG_BACK),
213
-            _goto_menu_move_distance_e, ui.goto_previous_screen,
213
+            _goto_menu_move_distance_e, nullptr,
214 214
             GET_TEXT(MSG_HOTEND_TOO_COLD), (const char *)nullptr, PSTR("!")
215 215
           );
216 216
         });

+ 1
- 1
Marlin/src/lcd/menu/menu_tramming.cpp Vedi File

@@ -66,7 +66,7 @@ static void _menu_single_probe() {
66 66
   STATIC_ITEM(MSG_BED_TRAMMING, SS_LEFT);
67 67
   STATIC_ITEM(MSG_LAST_VALUE_SP, SS_LEFT, z_isvalid[tram_index] ? ftostr42_52(z_measured[reference_index] - z_measured[tram_index]) : "---");
68 68
   ACTION_ITEM(MSG_UBL_BC_INSERT2, []{ if (probe_single_point()) ui.refresh(); });
69
-  ACTION_ITEM(MSG_BUTTON_DONE, []{ ui.goto_previous_screen(); });
69
+  ACTION_ITEM(MSG_BUTTON_DONE, ui.goto_previous_screen);
70 70
   END_MENU();
71 71
 }
72 72
 

Loading…
Annulla
Salva