Skip to content

Commit 1ac6428

Browse files
ellenspthinkyhead
andauthored
🔪 Options to slim M111, remove M115 (#26603)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
1 parent 7c159a2 commit 1ac6428

File tree

9 files changed

+62
-30
lines changed

9 files changed

+62
-30
lines changed

Marlin/Configuration_adv.h

+12
Original file line numberDiff line numberDiff line change
@@ -3935,6 +3935,18 @@
39353935

39363936
//#define REPETIER_GCODE_M360 // Add commands originally from Repetier FW
39373937

3938+
/**
3939+
* Enable M111 debug flags 1=ECHO, 2=INFO, 4=ERRORS (unimplemented).
3940+
* Disable to save some flash. Some hosts (Repetier Host) may rely on this feature.
3941+
*/
3942+
#define DEBUG_FLAGS_GCODE
3943+
3944+
/**
3945+
* M115 - Report capabilites. Disable to save ~1150 bytes of flash.
3946+
* Some hosts (and serial TFT displays) rely on this feature.
3947+
*/
3948+
#define REPORT_CAPABILITIES_GCODE
3949+
39383950
/**
39393951
* Enable this option for a leaner build of Marlin that removes
39403952
* workspace offsets to slightly optimize performance.

Marlin/src/core/serial.h

+8-13
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,14 @@
3333
//
3434
enum MarlinDebugFlags : uint8_t {
3535
MARLIN_DEBUG_NONE = 0,
36-
MARLIN_DEBUG_ECHO = _BV(0), ///< Echo commands in order as they are processed
37-
MARLIN_DEBUG_INFO = _BV(1), ///< Print messages for code that has debug output
38-
MARLIN_DEBUG_ERRORS = _BV(2), ///< Not implemented
39-
MARLIN_DEBUG_DRYRUN = _BV(3), ///< Ignore temperature setting and E movement commands
40-
MARLIN_DEBUG_COMMUNICATION = _BV(4), ///< Not implemented
41-
#if ENABLED(DEBUG_LEVELING_FEATURE)
42-
MARLIN_DEBUG_LEVELING = _BV(5), ///< Print detailed output for homing and leveling
43-
MARLIN_DEBUG_MESH_ADJUST = _BV(6), ///< UBL bed leveling
44-
#else
45-
MARLIN_DEBUG_LEVELING = 0,
46-
MARLIN_DEBUG_MESH_ADJUST = 0,
47-
#endif
48-
MARLIN_DEBUG_ALL = 0xFF
36+
MARLIN_DEBUG_ECHO = TERN0(DEBUG_FLAGS_GCODE, _BV(0)), //!< Echo commands in order as they are processed
37+
MARLIN_DEBUG_INFO = TERN0(DEBUG_FLAGS_GCODE, _BV(1)), //!< Print messages for code that has debug output
38+
MARLIN_DEBUG_ERRORS = TERN0(DEBUG_FLAGS_GCODE, _BV(2)), //!< Not implemented
39+
MARLIN_DEBUG_DRYRUN = _BV(3), //!< Ignore temperature setting and E movement commands
40+
MARLIN_DEBUG_COMMUNICATION = TERN0(DEBUG_FLAGS_GCODE, _BV(4)), //!< Not implemented
41+
MARLIN_DEBUG_LEVELING = TERN0(DEBUG_LEVELING_FEATURE, _BV(5)), //!< Print detailed output for homing and leveling
42+
MARLIN_DEBUG_MESH_ADJUST = TERN0(DEBUG_LEVELING_FEATURE, _BV(6)), //!< UBL bed leveling
43+
MARLIN_DEBUG_ALL = MARLIN_DEBUG_ECHO|MARLIN_DEBUG_INFO|MARLIN_DEBUG_ERRORS|MARLIN_DEBUG_COMMUNICATION|MARLIN_DEBUG_LEVELING|MARLIN_DEBUG_MESH_ADJUST
4944
};
5045

5146
extern uint8_t marlin_debug_flags;

Marlin/src/gcode/control/M111.cpp

+19-13
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,33 @@
2020
*
2121
*/
2222

23+
#include "../../inc/MarlinConfig.h"
2324
#include "../gcode.h"
2425

2526
/**
2627
* M111: Set the debug level
2728
*/
2829
void GcodeSuite::M111() {
2930
if (parser.seenval('S')) marlin_debug_flags = parser.value_byte();
30-
31-
static PGMSTR(str_debug_1, STR_DEBUG_ECHO);
32-
static PGMSTR(str_debug_2, STR_DEBUG_INFO);
33-
static PGMSTR(str_debug_4, STR_DEBUG_ERRORS);
31+
#if ENABLED(DEBUG_FLAGS_GCODE)
32+
static PGMSTR(str_debug_1, STR_DEBUG_ECHO);
33+
static PGMSTR(str_debug_2, STR_DEBUG_INFO);
34+
static PGMSTR(str_debug_4, STR_DEBUG_ERRORS);
35+
#endif
3436
static PGMSTR(str_debug_8, STR_DEBUG_DRYRUN);
35-
static PGMSTR(str_debug_16, STR_DEBUG_COMMUNICATION);
37+
#if ENABLED(DEBUG_FLAGS_GCODE)
38+
static PGMSTR(str_debug_16, STR_DEBUG_COMMUNICATION);
39+
#endif
3640
#if ENABLED(DEBUG_LEVELING_FEATURE)
3741
static PGMSTR(str_debug_detail, STR_DEBUG_DETAIL);
3842
#endif
3943

4044
static PGM_P const debug_strings[] PROGMEM = {
41-
str_debug_1, str_debug_2, str_debug_4, str_debug_8, str_debug_16,
45+
TERN(DEBUG_FLAGS_GCODE, str_debug_1, nullptr),
46+
TERN(DEBUG_FLAGS_GCODE, str_debug_2, nullptr),
47+
TERN(DEBUG_FLAGS_GCODE, str_debug_4, nullptr),
48+
str_debug_8,
49+
TERN(DEBUG_FLAGS_GCODE, str_debug_16, nullptr),
4250
TERN_(DEBUG_LEVELING_FEATURE, str_debug_detail)
4351
};
4452

@@ -47,31 +55,29 @@ void GcodeSuite::M111() {
4755
if (marlin_debug_flags) {
4856
uint8_t comma = 0;
4957
for (uint8_t i = 0; i < COUNT(debug_strings); ++i) {
50-
if (TEST(marlin_debug_flags, i)) {
58+
PGM_P const pstr = (PGM_P)pgm_read_ptr(&debug_strings[i]);
59+
if (pstr && TEST(marlin_debug_flags, i)) {
5160
if (comma++) SERIAL_CHAR(',');
52-
SERIAL_ECHOPGM_P((PGM_P)pgm_read_ptr(&debug_strings[i]));
61+
SERIAL_ECHOPGM_P(pstr);
5362
}
5463
}
5564
}
5665
else {
5766
SERIAL_ECHOPGM(STR_DEBUG_OFF);
58-
#if !defined(__AVR__) || !defined(USBCON)
67+
#if !(defined(__AVR__) && defined(USBCON))
5968
#if ENABLED(SERIAL_STATS_RX_BUFFER_OVERRUNS)
6069
SERIAL_ECHOPGM("\nBuffer Overruns: ", MYSERIAL1.buffer_overruns());
6170
#endif
62-
6371
#if ENABLED(SERIAL_STATS_RX_FRAMING_ERRORS)
6472
SERIAL_ECHOPGM("\nFraming Errors: ", MYSERIAL1.framing_errors());
6573
#endif
66-
6774
#if ENABLED(SERIAL_STATS_DROPPED_RX)
6875
SERIAL_ECHOPGM("\nDropped bytes: ", MYSERIAL1.dropped());
6976
#endif
70-
7177
#if ENABLED(SERIAL_STATS_MAX_RX_QUEUED)
7278
SERIAL_ECHOPGM("\nMax RX Queue Size: ", MYSERIAL1.rxMaxEnqueued());
7379
#endif
74-
#endif // !__AVR__ || !USBCON
80+
#endif // !(__AVR__ && USBCON)
7581
}
7682
SERIAL_EOL();
7783
}

Marlin/src/gcode/gcode.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,10 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) {
669669

670670
case 92: M92(); break; // M92: Set the steps-per-unit for one or more axes
671671
case 114: M114(); break; // M114: Report current position
672-
case 115: M115(); break; // M115: Report capabilities
672+
673+
#if ENABLED(REPORT_CAPABILITIES_GCODE)
674+
case 115: M115(); break; // M115: Report capabilities
675+
#endif
673676

674677
case 117: TERN_(HAS_STATUS_MESSAGE, M117()); break; // M117: Set LCD message text, if possible
675678

Marlin/src/gcode/gcode.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,10 @@ class GcodeSuite {
760760
#endif
761761

762762
static void M114();
763-
static void M115();
763+
764+
#if ENABLED(REPORT_CAPABILITIES_GCODE)
765+
static void M115();
766+
#endif
764767

765768
#if HAS_STATUS_MESSAGE
766769
static void M117();

Marlin/src/gcode/host/M115.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@
2020
*
2121
*/
2222

23-
#include "../gcode.h"
2423
#include "../../inc/MarlinConfig.h"
24+
25+
#if ENABLED(REPORT_CAPABILITIES_GCODE)
26+
27+
#include "../gcode.h"
2528
#include "../queue.h" // for getting the command port
2629

2730
#if ENABLED(M115_GEOMETRY_REPORT)
@@ -271,3 +274,5 @@ void GcodeSuite::M115() {
271274

272275
#endif // EXTENDED_CAPABILITIES_REPORT
273276
}
277+
278+
#endif // REPORT_CAPABILITIES_GCODE

Marlin/src/inc/Warnings.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@
4242
#endif
4343
#endif
4444

45+
#if DISABLED(DEBUG_FLAGS_GCODE)
46+
#warning "DEBUG_FLAGS_GCODE is recommended if you have space. Some hosts rely on it."
47+
#endif
48+
49+
#if DISABLED(REPORT_CAPABILITIES_GCODE)
50+
#warning "REPORT_CAPABILITIES_GCODE is recommended if you have space. Some hosts rely on it."
51+
#endif
52+
4553
#if ENABLED(LA_DEBUG)
4654
#warning "WARNING! Disable LA_DEBUG for the final build!"
4755
#endif

ini/features.ini

+1
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ CNC_COORDINATE_SYSTEMS = build_src_filter=+<src/gcode/geometry/G
322322
HAS_HOME_OFFSET = build_src_filter=+<src/gcode/geometry/M206_M428.cpp>
323323
EXPECTED_PRINTER_CHECK = build_src_filter=+<src/gcode/host/M16.cpp>
324324
HOST_KEEPALIVE_FEATURE = build_src_filter=+<src/gcode/host/M113.cpp>
325+
REPORT_CAPABILITIES_GCODE = build_src_filter=+<src/gcode/host/M115.cpp>
325326
AUTO_REPORT_POSITION = build_src_filter=+<src/gcode/host/M154.cpp>
326327
REPETIER_GCODE_M360 = build_src_filter=+<src/gcode/host/M360.cpp>
327328
HAS_GCODE_M876 = build_src_filter=+<src/gcode/host/M876.cpp>

platformio.ini

-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ default_src_filter = +<src/*> -<src/config> -<src/tests>
111111
+<src/gcode/geometry/G92.cpp>
112112
+<src/gcode/host/M110.cpp>
113113
+<src/gcode/host/M114.cpp>
114-
+<src/gcode/host/M115.cpp>
115114
+<src/gcode/host/M118.cpp>
116115
+<src/gcode/host/M119.cpp>
117116
+<src/gcode/motion/G0_G1.cpp>

0 commit comments

Comments
 (0)