Move SD commands to cpp

This commit is contained in:
Scott Lahteine 2017-09-16 03:24:47 -05:00
parent be0e4a4ad0
commit a442c34a1a
16 changed files with 163 additions and 85 deletions

View File

@ -360,33 +360,8 @@ void suicide() {
***************** GCode Handlers *****************
**************************************************/
#if ENABLED(SDSUPPORT)
#include "gcode/sdcard/M20.h" // M20 - List SD card. (Requires SDSUPPORT)
#include "gcode/sdcard/M21.h" // M21 - Init SD card. (Requires SDSUPPORT)
#include "gcode/sdcard/M22.h" // M22 - Release SD card. (Requires SDSUPPORT)
#include "gcode/sdcard/M23.h" // M23 - Select SD file: "M23 /path/file.gco". (Requires SDSUPPORT)
#include "gcode/sdcard/M24.h" // M24 - Start/resume SD print. (Requires SDSUPPORT)
#include "gcode/sdcard/M25.h" // M25 - Pause SD print. (Requires SDSUPPORT)
#include "gcode/sdcard/M26.h" // M26 - Set SD position in bytes: "M26 S12345". (Requires SDSUPPORT)
#include "gcode/sdcard/M27.h" // M27 - Report SD print status. (Requires SDSUPPORT)
#include "gcode/sdcard/M28.h" // M28 - Start SD write: "M28 /path/file.gco". (Requires SDSUPPORT)
#include "gcode/sdcard/M29.h" // M29 - Stop SD write. (Requires SDSUPPORT)
#include "gcode/sdcard/M30.h" // M30 - Delete file from SD: "M30 /path/file.gco"
#endif
#include "gcode/stats/M31.h" // M31: Get the time since the start of SD Print (or last M109)
#if ENABLED(SDSUPPORT)
#include "gcode/sdcard/M32.h"
#if ENABLED(LONG_FILENAME_HOST_SUPPORT)
#include "gcode/sdcard/M33.h"
#endif
#if ENABLED(SDCARD_SORT_ALPHA) && ENABLED(SDSORT_GCODE)
#include "gcode/sdcard/M34.h"
#endif
#include "gcode/sdcard/M928.h"
#endif
/**
* Sensitive pin test for M42, M226
*/

View File

@ -117,20 +117,7 @@ void GcodeSuite::dwell(millis_t time) {
// Placeholders for non-migrated codes
//
extern void gcode_M18_M84();
extern void gcode_M20();
extern void gcode_M21();
extern void gcode_M22();
extern void gcode_M23();
extern void gcode_M25();
extern void gcode_M26();
extern void gcode_M27();
extern void gcode_M28();
extern void gcode_M29();
extern void gcode_M30();
extern void gcode_M31();
extern void gcode_M32();
extern void gcode_M33();
extern void gcode_M34();
extern void gcode_M42();
extern void gcode_M43();
extern void gcode_M48();
@ -160,7 +147,6 @@ extern void gcode_M118();
extern void gcode_M119();
extern void gcode_M120();
extern void gcode_M121();
extern void gcode_M125();
extern void gcode_M126();
extern void gcode_M127();
extern void gcode_M128();
@ -225,7 +211,6 @@ extern void gcode_M907();
extern void gcode_M908();
extern void gcode_M909();
extern void gcode_M910();
extern void gcode_M928();
extern void gcode_M999();
extern void gcode_T(uint8_t tmp_extruder);
@ -423,43 +408,28 @@ void GcodeSuite::process_next_command() {
break;
#if ENABLED(SDSUPPORT)
case 20: // M20: list SD card
gcode_M20(); break;
case 21: // M21: init SD card
gcode_M21(); break;
case 22: // M22: release SD card
gcode_M22(); break;
case 23: // M23: Select file
gcode_M23(); break;
case 24: // M24: Start SD print
M24(); break;
case 25: // M25: Pause SD print
gcode_M25(); break;
case 26: // M26: Set SD index
gcode_M26(); break;
case 27: // M27: Get SD status
gcode_M27(); break;
case 28: // M28: Start SD write
gcode_M28(); break;
case 29: // M29: Stop SD write
gcode_M29(); break;
case 30: // M30 <filename> Delete File
gcode_M30(); break;
case 32: // M32: Select file and start SD print
gcode_M32(); break;
case 20: M20(); break; // M20: list SD card
case 21: M21(); break; // M21: init SD card
case 22: M22(); break; // M22: release SD card
case 23: M23(); break; // M23: Select file
case 24: M24(); break; // M24: Start SD print
case 25: M25(); break; // M25: Pause SD print
case 26: M26(); break; // M26: Set SD index
case 27: M27(); break; // M27: Get SD status
case 28: M28(); break; // M28: Start SD write
case 29: M29(); break; // M29: Stop SD write
case 30: M30(); break; // M30 <filename> Delete File
case 32: M32(); break; // M32: Select file and start SD print
#if ENABLED(LONG_FILENAME_HOST_SUPPORT)
case 33: // M33: Get the long full path to a file or folder
gcode_M33(); break;
case 33: M33(); break; // M33: Get the long full path to a file or folder
#endif
#if ENABLED(SDCARD_SORT_ALPHA) && ENABLED(SDSORT_GCODE)
case 34: // M34: Set SD card sorting options
gcode_M34(); break;
#endif // SDCARD_SORT_ALPHA && SDSORT_GCODE
case 34: M34(); break; // M34: Set SD card sorting options
#endif
case 928: // M928: Start SD write
gcode_M928(); break;
case 928: M928(); break; // M928: Start SD write
#endif // SDSUPPORT
case 31: // M31: Report time since the start of SD print or last M109

View File

@ -20,11 +20,20 @@
*
*/
#include "../../inc/MarlinConfig.h"
#if ENABLED(SDSUPPORT)
#include "../gcode.h"
#include "../../sd/cardreader.h"
/**
* M20: List SD card to serial output
*/
void gcode_M20() {
void GcodeSuite::M20() {
SERIAL_PROTOCOLLNPGM(MSG_BEGIN_FILE_LIST);
card.ls();
SERIAL_PROTOCOLLNPGM(MSG_END_FILE_LIST);
}
#endif // SDSUPPORT

View File

@ -20,7 +20,16 @@
*
*/
#include "../../inc/MarlinConfig.h"
#if ENABLED(SDSUPPORT)
#include "../gcode.h"
#include "../../sd/cardreader.h"
/**
* M21: Init SD Card
*/
void gcode_M21() { card.initsd(); }
void GcodeSuite::M21() { card.initsd(); }
#endif // SDSUPPORT

View File

@ -20,7 +20,16 @@
*
*/
#include "../../inc/MarlinConfig.h"
#if ENABLED(SDSUPPORT)
#include "../gcode.h"
#include "../../sd/cardreader.h"
/**
* M22: Release SD Card
*/
void gcode_M22() { card.release(); }
void GcodeSuite::M22() { card.release(); }
#endif // SDSUPPORT

View File

@ -20,11 +20,20 @@
*
*/
#include "../../inc/MarlinConfig.h"
#if ENABLED(SDSUPPORT)
#include "../gcode.h"
#include "../../sd/cardreader.h"
/**
* M23: Open a file
*/
void gcode_M23() {
void GcodeSuite::M23() {
// Simplify3D includes the size, so zero out all spaces (#7227)
for (char *fn = parser.string_arg; *fn; ++fn) if (*fn == ' ') *fn = '\0';
card.openFile(parser.string_arg, true);
}
#endif // SDSUPPORT

View File

@ -20,10 +20,22 @@
*
*/
#include "../../inc/MarlinConfig.h"
#if ENABLED(SDSUPPORT)
#include "../gcode.h"
#include "../../sd/cardreader.h"
#include "../../module/printcounter.h"
#if ENABLED(PARK_HEAD_ON_PAUSE)
#include "../queue.h"
#endif
/**
* M25: Pause SD Print
*/
void gcode_M25() {
void GcodeSuite::M25() {
card.pauseSDPrint();
print_job_timer.pause();
@ -31,3 +43,5 @@ void gcode_M25() {
enqueue_and_echo_commands_P(PSTR("M125")); // Must be enqueued with pauseSDPrint set to be last in the buffer
#endif
}
#endif // SDSUPPORT

View File

@ -20,10 +20,19 @@
*
*/
#include "../../inc/MarlinConfig.h"
#if ENABLED(SDSUPPORT)
#include "../gcode.h"
#include "../../sd/cardreader.h"
/**
* M26: Set SD Card file index
*/
void gcode_M26() {
void GcodeSuite::M26() {
if (card.cardOK && parser.seenval('S'))
card.setIndex(parser.value_long());
}
#endif // SDSUPPORT

View File

@ -20,7 +20,16 @@
*
*/
#include "../../inc/MarlinConfig.h"
#if ENABLED(SDSUPPORT)
#include "../gcode.h"
#include "../../sd/cardreader.h"
/**
* M27: Get SD Card status
*/
void gcode_M27() { card.getStatus(); }
void GcodeSuite::M27() { card.getStatus(); }
#endif // SDSUPPORT

View File

@ -20,7 +20,16 @@
*
*/
#include "../../inc/MarlinConfig.h"
#if ENABLED(SDSUPPORT)
#include "../gcode.h"
#include "../../sd/cardreader.h"
/**
* M28: Start SD Write
*/
void gcode_M28() { card.openFile(parser.string_arg, false); }
void GcodeSuite::M28() { card.openFile(parser.string_arg, false); }
#endif // SDSUPPORT

View File

@ -20,10 +20,19 @@
*
*/
#include "../../inc/MarlinConfig.h"
#if ENABLED(SDSUPPORT)
#include "../gcode.h"
#include "../../sd/cardreader.h"
/**
* M29: Stop SD Write
* Processed in write to file routine above
*/
void gcode_M29() {
void GcodeSuite::M29() {
// card.saving = false;
}
#endif // SDSUPPORT

View File

@ -20,12 +20,21 @@
*
*/
#include "../../inc/MarlinConfig.h"
#if ENABLED(SDSUPPORT)
#include "../gcode.h"
#include "../../sd/cardreader.h"
/**
* M30 <filename>: Delete SD Card file
*/
void gcode_M30() {
void GcodeSuite::M30() {
if (card.cardOK) {
card.closefile();
card.removeFile(parser.string_arg);
}
}
#endif // SDSUPPORT

View File

@ -20,10 +20,19 @@
*
*/
#include "../../inc/MarlinConfig.h"
#if ENABLED(SDSUPPORT)
#include "../gcode.h"
#include "../../sd/cardreader.h"
#include "../../module/stepper.h"
#include "../../module/printcounter.h"
/**
* M32: Select file and start SD Print
*/
void gcode_M32() {
void GcodeSuite::M32() {
if (IS_SD_PRINTING)
stepper.synchronize();
@ -42,3 +51,5 @@ void gcode_M32() {
if (!call_procedure) print_job_timer.start();
}
}
#endif // SDSUPPORT

View File

@ -20,6 +20,13 @@
*
*/
#include "../../inc/MarlinConfig.h"
#if ENABLED(SDSUPPORT) && ENABLED(LONG_FILENAME_HOST_SUPPORT)
#include "../gcode.h"
#include "../../sd/cardreader.h"
/**
* M33: Get the long full path of a file or folder
*
@ -32,6 +39,8 @@
* Output:
* /Miscellaneous/Armchair/Armchair.gcode
*/
void gcode_M33() {
void GcodeSuite::M33() {
card.printLongPath(parser.string_arg);
}
#endif // SDSUPPORT && LONG_FILENAME_HOST_SUPPORT

View File

@ -20,10 +20,17 @@
*
*/
#include "../../inc/MarlinConfig.h"
#if ENABLED(SDSUPPORT) && ENABLED(SDCARD_SORT_ALPHA) && ENABLED(SDSORT_GCODE)
#include "../gcode.h"
#include "../../sd/cardreader.h"
/**
* M34: Set SD Card Sorting Options
*/
void gcode_M34() {
void GcodeSuite::M34() {
if (parser.seen('S')) card.setSortOn(parser.value_bool());
if (parser.seenval('F')) {
const int v = parser.value_long();
@ -31,3 +38,5 @@ void gcode_M34() {
}
//if (parser.seen('R')) card.setSortReverse(parser.value_bool());
}
#endif // SDSUPPORT && SDCARD_SORT_ALPHA && SDSORT_GCODE

View File

@ -20,9 +20,18 @@
*
*/
#include "../../inc/MarlinConfig.h"
#if ENABLED(SDSUPPORT)
#include "../gcode.h"
#include "../../sd/cardreader.h"
/**
* M928: Start SD Write
*/
void gcode_M928() {
void GcodeSuite::M928() {
card.openLogFile(parser.string_arg);
}
#endif // SDSUPPORT