Improve G34, M422 (Z alignment) (#14142)

This commit is contained in:
InsanityAutomation
2019-06-18 08:02:18 -04:00
committed by Scott Lahteine
parent 391250b04f
commit bf64dd4db6
4 changed files with 137 additions and 116 deletions

View File

@ -187,11 +187,7 @@ void GcodeSuite::dwell(millis_t time) {
/**
* Process the parsed command and dispatch it to its handler
*/
void GcodeSuite::process_parsed_command(
#if USE_EXECUTE_COMMANDS_IMMEDIATE
const bool no_ok
#endif
) {
void GcodeSuite::process_parsed_command(const bool no_ok) {
KEEPALIVE_STATE(IN_HANDLER);
// Handle a known G, M, or T
@ -802,10 +798,7 @@ void GcodeSuite::process_parsed_command(
KEEPALIVE_STATE(NOT_BUSY);
#if USE_EXECUTE_COMMANDS_IMMEDIATE
if (!no_ok)
#endif
ok_to_send();
if (!no_ok) ok_to_send();
}
/**
@ -831,43 +824,39 @@ void GcodeSuite::process_next_command() {
process_parsed_command();
}
#if USE_EXECUTE_COMMANDS_IMMEDIATE
/**
* Run a series of commands, bypassing the command queue to allow
* G-code "macros" to be called from within other G-code handlers.
*/
/**
* Run a series of commands, bypassing the command queue to allow
* G-code "macros" to be called from within other G-code handlers.
*/
void GcodeSuite::process_subcommands_now_P(PGM_P pgcode) {
char * const saved_cmd = parser.command_ptr; // Save the parser state
for (;;) {
PGM_P const delim = strchr_P(pgcode, '\n'); // Get address of next newline
const size_t len = delim ? delim - pgcode : strlen_P(pgcode); // Get the command length
char cmd[len + 1]; // Allocate a stack buffer
strncpy_P(cmd, pgcode, len); // Copy the command to the stack
cmd[len] = '\0'; // End with a nul
parser.parse(cmd); // Parse the command
process_parsed_command(true); // Process it
if (!delim) break; // Last command?
pgcode = delim + 1; // Get the next command
}
parser.parse(saved_cmd); // Restore the parser state
void GcodeSuite::process_subcommands_now_P(PGM_P pgcode) {
char * const saved_cmd = parser.command_ptr; // Save the parser state
for (;;) {
PGM_P const delim = strchr_P(pgcode, '\n'); // Get address of next newline
const size_t len = delim ? delim - pgcode : strlen_P(pgcode); // Get the command length
char cmd[len + 1]; // Allocate a stack buffer
strncpy_P(cmd, pgcode, len); // Copy the command to the stack
cmd[len] = '\0'; // End with a nul
parser.parse(cmd); // Parse the command
process_parsed_command(true); // Process it
if (!delim) break; // Last command?
pgcode = delim + 1; // Get the next command
}
parser.parse(saved_cmd); // Restore the parser state
}
void GcodeSuite::process_subcommands_now(char * gcode) {
char * const saved_cmd = parser.command_ptr; // Save the parser state
for (;;) {
char * const delim = strchr(gcode, '\n'); // Get address of next newline
if (delim) *delim = '\0'; // Replace with nul
parser.parse(gcode); // Parse the current command
process_parsed_command(true); // Process it
if (!delim) break; // Last command?
gcode = delim + 1; // Get the next command
}
parser.parse(saved_cmd); // Restore the parser state
void GcodeSuite::process_subcommands_now(char * gcode) {
char * const saved_cmd = parser.command_ptr; // Save the parser state
for (;;) {
char * const delim = strchr(gcode, '\n'); // Get address of next newline
if (delim) *delim = '\0'; // Replace with nul
parser.parse(gcode); // Parse the current command
process_parsed_command(true); // Process it
if (!delim) break; // Last command?
gcode = delim + 1; // Get the next command
}
#endif // USE_EXECUTE_COMMANDS_IMMEDIATE
parser.parse(saved_cmd); // Restore the parser state
}
#if ENABLED(HOST_KEEPALIVE_FEATURE)