|
@@ -51,7 +51,7 @@ private:
|
51
|
51
|
static char *value_ptr; // Set by seen, used to fetch the value
|
52
|
52
|
|
53
|
53
|
#if ENABLED(FASTER_GCODE_PARSER)
|
54
|
|
- static byte codebits[4]; // Parameters pre-scanned
|
|
54
|
+ static uint32_t codebits; // Parameters pre-scanned
|
55
|
55
|
static uint8_t param[26]; // For A-Z, offsets into command args
|
56
|
56
|
#else
|
57
|
57
|
static char *command_args; // Args start here, for slow scan
|
|
@@ -88,26 +88,22 @@ public:
|
88
|
88
|
// Reset is done before parsing
|
89
|
89
|
static void reset();
|
90
|
90
|
|
91
|
|
- // Index so that 'X' falls on index 24
|
92
|
|
- #define PARAM_IND(N) ((N) >> 3)
|
93
|
|
- #define PARAM_BIT(N) ((N) & 0x7)
|
94
|
|
- #define LETTER_OFF(N) ((N) - 'A')
|
95
|
|
- #define LETTER_IND(N) PARAM_IND(LETTER_OFF(N))
|
96
|
|
- #define LETTER_BIT(N) PARAM_BIT(LETTER_OFF(N))
|
|
91
|
+ #define LETTER_BIT(N) ((N) - 'A')
|
97
|
92
|
|
98
|
93
|
#if ENABLED(FASTER_GCODE_PARSER)
|
99
|
94
|
|
100
|
95
|
// Set the flag and pointer for a parameter
|
101
|
96
|
static void set(const char c, char * const ptr) {
|
102
|
|
- const uint8_t ind = LETTER_OFF(c);
|
|
97
|
+ const uint8_t ind = LETTER_BIT(c);
|
103
|
98
|
if (ind >= COUNT(param)) return; // Only A-Z
|
104
|
|
- SBI(codebits[PARAM_IND(ind)], PARAM_BIT(ind)); // parameter exists
|
|
99
|
+ SBI(codebits, ind); // parameter exists
|
105
|
100
|
param[ind] = ptr ? ptr - command_ptr : 0; // parameter offset or 0
|
106
|
101
|
#if ENABLED(DEBUG_GCODE_PARSER)
|
107
|
102
|
if (codenum == 800) {
|
108
|
|
- SERIAL_ECHOPAIR("Set bit ", (int)PARAM_BIT(ind));
|
109
|
|
- SERIAL_ECHOPAIR(" of index ", (int)PARAM_IND(ind));
|
110
|
|
- SERIAL_ECHOLNPAIR(" | param = ", (int)param[ind]);
|
|
103
|
+ SERIAL_ECHOPAIR("Set bit ", (int)ind);
|
|
104
|
+ SERIAL_ECHOPAIR(" of codebits (", hex_address((void*)(codebits >> 16)));
|
|
105
|
+ print_hex_word((uint16_t)(codebits & 0xFFFF));
|
|
106
|
+ SERIAL_ECHOLNPAIR(") | param = ", (int)param[ind]);
|
111
|
107
|
}
|
112
|
108
|
#endif
|
113
|
109
|
}
|
|
@@ -115,16 +111,19 @@ public:
|
115
|
111
|
// Code seen bit was set. If not found, value_ptr is unchanged.
|
116
|
112
|
// This allows "if (seen('A')||seen('B'))" to use the last-found value.
|
117
|
113
|
static bool seen(const char c) {
|
118
|
|
- const uint8_t ind = LETTER_OFF(c);
|
|
114
|
+ const uint8_t ind = LETTER_BIT(c);
|
119
|
115
|
if (ind >= COUNT(param)) return false; // Only A-Z
|
120
|
|
- const bool b = TEST(codebits[PARAM_IND(ind)], PARAM_BIT(ind));
|
121
|
|
- if (b) value_ptr = param[ind] ? command_ptr + param[ind] : (char*)NULL;
|
|
116
|
+ const bool b = TEST(codebits, ind);
|
|
117
|
+ if (b) {
|
|
118
|
+ char * const ptr = command_ptr + param[ind];
|
|
119
|
+ value_ptr = param[ind] && valid_float(ptr) ? ptr : (char*)NULL;
|
|
120
|
+ }
|
122
|
121
|
return b;
|
123
|
122
|
}
|
124
|
123
|
|
125
|
|
- static bool seen_any() { return codebits[3] || codebits[2] || codebits[1] || codebits[0]; }
|
|
124
|
+ static bool seen_any() { return !!codebits; }
|
126
|
125
|
|
127
|
|
- #define SEEN_TEST(L) TEST(codebits[LETTER_IND(L)], LETTER_BIT(L))
|
|
126
|
+ #define SEEN_TEST(L) TEST(codebits, LETTER_BIT(L))
|
128
|
127
|
|
129
|
128
|
#else // !FASTER_GCODE_PARSER
|
130
|
129
|
|