Browse Source

Open File Browser on Media Insert (option) (#20151)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
Thomas Niccolo Reyes 4 years ago
parent
commit
ecd8227de0
No account linked to committer's email address

+ 2
- 0
Marlin/Configuration_adv.h View File

@@ -1193,6 +1193,8 @@
1193 1193
 
1194 1194
   //#define MENU_ADDAUTOSTART               // Add a menu option to run auto#.g files
1195 1195
 
1196
+  //#define BROWSE_MEDIA_ON_INSERT          // Open the file browser when media is inserted
1197
+
1196 1198
   #define EVENT_GCODE_SD_ABORT "G28XY"      // G-code to run on SD Abort Print (e.g., "G28XY" or "G27")
1197 1199
 
1198 1200
   #if ENABLED(PRINTER_EVENT_LEDS)

+ 1
- 1
Marlin/src/feature/password/password.h View File

@@ -47,7 +47,7 @@ public:
47 47
     static void start_over();
48 48
 
49 49
     static void digit_entered();
50
-    static void set_password_done();
50
+    static void set_password_done(const bool with_set=true);
51 51
     static void menu_password_report();
52 52
 
53 53
     static void remove_password();

+ 2
- 6
Marlin/src/gcode/gcode.h View File

@@ -769,12 +769,8 @@ private:
769 769
 
770 770
   #if ENABLED(PASSWORD_FEATURE)
771 771
     static void M510();
772
-    #if ENABLED(PASSWORD_UNLOCK_GCODE)
773
-      static void M511();
774
-    #endif
775
-    #if ENABLED(PASSWORD_CHANGE_GCODE)
776
-      static void M512();
777
-    #endif
772
+    TERN_(PASSWORD_UNLOCK_GCODE, static void M511());
773
+    TERN_(PASSWORD_CHANGE_GCODE, static void M512());
778 774
   #endif
779 775
 
780 776
   TERN_(SDSUPPORT, static void M524());

+ 10
- 1
Marlin/src/lcd/marlinui.cpp View File

@@ -30,6 +30,10 @@
30 30
   #include "../feature/host_actions.h"
31 31
 #endif
32 32
 
33
+#if ENABLED(BROWSE_MEDIA_ON_INSERT, PASSWORD_ON_SD_PRINT_MENU)
34
+  #include "../feature/password/password.h"
35
+#endif
36
+
33 37
 // All displays share the MarlinUI class
34 38
 #include "marlinui.h"
35 39
 MarlinUI ui;
@@ -1620,7 +1624,12 @@ void MarlinUI::update() {
1620 1624
     if (status) {
1621 1625
       if (old_status < 2) {
1622 1626
         TERN_(EXTENSIBLE_UI, ExtUI::onMediaInserted()); // ExtUI response
1623
-        set_status_P(GET_TEXT(MSG_MEDIA_INSERTED));
1627
+        #if ENABLED(BROWSE_MEDIA_ON_INSERT)
1628
+          quick_feedback();
1629
+          goto_screen(MEDIA_MENU_GATEWAY);
1630
+        #else
1631
+          set_status_P(GET_TEXT(MSG_MEDIA_INSERTED));
1632
+        #endif
1624 1633
       }
1625 1634
     }
1626 1635
     else {

+ 1
- 0
Marlin/src/lcd/marlinui.h View File

@@ -322,6 +322,7 @@ public:
322 322
   #endif
323 323
 
324 324
   #if ENABLED(SDSUPPORT)
325
+    #define MEDIA_MENU_GATEWAY TERN(PASSWORD_ON_SD_PRINT_MENU, password.media_gatekeeper, menu_media)
325 326
     static void media_changed(const uint8_t old_stat, const uint8_t stat);
326 327
   #endif
327 328
 

+ 1
- 0
Marlin/src/lcd/menu/menu_item.h View File

@@ -354,6 +354,7 @@ class MenuItem_bool : public MenuEditItemBase {
354 354
 #define MENU_ITEM_P(TYPE, PLABEL, V...)                 _MENU_ITEM_P(TYPE, false, PLABEL, ##V)
355 355
 #define MENU_ITEM(TYPE, LABEL, V...)                     MENU_ITEM_P(TYPE, GET_TEXT(LABEL), ##V)
356 356
 
357
+#define BACK_ITEM_P(PLABEL)                              MENU_ITEM_P(back, PLABEL)
357 358
 #define BACK_ITEM(LABEL)                                   MENU_ITEM(back, LABEL)
358 359
 
359 360
 #define ACTION_ITEM_N_S_P(N, S, PLABEL, ACTION)      MENU_ITEM_N_S_P(function, N, S, PLABEL, ACTION)

+ 2
- 2
Marlin/src/lcd/menu/menu_main.cpp View File

@@ -141,7 +141,7 @@ void menu_main() {
141 141
 
142 142
       if (card_detected) {
143 143
         if (!card_open) {
144
-          SUBMENU(MSG_MEDIA_MENU, TERN(PASSWORD_ON_SD_PRINT_MENU, password.media_gatekeeper, menu_media));
144
+          SUBMENU(MSG_MEDIA_MENU, MEDIA_MENU_GATEWAY);
145 145
           #if PIN_EXISTS(SD_DETECT)
146 146
             GCODES_ITEM(MSG_CHANGE_MEDIA, M21_STR);
147 147
           #else
@@ -248,7 +248,7 @@ void menu_main() {
248 248
           #else
249 249
             GCODES_ITEM(MSG_RELEASE_MEDIA, PSTR("M22"));
250 250
           #endif
251
-          SUBMENU(MSG_MEDIA_MENU, TERN(PASSWORD_ON_SD_PRINT_MENU, password.media_gatekeeper, menu_media));
251
+          SUBMENU(MSG_MEDIA_MENU, MEDIA_MENU_GATEWAY);
252 252
         }
253 253
       }
254 254
       else {

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

@@ -104,6 +104,8 @@ class MenuItem_sdfolder : public MenuItem_sdbase {
104 104
     }
105 105
 };
106 106
 
107
+extern uint8_t screen_history_depth;
108
+
107 109
 void menu_media() {
108 110
   ui.encoder_direction_menus();
109 111
 
@@ -115,7 +117,7 @@ void menu_media() {
115 117
   #endif
116 118
 
117 119
   START_MENU();
118
-  BACK_ITEM(MSG_MAIN);
120
+  BACK_ITEM_P(TERN1(BROWSE_MEDIA_ON_INSERT, screen_history_depth) ? GET_TEXT(MSG_MAIN) : GET_TEXT(MSG_BACK));
119 121
   if (card.flag.workDirIsRoot) {
120 122
     #if !PIN_EXISTS(SD_DETECT)
121 123
       ACTION_ITEM(MSG_REFRESH, []{ encoderTopLine = 0; card.mount(); });

+ 3
- 5
Marlin/src/lcd/menu/menu_password.cpp View File

@@ -152,19 +152,17 @@ void Password::menu_password_report() {
152 152
   END_SCREEN();
153 153
 }
154 154
 
155
-void Password::set_password_done() {
156
-  is_set = true;
155
+void Password::set_password_done(const bool with_set/*=true*/) {
156
+  is_set = with_set;
157 157
   value = value_entry;
158 158
   ui.completion_feedback(true);
159 159
   ui.goto_screen(menu_password_report);
160 160
 }
161 161
 
162 162
 void Password::remove_password() {
163
-  is_set = false;
164 163
   string[0] = '0';
165 164
   string[1] = '\0';
166
-  ui.completion_feedback(true);
167
-  ui.goto_screen(menu_password_report);
165
+  set_password_done(false);
168 166
 }
169 167
 
170 168
 //

Loading…
Cancel
Save