Tweaks and minor bug fixes. Added purge buffer command.

- Added a purge buffer (and lock) command. This is an advanced option
to clear any queued blocks in the buffer in the event of system
position being lost or homed. These queued blocks will likely not move
correctly if not purged. In typical use, the purging command releases
the homing axes lock in case a user need to move the axes off their
hard limit switches, but position is not guaranteed. Homing is advised
immediately after.

- Created a system-wide sync current position function. Cleans up some
of the repetitive tasks in various places in the code that do the same
thing.

- Removed the clear all switches command '$S'. Not really needed and
helped clean up a sync call.

- Other minor tweaks. Readme updated slightly..
This commit is contained in:
Sonny Jeon
2012-11-04 08:44:54 -07:00
parent 4c711a4af7
commit 8c0106c247
12 changed files with 59 additions and 52 deletions

View File

@ -183,25 +183,33 @@ uint8_t protocol_execute_line(char *line)
// block buffer without having the planner plan them. It would need to manage de/ac-celerations
// on its own carefully. This approach could be effective and possibly size/memory efficient.
case 'S' : // Switch modes
if ( line[++char_counter] != 0 ) { return(STATUS_UNSUPPORTED_STATEMENT); }
// Set helper_var as switch bitmask or clearing flag
switch (line[++char_counter]) {
case 0 : helper_var = 0; break;
case '0' : helper_var = BITFLAG_CHECK_GCODE; break;
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(); }
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;
default : return(STATUS_INVALID_STATEMENT);
}
if (helper_var) {
if ( line[++char_counter] != 0 ) { return(STATUS_UNSUPPORTED_STATEMENT); }
gc.switches ^= helper_var;
if (bit_istrue(gc.switches,helper_var)) { report_feedback_message(MESSAGE_SWITCH_ON); }
else { report_feedback_message(MESSAGE_SWITCH_OFF); }
} else {
gc.switches = helper_var; // Clear all switches
report_feedback_message(MESSAGE_SWITCHES_CLEARED);
gc.switches ^= helper_var;
if (bit_istrue(gc.switches,helper_var)) { report_feedback_message(MESSAGE_SWITCH_ON); }
else { report_feedback_message(MESSAGE_SWITCH_OFF); }
break;
case 'P' : // Purge system
if ( line[++char_counter] != 0 ) { return(STATUS_UNSUPPORTED_STATEMENT); }
if (sys.state == STATE_CYCLE) { return(STATUS_PURGE_CYCLE); } // Also prevents position error
plan_reset_buffer();
if (sys.state == STATE_LOST) {
report_feedback_message(MESSAGE_PURGE_AXES_LOCK);
sys_sync_current_position(); // Any motion commands during a lock can unsync position vectors.
}
sys.state = STATE_IDLE;
break;
case 'N' : // Startup lines.
if ( line[++char_counter] == 0 ) { // Print startup lines