M808 Repeat Markers (#20084)
This commit is contained in:
@ -882,6 +882,10 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) {
|
||||
case 800: parser.debug(); break; // M800: GCode Parser Test for M
|
||||
#endif
|
||||
|
||||
#if ENABLED(GCODE_REPEAT_MARKERS)
|
||||
case 808: M808(); break; // M808: Set / Goto repeat markers
|
||||
#endif
|
||||
|
||||
#if ENABLED(I2C_POSITION_ENCODERS)
|
||||
case 860: M860(); break; // M860: Report encoder module position
|
||||
case 861: M861(); break; // M861: Report encoder module status
|
||||
|
@ -242,6 +242,7 @@
|
||||
* M672 - Set/Reset Duet Smart Effector's sensitivity. (Requires DUET_SMART_EFFECTOR and SMART_EFFECTOR_MOD_PIN)
|
||||
* M701 - Load filament (Requires FILAMENT_LOAD_UNLOAD_GCODES)
|
||||
* M702 - Unload filament (Requires FILAMENT_LOAD_UNLOAD_GCODES)
|
||||
* M808 - Set or Goto a Repeat Marker (Requires GCODE_REPEAT_MARKERS)
|
||||
* M810-M819 - Define/execute a G-code macro (Requires GCODE_MACROS)
|
||||
* M851 - Set Z probe's XYZ offsets in current units. (Negative values: X=left, Y=front, Z=below)
|
||||
* M852 - Set skew factors: "M852 [I<xy>] [J<xz>] [K<yz>]". (Requires SKEW_CORRECTION_GCODE, and SKEW_CORRECTION_FOR_Z for IJ)
|
||||
@ -807,6 +808,8 @@ private:
|
||||
static void M702();
|
||||
#endif
|
||||
|
||||
TERN_(GCODE_REPEAT_MARKERS, static void M808());
|
||||
|
||||
TERN_(GCODE_MACROS, static void M810_819());
|
||||
|
||||
TERN_(HAS_BED_PROBE, static void M851());
|
||||
|
@ -117,6 +117,9 @@ void GcodeSuite::M115() {
|
||||
// SDCARD (M20, M23, M24, etc.)
|
||||
cap_line(PSTR("SDCARD"), ENABLED(SDSUPPORT));
|
||||
|
||||
// REPEAT (M808)
|
||||
cap_line(PSTR("REPEAT"), ENABLED(GCODE_REPEAT_MARKERS));
|
||||
|
||||
// AUTOREPORT_SD_STATUS (M27 extension)
|
||||
cap_line(PSTR("AUTOREPORT_SD_STATUS"), ENABLED(AUTO_REPORT_SD_STATUS));
|
||||
|
||||
|
@ -51,6 +51,10 @@ GCodeQueue queue;
|
||||
#include "../feature/powerloss.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(GCODE_REPEAT_MARKERS)
|
||||
#include "../feature/repeat.h"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* GCode line number handling. Hosts may opt to include line numbers when
|
||||
* sending commands to Marlin, and lines will be checked for sequentiality.
|
||||
@ -577,10 +581,9 @@ void GCodeQueue::get_serial_commands() {
|
||||
if (!IS_SD_PRINTING()) return;
|
||||
|
||||
int sd_count = 0;
|
||||
bool card_eof = card.eof();
|
||||
while (length < BUFSIZE && !card_eof) {
|
||||
while (length < BUFSIZE && !card.eof()) {
|
||||
const int16_t n = card.get();
|
||||
card_eof = card.eof();
|
||||
const bool card_eof = card.eof();
|
||||
if (n < 0 && !card_eof) { SERIAL_ERROR_MSG(STR_SD_ERR_READ); continue; }
|
||||
|
||||
const char sd_char = (char)n;
|
||||
@ -590,17 +593,21 @@ void GCodeQueue::get_serial_commands() {
|
||||
// Reset stream state, terminate the buffer, and commit a non-empty command
|
||||
if (!is_eol && sd_count) ++sd_count; // End of file with no newline
|
||||
if (!process_line_done(sd_input_state, command_buffer[index_w], sd_count)) {
|
||||
|
||||
// M808 S saves the sdpos of the next line. M808 loops to a new sdpos.
|
||||
TERN_(GCODE_REPEAT_MARKERS, repeat.early_parse_M808(command_buffer[index_w]));
|
||||
|
||||
// Put the new command into the buffer (no "ok" sent)
|
||||
_commit_command(false);
|
||||
#if ENABLED(POWER_LOSS_RECOVERY)
|
||||
recovery.cmd_sdpos = card.getIndex(); // Prime for the NEXT _commit_command
|
||||
#endif
|
||||
|
||||
// Prime Power-Loss Recovery for the NEXT _commit_command
|
||||
TERN_(POWER_LOSS_RECOVERY, recovery.cmd_sdpos = card.getIndex());
|
||||
}
|
||||
|
||||
if (card_eof) card.fileHasFinished(); // Handle end of file reached
|
||||
if (card.eof()) card.fileHasFinished(); // Handle end of file reached
|
||||
}
|
||||
else
|
||||
process_stream_char(sd_char, sd_input_state, command_buffer[index_w], sd_count);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
51
Marlin/src/gcode/sd/M808.cpp
Normal file
51
Marlin/src/gcode/sd/M808.cpp
Normal file
@ -0,0 +1,51 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2020 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 <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(GCODE_REPEAT_MARKERS)
|
||||
|
||||
#include "../gcode.h"
|
||||
#include "../../feature/repeat.h"
|
||||
|
||||
/**
|
||||
* M808: Set / Goto a repeat marker
|
||||
*
|
||||
* L<count> - Set a repeat marker with 'count' repetitions. If omitted, infinity.
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* M808 L ; Set a loop marker with a count of infinity
|
||||
* M808 L2 ; Set a loop marker with a count of 2
|
||||
* M808 ; Decrement and loop if not zero.
|
||||
*/
|
||||
void GcodeSuite::M808() {
|
||||
|
||||
// Handled early and ignored here in the queue.
|
||||
// Allowed to go into the queue for logging purposes.
|
||||
|
||||
// M808 K sent from the host to cancel all loops
|
||||
if (parser.seen('K')) repeat.cancel();
|
||||
|
||||
}
|
||||
|
||||
#endif // GCODE_REPEAT_MARKERS
|
Reference in New Issue
Block a user