Skip to content

Commit

Permalink
🔪 Options to slim M111, remove M115 (MarlinFirmware#26603)
Browse files Browse the repository at this point in the history
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
  • Loading branch information
ellensp and thinkyhead committed Jan 3, 2024
1 parent 7c159a2 commit 1ac6428
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 30 deletions.
12 changes: 12 additions & 0 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -3935,6 +3935,18 @@

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

/**
* Enable M111 debug flags 1=ECHO, 2=INFO, 4=ERRORS (unimplemented).
* Disable to save some flash. Some hosts (Repetier Host) may rely on this feature.
*/
#define DEBUG_FLAGS_GCODE

/**
* M115 - Report capabilites. Disable to save ~1150 bytes of flash.
* Some hosts (and serial TFT displays) rely on this feature.
*/
#define REPORT_CAPABILITIES_GCODE

/**
* Enable this option for a leaner build of Marlin that removes
* workspace offsets to slightly optimize performance.
Expand Down
21 changes: 8 additions & 13 deletions Marlin/src/core/serial.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,14 @@
//
enum MarlinDebugFlags : uint8_t {
MARLIN_DEBUG_NONE = 0,
MARLIN_DEBUG_ECHO = _BV(0), ///< Echo commands in order as they are processed
MARLIN_DEBUG_INFO = _BV(1), ///< Print messages for code that has debug output
MARLIN_DEBUG_ERRORS = _BV(2), ///< Not implemented
MARLIN_DEBUG_DRYRUN = _BV(3), ///< Ignore temperature setting and E movement commands
MARLIN_DEBUG_COMMUNICATION = _BV(4), ///< Not implemented
#if ENABLED(DEBUG_LEVELING_FEATURE)
MARLIN_DEBUG_LEVELING = _BV(5), ///< Print detailed output for homing and leveling
MARLIN_DEBUG_MESH_ADJUST = _BV(6), ///< UBL bed leveling
#else
MARLIN_DEBUG_LEVELING = 0,
MARLIN_DEBUG_MESH_ADJUST = 0,
#endif
MARLIN_DEBUG_ALL = 0xFF
MARLIN_DEBUG_ECHO = TERN0(DEBUG_FLAGS_GCODE, _BV(0)), //!< Echo commands in order as they are processed
MARLIN_DEBUG_INFO = TERN0(DEBUG_FLAGS_GCODE, _BV(1)), //!< Print messages for code that has debug output
MARLIN_DEBUG_ERRORS = TERN0(DEBUG_FLAGS_GCODE, _BV(2)), //!< Not implemented
MARLIN_DEBUG_DRYRUN = _BV(3), //!< Ignore temperature setting and E movement commands
MARLIN_DEBUG_COMMUNICATION = TERN0(DEBUG_FLAGS_GCODE, _BV(4)), //!< Not implemented
MARLIN_DEBUG_LEVELING = TERN0(DEBUG_LEVELING_FEATURE, _BV(5)), //!< Print detailed output for homing and leveling
MARLIN_DEBUG_MESH_ADJUST = TERN0(DEBUG_LEVELING_FEATURE, _BV(6)), //!< UBL bed leveling
MARLIN_DEBUG_ALL = MARLIN_DEBUG_ECHO|MARLIN_DEBUG_INFO|MARLIN_DEBUG_ERRORS|MARLIN_DEBUG_COMMUNICATION|MARLIN_DEBUG_LEVELING|MARLIN_DEBUG_MESH_ADJUST
};

extern uint8_t marlin_debug_flags;
Expand Down
32 changes: 19 additions & 13 deletions Marlin/src/gcode/control/M111.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,33 @@
*
*/

#include "../../inc/MarlinConfig.h"
#include "../gcode.h"

/**
* M111: Set the debug level
*/
void GcodeSuite::M111() {
if (parser.seenval('S')) marlin_debug_flags = parser.value_byte();

static PGMSTR(str_debug_1, STR_DEBUG_ECHO);
static PGMSTR(str_debug_2, STR_DEBUG_INFO);
static PGMSTR(str_debug_4, STR_DEBUG_ERRORS);
#if ENABLED(DEBUG_FLAGS_GCODE)
static PGMSTR(str_debug_1, STR_DEBUG_ECHO);
static PGMSTR(str_debug_2, STR_DEBUG_INFO);
static PGMSTR(str_debug_4, STR_DEBUG_ERRORS);
#endif
static PGMSTR(str_debug_8, STR_DEBUG_DRYRUN);
static PGMSTR(str_debug_16, STR_DEBUG_COMMUNICATION);
#if ENABLED(DEBUG_FLAGS_GCODE)
static PGMSTR(str_debug_16, STR_DEBUG_COMMUNICATION);
#endif
#if ENABLED(DEBUG_LEVELING_FEATURE)
static PGMSTR(str_debug_detail, STR_DEBUG_DETAIL);
#endif

static PGM_P const debug_strings[] PROGMEM = {
str_debug_1, str_debug_2, str_debug_4, str_debug_8, str_debug_16,
TERN(DEBUG_FLAGS_GCODE, str_debug_1, nullptr),
TERN(DEBUG_FLAGS_GCODE, str_debug_2, nullptr),
TERN(DEBUG_FLAGS_GCODE, str_debug_4, nullptr),
str_debug_8,
TERN(DEBUG_FLAGS_GCODE, str_debug_16, nullptr),
TERN_(DEBUG_LEVELING_FEATURE, str_debug_detail)
};

Expand All @@ -47,31 +55,29 @@ void GcodeSuite::M111() {
if (marlin_debug_flags) {
uint8_t comma = 0;
for (uint8_t i = 0; i < COUNT(debug_strings); ++i) {
if (TEST(marlin_debug_flags, i)) {
PGM_P const pstr = (PGM_P)pgm_read_ptr(&debug_strings[i]);
if (pstr && TEST(marlin_debug_flags, i)) {
if (comma++) SERIAL_CHAR(',');
SERIAL_ECHOPGM_P((PGM_P)pgm_read_ptr(&debug_strings[i]));
SERIAL_ECHOPGM_P(pstr);
}
}
}
else {
SERIAL_ECHOPGM(STR_DEBUG_OFF);
#if !defined(__AVR__) || !defined(USBCON)
#if !(defined(__AVR__) && defined(USBCON))
#if ENABLED(SERIAL_STATS_RX_BUFFER_OVERRUNS)
SERIAL_ECHOPGM("\nBuffer Overruns: ", MYSERIAL1.buffer_overruns());
#endif

#if ENABLED(SERIAL_STATS_RX_FRAMING_ERRORS)
SERIAL_ECHOPGM("\nFraming Errors: ", MYSERIAL1.framing_errors());
#endif

#if ENABLED(SERIAL_STATS_DROPPED_RX)
SERIAL_ECHOPGM("\nDropped bytes: ", MYSERIAL1.dropped());
#endif

#if ENABLED(SERIAL_STATS_MAX_RX_QUEUED)
SERIAL_ECHOPGM("\nMax RX Queue Size: ", MYSERIAL1.rxMaxEnqueued());
#endif
#endif // !__AVR__ || !USBCON
#endif // !(__AVR__ && USBCON)
}
SERIAL_EOL();
}
5 changes: 4 additions & 1 deletion Marlin/src/gcode/gcode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,10 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) {

case 92: M92(); break; // M92: Set the steps-per-unit for one or more axes
case 114: M114(); break; // M114: Report current position
case 115: M115(); break; // M115: Report capabilities

#if ENABLED(REPORT_CAPABILITIES_GCODE)
case 115: M115(); break; // M115: Report capabilities
#endif

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

Expand Down
5 changes: 4 additions & 1 deletion Marlin/src/gcode/gcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,10 @@ class GcodeSuite {
#endif

static void M114();
static void M115();

#if ENABLED(REPORT_CAPABILITIES_GCODE)
static void M115();
#endif

#if HAS_STATUS_MESSAGE
static void M117();
Expand Down
7 changes: 6 additions & 1 deletion Marlin/src/gcode/host/M115.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@
*
*/

#include "../gcode.h"
#include "../../inc/MarlinConfig.h"

#if ENABLED(REPORT_CAPABILITIES_GCODE)

#include "../gcode.h"
#include "../queue.h" // for getting the command port

#if ENABLED(M115_GEOMETRY_REPORT)
Expand Down Expand Up @@ -271,3 +274,5 @@ void GcodeSuite::M115() {

#endif // EXTENDED_CAPABILITIES_REPORT
}

#endif // REPORT_CAPABILITIES_GCODE
8 changes: 8 additions & 0 deletions Marlin/src/inc/Warnings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@
#endif
#endif

#if DISABLED(DEBUG_FLAGS_GCODE)
#warning "DEBUG_FLAGS_GCODE is recommended if you have space. Some hosts rely on it."
#endif

#if DISABLED(REPORT_CAPABILITIES_GCODE)
#warning "REPORT_CAPABILITIES_GCODE is recommended if you have space. Some hosts rely on it."
#endif

#if ENABLED(LA_DEBUG)
#warning "WARNING! Disable LA_DEBUG for the final build!"
#endif
Expand Down
1 change: 1 addition & 0 deletions ini/features.ini
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ CNC_COORDINATE_SYSTEMS = build_src_filter=+<src/gcode/geometry/G
HAS_HOME_OFFSET = build_src_filter=+<src/gcode/geometry/M206_M428.cpp>
EXPECTED_PRINTER_CHECK = build_src_filter=+<src/gcode/host/M16.cpp>
HOST_KEEPALIVE_FEATURE = build_src_filter=+<src/gcode/host/M113.cpp>
REPORT_CAPABILITIES_GCODE = build_src_filter=+<src/gcode/host/M115.cpp>
AUTO_REPORT_POSITION = build_src_filter=+<src/gcode/host/M154.cpp>
REPETIER_GCODE_M360 = build_src_filter=+<src/gcode/host/M360.cpp>
HAS_GCODE_M876 = build_src_filter=+<src/gcode/host/M876.cpp>
Expand Down
1 change: 0 additions & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ default_src_filter = +<src/*> -<src/config> -<src/tests>
+<src/gcode/geometry/G92.cpp>
+<src/gcode/host/M110.cpp>
+<src/gcode/host/M114.cpp>
+<src/gcode/host/M115.cpp>
+<src/gcode/host/M118.cpp>
+<src/gcode/host/M119.cpp>
+<src/gcode/motion/G0_G1.cpp>
Expand Down

0 comments on commit 1ac6428

Please sign in to comment.