From 2064c83c6681afac7dec636ce361e91b8ecba76b Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 26 May 2024 11:57:42 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20Fix=20SD=20nav=20after=20"one=20?= =?UTF-8?q?click=20print"=20(2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/gcode/gcode.cpp | 4 +++ Marlin/src/gcode/gcode.h | 4 +++ Marlin/src/gcode/sd/M1003.cpp | 36 ++++++++++++++++++++ Marlin/src/lcd/menu/menu_one_click_print.cpp | 7 ++-- buildroot/tests/rambo | 2 +- ini/features.ini | 2 +- 6 files changed, 49 insertions(+), 6 deletions(-) create mode 100644 Marlin/src/gcode/sd/M1003.cpp diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index 1ff643dc21..9e81c7d4bc 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -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 diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index 1e3ec7c7f1..144d724cd9 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -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 diff --git a/Marlin/src/gcode/sd/M1003.cpp b/Marlin/src/gcode/sd/M1003.cpp new file mode 100644 index 0000000000..bed9d2cb10 --- /dev/null +++ b/Marlin/src/gcode/sd/M1003.cpp @@ -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 . + * + */ + +#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 diff --git a/Marlin/src/lcd/menu/menu_one_click_print.cpp b/Marlin/src/lcd/menu/menu_one_click_print.cpp index e334e9e512..c739964bce 100644 --- a/Marlin/src/lcd/menu/menu_one_click_print.cpp +++ b/Marlin/src/lcd/menu/menu_one_click_print.cpp @@ -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("?") ); }); diff --git a/buildroot/tests/rambo b/buildroot/tests/rambo index 0701a5c4c7..a7deb02c9f 100755 --- a/buildroot/tests/rambo +++ b/buildroot/tests/rambo @@ -29,7 +29,7 @@ opt_enable REPRAP_DISCOUNT_SMART_CONTROLLER LCD_PROGRESS_BAR LCD_PROGRESS_BAR_TE ADVANCED_PAUSE_FEATURE FILAMENT_LOAD_UNLOAD_GCODES FILAMENT_UNLOAD_ALL_EXTRUDERS \ PASSWORD_FEATURE PASSWORD_ON_STARTUP PASSWORD_ON_SD_PRINT_MENU PASSWORD_AFTER_SD_PRINT_END PASSWORD_AFTER_SD_PRINT_ABORT \ AUTO_BED_LEVELING_BILINEAR Z_MIN_PROBE_REPEATABILITY_TEST DISTINCT_E_FACTORS \ - SKEW_CORRECTION SKEW_CORRECTION_FOR_Z SKEW_CORRECTION_GCODE \ + SKEW_CORRECTION SKEW_CORRECTION_FOR_Z SKEW_CORRECTION_GCODE ONE_CLICK_PRINT NO_SD_AUTOSTART \ BACKLASH_COMPENSATION BACKLASH_GCODE BAUD_RATE_GCODE BEZIER_CURVE_SUPPORT \ FWRETRACT ARC_P_CIRCLES CNC_WORKSPACE_PLANES CNC_COORDINATE_SYSTEMS \ PSU_CONTROL LED_POWEROFF_TIMEOUT PS_OFF_CONFIRM PS_OFF_SOUND POWER_OFF_WAIT_FOR_COOLDOWN \ diff --git a/ini/features.ini b/ini/features.ini index cb3b96c402..b81c5285bf 100644 --- a/ini/features.ini +++ b/ini/features.ini @@ -183,7 +183,7 @@ HAS_MENU_LED = build_src_filter=+ HAS_MENU_MIXER = build_src_filter=+ HAS_MENU_MMU2 = build_src_filter=+ -HAS_MENU_ONE_CLICK_PRINT = build_src_filter=+ +HAS_MENU_ONE_CLICK_PRINT = build_src_filter=+ + HAS_MENU_PASSWORD = build_src_filter=+ HAS_MENU_POWER_MONITOR = build_src_filter=+ HAS_MENU_CUTTER = build_src_filter=+