🚸 Fix SD nav after "one click print" (2)

This commit is contained in:
Scott Lahteine
2024-05-26 11:57:42 -05:00
parent 2e97ad1f4b
commit 2064c83c66
6 changed files with 49 additions and 6 deletions

View File

@@ -1105,6 +1105,10 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) {
case 1002: M1002(); break; // M1002: [INTERNAL] Tool-change and Relative E Move
#endif
#if ENABLED(ONE_CLICK_PRINT)
case 1003: M1003(); break; // M1003: [INTERNAL] Set the current dir to /
#endif
#if ENABLED(UBL_MESH_WIZARD)
case 1004: M1004(); break; // M1004: UBL Mesh Wizard
#endif

View File

@@ -1276,6 +1276,10 @@ private:
static void M1002();
#endif
#if ENABLED(ONE_CLICK_PRINT)
static void M1003();
#endif
#if ENABLED(UBL_MESH_WIZARD)
static void M1004();
#endif

View File

@@ -0,0 +1,36 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2024 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#include "../../inc/MarlinConfig.h"
#if ENABLED(ONE_CLICK_PRINT)
#include "../gcode.h"
#include "../../sd/cardreader.h"
/**
* M1003: Set the current dir to /. Should come after 'M24'.
* Prevents the SD menu getting stuck in the newest file's workDir.
*/
void GcodeSuite::M1003() { card.cdroot(); }
#endif // ONE_CLICK_PRINT

View File

@@ -25,11 +25,12 @@
#if ENABLED(ONE_CLICK_PRINT)
#include "menu.h"
#include "../../gcode/queue.h"
static void one_click_print_done() {
card.cdroot(); // Make sure SD card browsing doesn't break!
ui.return_to_status();
ui.reset_status();
queue.enqueue_one_now(F("M1003")); // Make sure SD card browsing doesn't break!
}
void one_click_print() {
@@ -41,9 +42,7 @@ void one_click_print() {
card.openAndPrintFile(card.filename);
one_click_print_done();
},
[]{
one_click_print_done();
},
one_click_print_done,
GET_TEXT_F(MSG_START_PRINT), filename, F("?")
);
});