Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

M21 - media select and mount, multi volume cap report #23780

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1626,7 +1626,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
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/gcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions Marlin/src/gcode/host/M115.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
15 changes: 14 additions & 1 deletion Marlin/src/gcode/sd/M21_M22.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down