Open File Browser on Media Insert (option) (#20151)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
parent
5768ee0f9e
commit
ecd8227de0
|
@ -1193,6 +1193,8 @@
|
|||
|
||||
//#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")
|
||||
|
||||
#if ENABLED(PRINTER_EVENT_LEDS)
|
||||
|
|
|
@ -47,7 +47,7 @@ public:
|
|||
static void start_over();
|
||||
|
||||
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 remove_password();
|
||||
|
|
|
@ -769,12 +769,8 @@ private:
|
|||
|
||||
#if ENABLED(PASSWORD_FEATURE)
|
||||
static void M510();
|
||||
#if ENABLED(PASSWORD_UNLOCK_GCODE)
|
||||
static void M511();
|
||||
#endif
|
||||
#if ENABLED(PASSWORD_CHANGE_GCODE)
|
||||
static void M512();
|
||||
#endif
|
||||
TERN_(PASSWORD_UNLOCK_GCODE, static void M511());
|
||||
TERN_(PASSWORD_CHANGE_GCODE, static void M512());
|
||||
#endif
|
||||
|
||||
TERN_(SDSUPPORT, static void M524());
|
||||
|
|
|
@ -30,6 +30,10 @@
|
|||
#include "../feature/host_actions.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(BROWSE_MEDIA_ON_INSERT, PASSWORD_ON_SD_PRINT_MENU)
|
||||
#include "../feature/password/password.h"
|
||||
#endif
|
||||
|
||||
// All displays share the MarlinUI class
|
||||
#include "marlinui.h"
|
||||
MarlinUI ui;
|
||||
|
@ -1620,7 +1624,12 @@ void MarlinUI::update() {
|
|||
if (status) {
|
||||
if (old_status < 2) {
|
||||
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 {
|
||||
|
|
|
@ -322,6 +322,7 @@ public:
|
|||
#endif
|
||||
|
||||
#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);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -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(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 ACTION_ITEM_N_S_P(N, S, PLABEL, ACTION) MENU_ITEM_N_S_P(function, N, S, PLABEL, ACTION)
|
||||
|
|
|
@ -141,7 +141,7 @@ void menu_main() {
|
|||
|
||||
if (card_detected) {
|
||||
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)
|
||||
GCODES_ITEM(MSG_CHANGE_MEDIA, M21_STR);
|
||||
#else
|
||||
|
@ -248,7 +248,7 @@ void menu_main() {
|
|||
#else
|
||||
GCODES_ITEM(MSG_RELEASE_MEDIA, PSTR("M22"));
|
||||
#endif
|
||||
SUBMENU(MSG_MEDIA_MENU, TERN(PASSWORD_ON_SD_PRINT_MENU, password.media_gatekeeper, menu_media));
|
||||
SUBMENU(MSG_MEDIA_MENU, MEDIA_MENU_GATEWAY);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -104,6 +104,8 @@ class MenuItem_sdfolder : public MenuItem_sdbase {
|
|||
}
|
||||
};
|
||||
|
||||
extern uint8_t screen_history_depth;
|
||||
|
||||
void menu_media() {
|
||||
ui.encoder_direction_menus();
|
||||
|
||||
|
@ -115,7 +117,7 @@ void menu_media() {
|
|||
#endif
|
||||
|
||||
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 !PIN_EXISTS(SD_DETECT)
|
||||
ACTION_ITEM(MSG_REFRESH, []{ encoderTopLine = 0; card.mount(); });
|
||||
|
|
|
@ -152,19 +152,17 @@ void Password::menu_password_report() {
|
|||
END_SCREEN();
|
||||
}
|
||||
|
||||
void Password::set_password_done() {
|
||||
is_set = true;
|
||||
void Password::set_password_done(const bool with_set/*=true*/) {
|
||||
is_set = with_set;
|
||||
value = value_entry;
|
||||
ui.completion_feedback(true);
|
||||
ui.goto_screen(menu_password_report);
|
||||
}
|
||||
|
||||
void Password::remove_password() {
|
||||
is_set = false;
|
||||
string[0] = '0';
|
||||
string[1] = '\0';
|
||||
ui.completion_feedback(true);
|
||||
ui.goto_screen(menu_password_report);
|
||||
set_password_done(false);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue