Skip to content

Commit c2d0008

Browse files
fmunteanthinkyhead
andcommitted
✨ M820 Report temporary M810-M819 macros (#27458)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
1 parent 68ae15e commit c2d0008

File tree

4 files changed

+55
-0
lines changed

4 files changed

+55
-0
lines changed

Marlin/src/core/language.h

+1
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@
324324
#define STR_TEMPERATURE_UNITS "Temperature Units"
325325
#define STR_USER_THERMISTORS "User thermistors"
326326
#define STR_DELAYED_POWEROFF "Delayed poweroff"
327+
#define STR_STORED_MACROS "Stored macros"
327328

328329
//
329330
// General axis names
+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/**
2+
* Marlin 3D Printer Firmware
3+
* Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4+
*
5+
* Based on Sprinter and grbl.
6+
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7+
*
8+
* This program is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU General Public License as published by
10+
* the Free Software Foundation, either version 3 of the License, or
11+
* (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU General Public License
19+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
20+
*
21+
*/
22+
23+
#include "../../../inc/MarlinConfig.h"
24+
25+
#if ENABLED(GCODE_MACROS)
26+
27+
#include "../../gcode.h"
28+
#include "../../queue.h"
29+
#include "../../parser.h"
30+
31+
extern char gcode_macros[GCODE_MACROS_SLOTS][GCODE_MACROS_SLOT_SIZE + 1];
32+
33+
/**
34+
* M820: List defined M810 - M819 macros
35+
*/
36+
void GcodeSuite::M820() {
37+
SERIAL_ECHOLNPGM(STR_STORED_MACROS);
38+
bool some = false;
39+
for (uint8_t i = 0; i < GCODE_MACROS_SLOTS; ++i) {
40+
const char *cmd = gcode_macros[i];
41+
if (*cmd) {
42+
SERIAL_ECHO(F("M81"), i, C(' '));
43+
char c;
44+
while ((c = *cmd++)) SERIAL_CHAR(c == '\n' ? '|' : c);
45+
SERIAL_EOL();
46+
some = true;
47+
}
48+
}
49+
if (!some) SERIAL_ECHOLNPGM("None");
50+
}
51+
52+
#endif // GCODE_MACROS

Marlin/src/gcode/gcode.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1010,6 +1010,7 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) {
10101010
case 810: case 811: case 812: case 813: case 814:
10111011
case 815: case 816: case 817: case 818: case 819:
10121012
M810_819(); break; // M810-M819: Define/execute G-code macro
1013+
case 820: M820(); break; // M820: Report macros to serial output
10131014
#endif
10141015

10151016
#if HAS_BED_PROBE

Marlin/src/gcode/gcode.h

+1
Original file line numberDiff line numberDiff line change
@@ -1194,6 +1194,7 @@ class GcodeSuite {
11941194

11951195
#if ENABLED(GCODE_MACROS)
11961196
static void M810_819();
1197+
static void M820();
11971198
#endif
11981199

11991200
#if HAS_BED_PROBE

0 commit comments

Comments
 (0)