Tweaked dry run and check g-code switches. Now resets when toggled off.

- To make managing the code easier and to help ensure a user starts
with a fresh reset, the functionality of check g-code and dry run has
been changed to automatically perform a soft reset when toggled off.
Position will not be lost, unless there is a cycle active. Feed hold
before toggling off it needed.

This is mainly a safety issue. If a user dry runs a program and kills
it mid-program, and then restarts it thinking to run it as normal, the
g-code modes that we're set may not be what they expect, and very bad
things can happen.

- NOTE: Grbl is at 83.5% of flash capacity. Not a lot of room left, but
I think we can squeeze in some more!
This commit is contained in:
Sonny Jeon
2012-11-05 13:32:29 -07:00
parent 9cabc915ef
commit c2b31a06ff
3 changed files with 35 additions and 16 deletions

View File

@ -123,7 +123,7 @@ void protocol_execute_runtime()
// System abort. Steppers have already been force stopped.
if (rt_exec & EXEC_RESET) {
sys.abort = true;
sys.abort = true; // Only place this is set true.
return; // Nothing else to do but exit.
}
@ -215,10 +215,20 @@ uint8_t protocol_execute_line(char *line)
switch (line[++char_counter]) {
case '0' :
helper_var = BITFLAG_CHECK_GCODE;
// Sync position vectors if check mode is being disabled. May be different after checking.
if (bit_istrue(gc.switches,helper_var)) { sys_sync_current_position(); }
// If check mode is being disabled, automatically soft reset Grbl to ensure the user starts
// fresh with the g-code modes in their default, known state.
if (bit_istrue(gc.switches,helper_var)) { sys.execute |= EXEC_RESET; }
break;
case '1' :
helper_var = BITFLAG_DRY_RUN;
// If dry run is being disabled, automatically soft reset Grbl as with check g-code mode
if (bit_istrue(gc.switches,helper_var)) {
// If disabled while in cycle, immediately stop everything and notify user that stopping
// mid-cycle likely lost position.
if (bit_istrue(sys.state,STATE_CYCLE)) { mc_alarm(); }
sys.execute |= EXEC_RESET; // Soft-reset Grbl.
}
break;
case '1' : helper_var = BITFLAG_DRY_RUN; break;
case '2' : helper_var = BITFLAG_BLOCK_DELETE; break;
case '3' : helper_var = BITFLAG_SINGLE_BLOCK; break;
case '4' : helper_var = BITFLAG_OPT_STOP; break;