From feafb7d49af67dd11172baf883d307eaea1e1b26 Mon Sep 17 00:00:00 2001 From: kisslorand <50251547+kisslorand@users.noreply.github.com> Date: Mon, 28 Feb 2022 04:38:11 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20M21=20P=20/=20S=20/=20U=20-=20Selec?= =?UTF-8?q?t=20Volume=20(#23780)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Scott Lahteine --- Marlin/Configuration_adv.h | 5 ++++- Marlin/src/gcode/gcode.h | 2 +- Marlin/src/gcode/host/M115.cpp | 5 +++++ Marlin/src/gcode/sd/M21_M22.cpp | 15 ++++++++++++++- 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 4a9cb77b8b..e5379ed84f 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1631,7 +1631,10 @@ // Enable if SD detect is rendered useless (e.g., by using an SD extender) //#define NO_SD_DETECT - // Multiple volume support - EXPERIMENTAL. + /** + * Multiple volume support - EXPERIMENTAL. + * Adds 'M21 Pm' / 'M21 S' / 'M21 U' to mount SD Card / USB Drive. + */ //#define MULTI_VOLUME #if ENABLED(MULTI_VOLUME) #define VOLUME_SD_ONBOARD diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index 78dd0bc680..a150aca41d 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -91,7 +91,7 @@ * *** Print from Media (SDSUPPORT) *** * M20 - List SD card. (Requires SDSUPPORT) - * M21 - Init SD card. (Requires SDSUPPORT) + * M21 - Init SD card. (Requires SDSUPPORT) With MULTI_VOLUME select a drive with `M21 Pn` / 'M21 S' / 'M21 U'. * M22 - Release SD card. (Requires SDSUPPORT) * M23 - Select SD file: "M23 /path/file.gco". (Requires SDSUPPORT) * M24 - Start/resume SD print. (Requires SDSUPPORT) diff --git a/Marlin/src/gcode/host/M115.cpp b/Marlin/src/gcode/host/M115.cpp index 45e0061a5b..36731c23da 100644 --- a/Marlin/src/gcode/host/M115.cpp +++ b/Marlin/src/gcode/host/M115.cpp @@ -142,6 +142,11 @@ void GcodeSuite::M115() { // SDCARD (M20, M23, M24, etc.) cap_line(F("SDCARD"), ENABLED(SDSUPPORT)); + // MULTI_VOLUME (M21 S/M21 U) + #if ENABLED(SDSUPPORT) + cap_line(F("MULTI_VOLUME"), ENABLED(MULTI_VOLUME)); + #endif + // REPEAT (M808) cap_line(F("REPEAT"), ENABLED(GCODE_REPEAT_MARKERS)); diff --git a/Marlin/src/gcode/sd/M21_M22.cpp b/Marlin/src/gcode/sd/M21_M22.cpp index c7f41f9c81..aec0de27ca 100644 --- a/Marlin/src/gcode/sd/M21_M22.cpp +++ b/Marlin/src/gcode/sd/M21_M22.cpp @@ -29,8 +29,21 @@ /** * M21: Init SD Card + * + * With MULTI_VOLUME: + * P0 or S - Change to the SD Card and mount it + * P1 or U - Change to the USB Drive and mount it */ -void GcodeSuite::M21() { card.mount(); } +void GcodeSuite::M21() { + #if ENABLED(MULTI_VOLUME) + const int8_t vol = parser.intval('P', -1); + if (vol == 0 || parser.seen_test('S')) // "S" for SD Card + card.changeMedia(&card.media_driver_sdcard); + else if (vol == 1 || parser.seen_test('U')) // "U" for USB + card.changeMedia(&card.media_driver_usbFlash); + #endif + card.mount(); +} /** * M22: Release SD Card