From ec9e84a068f0f607775c5f5efdb83d290920b198 Mon Sep 17 00:00:00 2001 From: Markus Hitter Date: Wed, 27 Nov 2013 18:50:37 +0100 Subject: [PATCH] gcode_parse.c: assume G1 only for stuff which might actually move. Previously, even comments were run through dda_create(), quite a waste of time. --- gcode_parse.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/gcode_parse.c b/gcode_parse.c index 2ac6f44..c86ea78 100644 --- a/gcode_parse.c +++ b/gcode_parse.c @@ -88,10 +88,6 @@ static int32_t decfloat_to_int(decfloat *df, uint16_t multiplicand) { void gcode_init(void) { // gcc guarantees us all variables are initialised to 0. - // assume a G1 by default - next_target.seen_G = 1; - next_target.G = 1; - #ifndef E_ABSOLUTE next_target.option_e_relative = 1; #endif @@ -327,6 +323,14 @@ void gcode_parse_char(uint8_t c) { if (DEBUG_ECHO && (debug_flags & DEBUG_ECHO)) serial_writechar(c); + // Assume G1 for unspecified movements. + if ( ! next_target.seen_G && + (next_target.seen_X || next_target.seen_Y || next_target.seen_Z || + next_target.seen_E || next_target.seen_F)) { + next_target.seen_G = 1; + next_target.G = 1; + } + if ( #ifdef REQUIRE_LINENUMBER ((next_target.N >= next_target.N_expected) && (next_target.seen_N == 1)) || @@ -365,15 +369,11 @@ void gcode_parse_char(uint8_t c) { next_target.seen_X = next_target.seen_Y = next_target.seen_Z = \ next_target.seen_E = next_target.seen_F = next_target.seen_S = \ next_target.seen_P = next_target.seen_T = next_target.seen_N = \ - next_target.seen_M = next_target.seen_checksum = next_target.seen_semi_comment = \ - next_target.seen_parens_comment = next_target.checksum_read = \ - next_target.checksum_calculated = 0; + next_target.seen_G = next_target.seen_M = next_target.seen_checksum = \ + next_target.seen_semi_comment = next_target.seen_parens_comment = \ + next_target.checksum_read = next_target.checksum_calculated = 0; // last_field and read_digit are reset above already - // assume a G1 by default - next_target.seen_G = 1; - next_target.G = 1; - if (next_target.option_all_relative) { next_target.target.X = next_target.target.Y = next_target.target.Z = 0; }