From 1ac6428c82aa72cc41c0c9f758659b71e7fce1cf Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Wed, 3 Jan 2024 13:52:12 +1300 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=AA=20Options=20to=20slim=20M111,=20re?= =?UTF-8?q?move=20M115=20(#26603)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Scott Lahteine --- Marlin/Configuration_adv.h | 12 ++++++++++++ Marlin/src/core/serial.h | 21 ++++++++------------ Marlin/src/gcode/control/M111.cpp | 32 ++++++++++++++++++------------- Marlin/src/gcode/gcode.cpp | 5 ++++- Marlin/src/gcode/gcode.h | 5 ++++- Marlin/src/gcode/host/M115.cpp | 7 ++++++- Marlin/src/inc/Warnings.cpp | 8 ++++++++ ini/features.ini | 1 + platformio.ini | 1 - 9 files changed, 62 insertions(+), 30 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 72aee11588..d19fb1d503 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -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. diff --git a/Marlin/src/core/serial.h b/Marlin/src/core/serial.h index ff02ebedc2..f9b73e6d26 100644 --- a/Marlin/src/core/serial.h +++ b/Marlin/src/core/serial.h @@ -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; diff --git a/Marlin/src/gcode/control/M111.cpp b/Marlin/src/gcode/control/M111.cpp index 02f37f8497..a8e549b69d 100644 --- a/Marlin/src/gcode/control/M111.cpp +++ b/Marlin/src/gcode/control/M111.cpp @@ -20,6 +20,7 @@ * */ +#include "../../inc/MarlinConfig.h" #include "../gcode.h" /** @@ -27,18 +28,25 @@ */ 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) }; @@ -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(); } diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index 6a0e8cb171..4266136ef4 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -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 diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index fffd0d714b..d5adf6c415 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -760,7 +760,10 @@ private: #endif static void M114(); - static void M115(); + + #if ENABLED(REPORT_CAPABILITIES_GCODE) + static void M115(); + #endif #if HAS_STATUS_MESSAGE static void M117(); diff --git a/Marlin/src/gcode/host/M115.cpp b/Marlin/src/gcode/host/M115.cpp index 806e593fcb..ae8e615507 100644 --- a/Marlin/src/gcode/host/M115.cpp +++ b/Marlin/src/gcode/host/M115.cpp @@ -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) @@ -271,3 +274,5 @@ void GcodeSuite::M115() { #endif // EXTENDED_CAPABILITIES_REPORT } + +#endif // REPORT_CAPABILITIES_GCODE diff --git a/Marlin/src/inc/Warnings.cpp b/Marlin/src/inc/Warnings.cpp index d239e6a7d5..8f260b237c 100644 --- a/Marlin/src/inc/Warnings.cpp +++ b/Marlin/src/inc/Warnings.cpp @@ -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 diff --git a/ini/features.ini b/ini/features.ini index a550783a38..120d599dca 100644 --- a/ini/features.ini +++ b/ini/features.ini @@ -322,6 +322,7 @@ CNC_COORDINATE_SYSTEMS = build_src_filter=+ EXPECTED_PRINTER_CHECK = build_src_filter=+ HOST_KEEPALIVE_FEATURE = build_src_filter=+ +REPORT_CAPABILITIES_GCODE = build_src_filter=+ AUTO_REPORT_POSITION = build_src_filter=+ REPETIER_GCODE_M360 = build_src_filter=+ HAS_GCODE_M876 = build_src_filter=+ diff --git a/platformio.ini b/platformio.ini index 81f97e73b8..5249b790f2 100644 --- a/platformio.ini +++ b/platformio.ini @@ -111,7 +111,6 @@ default_src_filter = + - - + + + - + + + +