20
20
*
21
21
*/
22
22
23
+ #include " ../../inc/MarlinConfig.h"
23
24
#include " ../gcode.h"
24
25
25
26
/* *
26
27
* M111: Set the debug level
27
28
*/
28
29
void GcodeSuite::M111 () {
29
30
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
34
36
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
36
40
#if ENABLED(DEBUG_LEVELING_FEATURE)
37
41
static PGMSTR (str_debug_detail, STR_DEBUG_DETAIL);
38
42
#endif
39
43
40
44
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 ),
42
50
TERN_ (DEBUG_LEVELING_FEATURE, str_debug_detail)
43
51
};
44
52
@@ -47,31 +55,29 @@ void GcodeSuite::M111() {
47
55
if (marlin_debug_flags) {
48
56
uint8_t comma = 0 ;
49
57
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)) {
51
60
if (comma++) SERIAL_CHAR (' ,' );
52
- SERIAL_ECHOPGM_P ((PGM_P) pgm_read_ptr (&debug_strings[i]) );
61
+ SERIAL_ECHOPGM_P (pstr );
53
62
}
54
63
}
55
64
}
56
65
else {
57
66
SERIAL_ECHOPGM (STR_DEBUG_OFF);
58
- #if !defined(__AVR__) || ! defined(USBCON)
67
+ #if !( defined(__AVR__) && defined(USBCON) )
59
68
#if ENABLED(SERIAL_STATS_RX_BUFFER_OVERRUNS)
60
69
SERIAL_ECHOPGM (" \n Buffer Overruns: " , MYSERIAL1.buffer_overruns ());
61
70
#endif
62
-
63
71
#if ENABLED(SERIAL_STATS_RX_FRAMING_ERRORS)
64
72
SERIAL_ECHOPGM (" \n Framing Errors: " , MYSERIAL1.framing_errors ());
65
73
#endif
66
-
67
74
#if ENABLED(SERIAL_STATS_DROPPED_RX)
68
75
SERIAL_ECHOPGM (" \n Dropped bytes: " , MYSERIAL1.dropped ());
69
76
#endif
70
-
71
77
#if ENABLED(SERIAL_STATS_MAX_RX_QUEUED)
72
78
SERIAL_ECHOPGM (" \n Max RX Queue Size: " , MYSERIAL1.rxMaxEnqueued ());
73
79
#endif
74
- #endif // !__AVR__ || ! USBCON
80
+ #endif // !( __AVR__ && USBCON)
75
81
}
76
82
SERIAL_EOL ();
77
83
}
0 commit comments