Browse Source

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

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
vanilla_fb_2.0.x
Thomas Niccolo Reyes 4 years ago
committed by Scott Lahteine
parent
commit
172cc0dd03
  1. 2
      Marlin/Configuration_adv.h
  2. 2
      Marlin/src/feature/password/password.h
  3. 8
      Marlin/src/gcode/gcode.h
  4. 11
      Marlin/src/lcd/marlinui.cpp
  5. 1
      Marlin/src/lcd/marlinui.h
  6. 1
      Marlin/src/lcd/menu/menu_item.h
  7. 4
      Marlin/src/lcd/menu/menu_main.cpp
  8. 4
      Marlin/src/lcd/menu/menu_media.cpp
  9. 8
      Marlin/src/lcd/menu/menu_password.cpp

2
Marlin/Configuration_adv.h

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

2
Marlin/src/feature/password/password.h

@ -47,7 +47,7 @@ public:
static void start_over(); static void start_over();
static void digit_entered(); static void digit_entered();
static void set_password_done(); static void set_password_done(const bool with_set=true);
static void menu_password_report(); static void menu_password_report();
static void remove_password(); static void remove_password();

8
Marlin/src/gcode/gcode.h

@ -769,12 +769,8 @@ private:
#if ENABLED(PASSWORD_FEATURE) #if ENABLED(PASSWORD_FEATURE)
static void M510(); static void M510();
#if ENABLED(PASSWORD_UNLOCK_GCODE) TERN_(PASSWORD_UNLOCK_GCODE, static void M511());
static void M511(); TERN_(PASSWORD_CHANGE_GCODE, static void M512());
#endif
#if ENABLED(PASSWORD_CHANGE_GCODE)
static void M512();
#endif
#endif #endif
TERN_(SDSUPPORT, static void M524()); TERN_(SDSUPPORT, static void M524());

11
Marlin/src/lcd/marlinui.cpp

@ -30,6 +30,10 @@
#include "../feature/host_actions.h" #include "../feature/host_actions.h"
#endif #endif
#if ENABLED(BROWSE_MEDIA_ON_INSERT, PASSWORD_ON_SD_PRINT_MENU)
#include "../feature/password/password.h"
#endif
// All displays share the MarlinUI class // All displays share the MarlinUI class
#include "marlinui.h" #include "marlinui.h"
MarlinUI ui; MarlinUI ui;
@ -1620,7 +1624,12 @@ void MarlinUI::update() {
if (status) { if (status) {
if (old_status < 2) { if (old_status < 2) {
TERN_(EXTENSIBLE_UI, ExtUI::onMediaInserted()); // ExtUI response TERN_(EXTENSIBLE_UI, ExtUI::onMediaInserted()); // ExtUI response
set_status_P(GET_TEXT(MSG_MEDIA_INSERTED)); #if ENABLED(BROWSE_MEDIA_ON_INSERT)
quick_feedback();
goto_screen(MEDIA_MENU_GATEWAY);
#else
set_status_P(GET_TEXT(MSG_MEDIA_INSERTED));
#endif
} }
} }
else { else {

1
Marlin/src/lcd/marlinui.h

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

1
Marlin/src/lcd/menu/menu_item.h

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

4
Marlin/src/lcd/menu/menu_main.cpp

@ -141,7 +141,7 @@ void menu_main() {
if (card_detected) { if (card_detected) {
if (!card_open) { if (!card_open) {
SUBMENU(MSG_MEDIA_MENU, TERN(PASSWORD_ON_SD_PRINT_MENU, password.media_gatekeeper, menu_media)); SUBMENU(MSG_MEDIA_MENU, MEDIA_MENU_GATEWAY);
#if PIN_EXISTS(SD_DETECT) #if PIN_EXISTS(SD_DETECT)
GCODES_ITEM(MSG_CHANGE_MEDIA, M21_STR); GCODES_ITEM(MSG_CHANGE_MEDIA, M21_STR);
#else #else
@ -248,7 +248,7 @@ void menu_main() {
#else #else
GCODES_ITEM(MSG_RELEASE_MEDIA, PSTR("M22")); GCODES_ITEM(MSG_RELEASE_MEDIA, PSTR("M22"));
#endif #endif
SUBMENU(MSG_MEDIA_MENU, TERN(PASSWORD_ON_SD_PRINT_MENU, password.media_gatekeeper, menu_media)); SUBMENU(MSG_MEDIA_MENU, MEDIA_MENU_GATEWAY);
} }
} }
else { else {

4
Marlin/src/lcd/menu/menu_media.cpp

@ -104,6 +104,8 @@ class MenuItem_sdfolder : public MenuItem_sdbase {
} }
}; };
extern uint8_t screen_history_depth;
void menu_media() { void menu_media() {
ui.encoder_direction_menus(); ui.encoder_direction_menus();
@ -115,7 +117,7 @@ void menu_media() {
#endif #endif
START_MENU(); START_MENU();
BACK_ITEM(MSG_MAIN); BACK_ITEM_P(TERN1(BROWSE_MEDIA_ON_INSERT, screen_history_depth) ? GET_TEXT(MSG_MAIN) : GET_TEXT(MSG_BACK));
if (card.flag.workDirIsRoot) { if (card.flag.workDirIsRoot) {
#if !PIN_EXISTS(SD_DETECT) #if !PIN_EXISTS(SD_DETECT)
ACTION_ITEM(MSG_REFRESH, []{ encoderTopLine = 0; card.mount(); }); ACTION_ITEM(MSG_REFRESH, []{ encoderTopLine = 0; card.mount(); });

8
Marlin/src/lcd/menu/menu_password.cpp

@ -152,19 +152,17 @@ void Password::menu_password_report() {
END_SCREEN(); END_SCREEN();
} }
void Password::set_password_done() { void Password::set_password_done(const bool with_set/*=true*/) {
is_set = true; is_set = with_set;
value = value_entry; value = value_entry;
ui.completion_feedback(true); ui.completion_feedback(true);
ui.goto_screen(menu_password_report); ui.goto_screen(menu_password_report);
} }
void Password::remove_password() { void Password::remove_password() {
is_set = false;
string[0] = '0'; string[0] = '0';
string[1] = '\0'; string[1] = '\0';
ui.completion_feedback(true); set_password_done(false);
ui.goto_screen(menu_password_report);
} }
// //

Loading…
Cancel
Save