M21 P / S / U - Select Volume (#23780)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
kisslorand 2022-02-28 04:38:11 +02:00 committed by GitHub
parent 4b0e84d9f3
commit 9ea6a588c3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 3 deletions

View file

@ -1631,7 +1631,10 @@
// Enable if SD detect is rendered useless (e.g., by using an SD extender) // Enable if SD detect is rendered useless (e.g., by using an SD extender)
//#define NO_SD_DETECT //#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 //#define MULTI_VOLUME
#if ENABLED(MULTI_VOLUME) #if ENABLED(MULTI_VOLUME)
#define VOLUME_SD_ONBOARD #define VOLUME_SD_ONBOARD

View file

@ -91,7 +91,7 @@
* *
*** Print from Media (SDSUPPORT) *** *** Print from Media (SDSUPPORT) ***
* M20 - List SD card. (Requires 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) * M22 - Release SD card. (Requires SDSUPPORT)
* M23 - Select SD file: "M23 /path/file.gco". (Requires SDSUPPORT) * M23 - Select SD file: "M23 /path/file.gco". (Requires SDSUPPORT)
* M24 - Start/resume SD print. (Requires SDSUPPORT) * M24 - Start/resume SD print. (Requires SDSUPPORT)

View file

@ -142,6 +142,11 @@ void GcodeSuite::M115() {
// SDCARD (M20, M23, M24, etc.) // SDCARD (M20, M23, M24, etc.)
cap_line(F("SDCARD"), ENABLED(SDSUPPORT)); 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) // REPEAT (M808)
cap_line(F("REPEAT"), ENABLED(GCODE_REPEAT_MARKERS)); cap_line(F("REPEAT"), ENABLED(GCODE_REPEAT_MARKERS));

View file

@ -29,8 +29,21 @@
/** /**
* M21: Init SD Card * 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 * M22: Release SD Card