Browse Source

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

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

+ 2
- 0
Marlin/Configuration_adv.h View File

1193
 
1193
 
1194
   //#define MENU_ADDAUTOSTART               // Add a menu option to run auto#.g files
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
   #define EVENT_GCODE_SD_ABORT "G28XY"      // G-code to run on SD Abort Print (e.g., "G28XY" or "G27")
1198
   #define EVENT_GCODE_SD_ABORT "G28XY"      // G-code to run on SD Abort Print (e.g., "G28XY" or "G27")
1197
 
1199
 
1198
   #if ENABLED(PRINTER_EVENT_LEDS)
1200
   #if ENABLED(PRINTER_EVENT_LEDS)

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

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

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

769
 
769
 
770
   #if ENABLED(PASSWORD_FEATURE)
770
   #if ENABLED(PASSWORD_FEATURE)
771
     static void M510();
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
   #endif
774
   #endif
779
 
775
 
780
   TERN_(SDSUPPORT, static void M524());
776
   TERN_(SDSUPPORT, static void M524());

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

30
   #include "../feature/host_actions.h"
30
   #include "../feature/host_actions.h"
31
 #endif
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
 // All displays share the MarlinUI class
37
 // All displays share the MarlinUI class
34
 #include "marlinui.h"
38
 #include "marlinui.h"
35
 MarlinUI ui;
39
 MarlinUI ui;
1620
     if (status) {
1624
     if (status) {
1621
       if (old_status < 2) {
1625
       if (old_status < 2) {
1622
         TERN_(EXTENSIBLE_UI, ExtUI::onMediaInserted()); // ExtUI response
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
     else {
1635
     else {

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

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

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

354
 #define MENU_ITEM_P(TYPE, PLABEL, V...)                 _MENU_ITEM_P(TYPE, false, PLABEL, ##V)
354
 #define MENU_ITEM_P(TYPE, PLABEL, V...)                 _MENU_ITEM_P(TYPE, false, PLABEL, ##V)
355
 #define MENU_ITEM(TYPE, LABEL, V...)                     MENU_ITEM_P(TYPE, GET_TEXT(LABEL), ##V)
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
 #define BACK_ITEM(LABEL)                                   MENU_ITEM(back, LABEL)
358
 #define BACK_ITEM(LABEL)                                   MENU_ITEM(back, LABEL)
358
 
359
 
359
 #define ACTION_ITEM_N_S_P(N, S, PLABEL, ACTION)      MENU_ITEM_N_S_P(function, N, S, PLABEL, ACTION)
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
 
141
 
142
       if (card_detected) {
142
       if (card_detected) {
143
         if (!card_open) {
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
           #if PIN_EXISTS(SD_DETECT)
145
           #if PIN_EXISTS(SD_DETECT)
146
             GCODES_ITEM(MSG_CHANGE_MEDIA, M21_STR);
146
             GCODES_ITEM(MSG_CHANGE_MEDIA, M21_STR);
147
           #else
147
           #else
248
           #else
248
           #else
249
             GCODES_ITEM(MSG_RELEASE_MEDIA, PSTR("M22"));
249
             GCODES_ITEM(MSG_RELEASE_MEDIA, PSTR("M22"));
250
           #endif
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
       else {
254
       else {

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

104
     }
104
     }
105
 };
105
 };
106
 
106
 
107
+extern uint8_t screen_history_depth;
108
+
107
 void menu_media() {
109
 void menu_media() {
108
   ui.encoder_direction_menus();
110
   ui.encoder_direction_menus();
109
 
111
 
115
   #endif
117
   #endif
116
 
118
 
117
   START_MENU();
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
   if (card.flag.workDirIsRoot) {
121
   if (card.flag.workDirIsRoot) {
120
     #if !PIN_EXISTS(SD_DETECT)
122
     #if !PIN_EXISTS(SD_DETECT)
121
       ACTION_ITEM(MSG_REFRESH, []{ encoderTopLine = 0; card.mount(); });
123
       ACTION_ITEM(MSG_REFRESH, []{ encoderTopLine = 0; card.mount(); });

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

152
   END_SCREEN();
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
   value = value_entry;
157
   value = value_entry;
158
   ui.completion_feedback(true);
158
   ui.completion_feedback(true);
159
   ui.goto_screen(menu_password_report);
159
   ui.goto_screen(menu_password_report);
160
 }
160
 }
161
 
161
 
162
 void Password::remove_password() {
162
 void Password::remove_password() {
163
-  is_set = false;
164
   string[0] = '0';
163
   string[0] = '0';
165
   string[1] = '\0';
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