Add g-code quoted strings, improve stream code (#16818)
This commit is contained in:
@@ -208,6 +208,12 @@ public:
|
||||
return SEEN_TEST('X') || SEEN_TEST('Y') || SEEN_TEST('Z') || SEEN_TEST('E');
|
||||
}
|
||||
|
||||
#if ENABLED(GCODE_QUOTED_STRINGS)
|
||||
static char* unescape_string(char* &src);
|
||||
#else
|
||||
FORCE_INLINE static char* unescape_string(char* &src) { return src; }
|
||||
#endif
|
||||
|
||||
// Populate all fields by parsing a single line of GCode
|
||||
// This uses 54 bytes of SRAM to speed up seen/value
|
||||
static void parse(char * p);
|
||||
@@ -223,6 +229,9 @@ public:
|
||||
// Seen a parameter with a value
|
||||
static inline bool seenval(const char c) { return seen(c) && has_value(); }
|
||||
|
||||
// Float removes 'E' to prevent scientific notation interpretation
|
||||
static inline char* value_string() { return value_ptr; }
|
||||
|
||||
// Float removes 'E' to prevent scientific notation interpretation
|
||||
static inline float value_float() {
|
||||
if (value_ptr) {
|
||||
@@ -369,6 +378,7 @@ public:
|
||||
void unknown_command_warning();
|
||||
|
||||
// Provide simple value accessors with default option
|
||||
static inline char* stringval(const char c, char * const dval=nullptr) { return seenval(c) ? value_string() : dval; }
|
||||
static inline float floatval(const char c, const float dval=0.0) { return seenval(c) ? value_float() : dval; }
|
||||
static inline bool boolval(const char c, const bool dval=false) { return seenval(c) ? value_bool() : (seen(c) ? true : dval); }
|
||||
static inline uint8_t byteval(const char c, const uint8_t dval=0) { return seenval(c) ? value_byte() : dval; }
|
||||
|
||||
Reference in New Issue
Block a user