Skip to content

Commit

Permalink
Allow USE_GCODE_SUBCODES for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Feb 23, 2020
1 parent b2328d0 commit 0ba1884
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Marlin/src/gcode/geometry/G92.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void GcodeSuite::G92() {

bool sync_E = false, sync_XYZ = false;

#if USE_GCODE_SUBCODES
#if ENABLED(USE_GCODE_SUBCODES)
const uint8_t subcode_G92 = parser.subcode;
#else
constexpr uint8_t subcode_G92 = 0;
Expand Down
22 changes: 11 additions & 11 deletions Marlin/src/gcode/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ char *GCodeParser::command_ptr,
char GCodeParser::command_letter;
int GCodeParser::codenum;

#if USE_GCODE_SUBCODES
#if ENABLED(USE_GCODE_SUBCODES)
uint8_t GCodeParser::subcode;
#endif

#if ENABLED(GCODE_MOTION_MODES)
int16_t GCodeParser::motion_mode_codenum = -1;
#if USE_GCODE_SUBCODES
#if ENABLED(USE_GCODE_SUBCODES)
uint8_t GCodeParser::motion_mode_subcode;
#endif
#endif
Expand All @@ -83,7 +83,7 @@ void GCodeParser::reset() {
string_arg = nullptr; // No whole line argument
command_letter = '?'; // No command letter
codenum = 0; // No command code
#if USE_GCODE_SUBCODES
#if ENABLED(USE_GCODE_SUBCODES)
subcode = 0; // No command sub-code
#endif
#if ENABLED(FASTER_GCODE_PARSER)
Expand Down Expand Up @@ -187,12 +187,12 @@ void GCodeParser::parse(char *p) {
do { codenum *= 10, codenum += *p++ - '0'; } while (NUMERIC(*p));

// Allow for decimal point in command
#if USE_GCODE_SUBCODES
if (*p == '.') {
p++;
while (NUMERIC(*p))
subcode *= 10, subcode += *p++ - '0';
}
#if ENABLED(USE_GCODE_SUBCODES)
if (*p == '.') {
p++;
while (NUMERIC(*p))
subcode *= 10, subcode += *p++ - '0';
}
#endif

// Skip all spaces to get to the first argument, or nul
Expand All @@ -206,7 +206,7 @@ void GCodeParser::parse(char *p) {
)
) {
motion_mode_codenum = codenum;
#if USE_GCODE_SUBCODES
#if ENABLED(USE_GCODE_SUBCODES)
motion_mode_subcode = subcode;
#endif
}
Expand All @@ -225,7 +225,7 @@ void GCodeParser::parse(char *p) {
if (motion_mode_codenum < 0) return;
command_letter = 'G';
codenum = motion_mode_codenum;
#if USE_GCODE_SUBCODES
#if ENABLED(USE_GCODE_SUBCODES)
subcode = motion_mode_subcode;
#endif
p--; // Back up one character to use the current parameter
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/gcode/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ class GCodeParser {
*string_arg, // string of command line
command_letter; // G, M, or T
static int codenum; // 123
#if USE_GCODE_SUBCODES
#if ENABLED(USE_GCODE_SUBCODES)
static uint8_t subcode; // .1
#endif

#if ENABLED(GCODE_MOTION_MODES)
static int16_t motion_mode_codenum;
#if USE_GCODE_SUBCODES
#if ENABLED(USE_GCODE_SUBCODES)
static uint8_t motion_mode_subcode;
#endif
FORCE_INLINE static void cancel_motion_mode() { motion_mode_codenum = -1; }
Expand Down
4 changes: 3 additions & 1 deletion Marlin/src/inc/Conditionals_post.h
Original file line number Diff line number Diff line change
Expand Up @@ -2110,7 +2110,9 @@
#endif

// Add commands that need sub-codes to this list
#define USE_GCODE_SUBCODES ANY(G38_PROBE_TARGET, CNC_COORDINATE_SYSTEMS, POWER_LOSS_RECOVERY)
#if ANY(G38_PROBE_TARGET, CNC_COORDINATE_SYSTEMS, POWER_LOSS_RECOVERY)
#define USE_GCODE_SUBCODES
#endif

// Parking Extruder
#if ENABLED(PARKING_EXTRUDER)
Expand Down

0 comments on commit 0ba1884

Please sign in to comment.