From 4f85f88ae3a8424b17b42c59f53e09647c046c0c Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 26 May 2024 02:12:22 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20Fix=20SD=20nav=20after=20"one=20?= =?UTF-8?q?click=20print"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/menu/menu_one_click_print.cpp | 14 +++++++++++--- Marlin/src/sd/cardreader.cpp | 4 ++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Marlin/src/lcd/menu/menu_one_click_print.cpp b/Marlin/src/lcd/menu/menu_one_click_print.cpp index f1ed92d0d5..e334e9e512 100644 --- a/Marlin/src/lcd/menu/menu_one_click_print.cpp +++ b/Marlin/src/lcd/menu/menu_one_click_print.cpp @@ -26,6 +26,12 @@ #include "menu.h" +static void one_click_print_done() { + card.cdroot(); // Make sure SD card browsing doesn't break! + ui.return_to_status(); + ui.reset_status(); +} + void one_click_print() { ui.goto_screen([]{ char * const filename = card.longest_filename(); @@ -33,9 +39,11 @@ void one_click_print() { GET_TEXT_F(MSG_BUTTON_PRINT), GET_TEXT_F(MSG_BUTTON_CANCEL), []{ card.openAndPrintFile(card.filename); - ui.return_to_status(); - ui.reset_status(); - }, nullptr, + one_click_print_done(); + }, + []{ + one_click_print_done(); + }, GET_TEXT_F(MSG_START_PRINT), filename, F("?") ); }); diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index 25a30585f8..1431994093 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -902,11 +902,11 @@ void CardReader::write_command(char * const buf) { * Select the newest file and ask the user if they want to print it. */ bool CardReader::one_click_check() { - const bool found = selectNewestFile(); + const bool found = selectNewestFile(); // Changes the current workDir if found if (found) { //SERIAL_ECHO_MSG(" OCP File: ", longest_filename(), "\n"); //ui.init(); - one_click_print(); + one_click_print(); // Restores workkDir to root (eventually) } return found; }