gcode_parse.c: process incoming digits earlier.
Idea and patch from ItsDrone, see http://forums.reprap.org/read.php?146,174364,174550#msg-174550 Thanks, ItsDrone.
This commit is contained in:
parent
03d49a1a87
commit
63d3f012a8
|
|
@ -211,8 +211,25 @@ void gcode_parse_char(uint8_t c) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// process character
|
// process character
|
||||||
|
// Can't do ranges in switch..case, so process actual digits here.
|
||||||
|
// Do it early, as there are many more digits than characters expected.
|
||||||
|
if (c >= '0' && c <= '9') {
|
||||||
|
if (read_digit.exponent < DECFLOAT_EXP_MAX + 1 &&
|
||||||
|
((next_target.option_inches == 0 &&
|
||||||
|
read_digit.mantissa < DECFLOAT_MANT_MM_MAX) ||
|
||||||
|
(next_target.option_inches &&
|
||||||
|
read_digit.mantissa < DECFLOAT_MANT_IN_MAX))) {
|
||||||
|
// this is simply mantissa = (mantissa * 10) + atoi(c) in different clothes
|
||||||
|
read_digit.mantissa = (read_digit.mantissa << 3) +
|
||||||
|
(read_digit.mantissa << 1) + (c - '0');
|
||||||
|
if (read_digit.exponent)
|
||||||
|
read_digit.exponent++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
// each currently known command is either G or M, so preserve previous G/M unless a new one has appeared
|
// Each currently known command is either G or M, so preserve
|
||||||
|
// previous G/M unless a new one has appeared.
|
||||||
// FIXME: same for T command
|
// FIXME: same for T command
|
||||||
case 'G':
|
case 'G':
|
||||||
next_target.seen_G = 1;
|
next_target.seen_G = 1;
|
||||||
|
|
@ -284,28 +301,14 @@ void gcode_parse_char(uint8_t c) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// can't do ranges in switch..case, so process actual digits here.
|
|
||||||
if (c >= '0' && c <= '9') {
|
|
||||||
if (read_digit.exponent < DECFLOAT_EXP_MAX + 1 &&
|
|
||||||
((next_target.option_inches == 0 &&
|
|
||||||
read_digit.mantissa < DECFLOAT_MANT_MM_MAX) ||
|
|
||||||
(next_target.option_inches &&
|
|
||||||
read_digit.mantissa < DECFLOAT_MANT_IN_MAX)))
|
|
||||||
{
|
|
||||||
// this is simply mantissa = (mantissa * 10) + atoi(c) in different clothes
|
|
||||||
read_digit.mantissa = (read_digit.mantissa << 3) + (read_digit.mantissa << 1) + (c - '0');
|
|
||||||
if (read_digit.exponent)
|
|
||||||
read_digit.exponent++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
else {
|
|
||||||
// invalid
|
// invalid
|
||||||
serial_writechar('?');
|
serial_writechar('?');
|
||||||
serial_writechar(c);
|
serial_writechar(c);
|
||||||
serial_writechar('?');
|
serial_writechar('?');
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if ( next_target.seen_parens_comment == 1 && c == ')')
|
} else if ( next_target.seen_parens_comment == 1 && c == ')')
|
||||||
next_target.seen_parens_comment = 0; // recognize stuff after a (comment)
|
next_target.seen_parens_comment = 0; // recognize stuff after a (comment)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue