Confirm before starting SD print (#13616)
This commit is contained in:
@ -62,8 +62,7 @@ void MarlinGame::init_game(const uint8_t init_state, const screenFunc_t screen)
|
||||
}
|
||||
|
||||
void MarlinGame::exit_game() {
|
||||
ui.goto_previous_screen();
|
||||
ui.defer_status_screen(false);
|
||||
ui.goto_previous_screen_no_defer();
|
||||
}
|
||||
|
||||
#endif // HAS_GAMES
|
||||
|
@ -436,4 +436,12 @@ void _lcd_draw_homing() {
|
||||
void _lcd_toggle_bed_leveling() { set_bed_leveling_enabled(!planner.leveling_active); }
|
||||
#endif
|
||||
|
||||
void do_select_screen(PGM_P const yes, PGM_P const no, bool &yesno, PGM_P const pref, const char * const string, PGM_P const suff) {
|
||||
if (ui.encoderPosition) {
|
||||
yesno = int32_t(ui.encoderPosition) > 0;
|
||||
ui.encoderPosition = 0;
|
||||
}
|
||||
draw_select_screen(yes, no, yesno, pref, string, suff);
|
||||
}
|
||||
|
||||
#endif // HAS_LCD_MENU
|
||||
|
@ -64,6 +64,11 @@ DECLARE_MENU_EDIT_TYPE(uint32_t, long5, ftostr5rj, 0.01f ); // 123
|
||||
////////////////////////////////////////////
|
||||
|
||||
void draw_edit_screen(PGM_P const pstr, const char* const value=NULL);
|
||||
void draw_select_screen(PGM_P const yes, PGM_P const no, const bool yesno, PGM_P const pref, const char * const string, PGM_P const suff);
|
||||
void do_select_screen(PGM_P const yes, PGM_P const no, bool &yesno, PGM_P const pref, const char * const string=NULL, PGM_P const suff=NULL);
|
||||
inline void do_select_screen_yn(bool &yesno, PGM_P const pref, const char * const string, PGM_P const suff) {
|
||||
do_select_screen(PSTR(MSG_YES), PSTR(MSG_NO), yesno, pref, string, suff);
|
||||
}
|
||||
void draw_menu_item(const bool sel, const uint8_t row, PGM_P const pstr, const char pre_char, const char post_char);
|
||||
void draw_menu_item_static(const uint8_t row, PGM_P const pstr, const bool center=true, const bool invert=false, const char *valstr=NULL);
|
||||
void _draw_menu_item_edit(const bool sel, const uint8_t row, PGM_P const pstr, const char* const data, const bool pgm);
|
||||
|
@ -72,15 +72,41 @@ void lcd_sd_updir() {
|
||||
}
|
||||
#endif
|
||||
|
||||
inline void sdcard_start_selected_file() {
|
||||
card.openAndPrintFile(card.filename);
|
||||
ui.return_to_status();
|
||||
ui.reset_status();
|
||||
}
|
||||
|
||||
#if ENABLED(SD_MENU_CONFIRM_START)
|
||||
|
||||
bool do_print_file;
|
||||
void menu_sd_confirm() {
|
||||
if (ui.should_draw())
|
||||
do_select_screen(PSTR(MSG_BUTTON_PRINT), PSTR(MSG_BUTTON_CANCEL), do_print_file, PSTR(MSG_START_PRINT " "), card.longest_filename(), PSTR("?"));
|
||||
|
||||
if (ui.use_click()) {
|
||||
if (do_print_file)
|
||||
sdcard_start_selected_file();
|
||||
else
|
||||
ui.goto_previous_screen();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
class MenuItem_sdfile {
|
||||
public:
|
||||
static void action(CardReader &theCard) {
|
||||
#if ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
|
||||
last_sdfile_encoderPosition = ui.encoderPosition; // Save which file was selected for later use
|
||||
#endif
|
||||
card.openAndPrintFile(theCard.filename);
|
||||
ui.return_to_status();
|
||||
ui.reset_status();
|
||||
#if ENABLED(SD_MENU_CONFIRM_START)
|
||||
do_print_file = false;
|
||||
MenuItem_submenu::action(menu_sd_confirm);
|
||||
#else
|
||||
sdcard_start_selected_file();
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user