Tidying up parking override control implementation
[new] Added a default configuration for the parking override control upon a reset or power-up. By default, parking is enabled, but this may be disabled via a config.h option. [fix] Parking override control should be checking if the command word is passed, rather than the value.
This commit is contained in:
		@@ -575,8 +575,10 @@
 | 
			
		||||
// These are controlled by `M56`, `M56 P1`, or `M56 Px` to enable and `M56 P0` to disable. 
 | 
			
		||||
// The command is modal and will be set after a planner sync. Since it is g-code, it is 
 | 
			
		||||
// executed in sync with g-code commands. It is not a real-time command.
 | 
			
		||||
// NOTE: PARKING_ENABLE is required.
 | 
			
		||||
// NOTE: PARKING_ENABLE is required. By default, M56 is active upon initialization. Use 
 | 
			
		||||
// DEACTIVATE_PARKING_UPON_INIT to set M56 P0 as the power-up default.
 | 
			
		||||
// #define ENABLE_PARKING_OVERRIDE_CONTROL   // Default disabled. Uncomment to enable
 | 
			
		||||
// #define DEACTIVATE_PARKING_UPON_INIT // Default disabled. Uncomment to enable.
 | 
			
		||||
 | 
			
		||||
// This option will automatically disable the laser during a feed hold by invoking a spindle stop
 | 
			
		||||
// override immediately after coming to a stop. However, this also means that the laser still may
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										12
									
								
								grbl/gcode.c
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								grbl/gcode.c
									
									
									
									
									
								
							@@ -437,7 +437,7 @@ uint8_t gc_execute_line(char *line)
 | 
			
		||||
  // [8. Coolant control ]: N/A
 | 
			
		||||
  // [9. Override control ]: Not supported except for a Grbl-only parking motion override control.
 | 
			
		||||
  #ifdef ENABLE_PARKING_OVERRIDE_CONTROL
 | 
			
		||||
    if (gc_block.modal.override == OVERRIDE_PARKING_MOTION) {
 | 
			
		||||
    if (bit_istrue(command_words,bit(MODAL_GROUP_M9))) { // Already set as enabled in parser.
 | 
			
		||||
      if (bit_istrue(value_words,bit(WORD_P))) {
 | 
			
		||||
        if (gc_block.values.p == 0.0) { gc_block.modal.override = OVERRIDE_DISABLED; }
 | 
			
		||||
        bit_false(value_words,bit(WORD_P));
 | 
			
		||||
@@ -1102,7 +1102,13 @@ uint8_t gc_execute_line(char *line)
 | 
			
		||||
      gc_state.modal.coord_select = 0; // G54
 | 
			
		||||
      gc_state.modal.spindle = SPINDLE_DISABLE;
 | 
			
		||||
      gc_state.modal.coolant = COOLANT_DISABLE;
 | 
			
		||||
      // gc_state.modal.override = OVERRIDE_DISABLE; // Not supported.
 | 
			
		||||
      #ifdef ENABLE_PARKING_OVERRIDE_CONTROL
 | 
			
		||||
        #ifdef DEACTIVATE_PARKING_UPON_INIT
 | 
			
		||||
          gc_state.modal.override = OVERRIDE_DISABLED;
 | 
			
		||||
        #else
 | 
			
		||||
          gc_state.modal.override = OVERRIDE_PARKING_MOTION;
 | 
			
		||||
        #endif
 | 
			
		||||
      #endif
 | 
			
		||||
 | 
			
		||||
      #ifdef RESTORE_OVERRIDES_AFTER_PROGRAM_END
 | 
			
		||||
        sys.f_override = DEFAULT_FEED_OVERRIDE;
 | 
			
		||||
@@ -1148,7 +1154,7 @@ uint8_t gc_execute_line(char *line)
 | 
			
		||||
   group 7 = {G41, G42} cutter radius compensation (G40 is supported)
 | 
			
		||||
   group 8 = {G43} tool length offset (G43.1/G49 are supported)
 | 
			
		||||
   group 8 = {M7*} enable mist coolant (* Compile-option)
 | 
			
		||||
   group 9 = {M48, M49} enable/disable feed and speed override switches
 | 
			
		||||
   group 9 = {M48, M49, M56*} enable/disable override switches (* Compile-option)
 | 
			
		||||
   group 10 = {G98, G99} return mode canned cycles
 | 
			
		||||
   group 13 = {G61.1, G64} path control mode (G61 is supported)
 | 
			
		||||
*/
 | 
			
		||||
 
 | 
			
		||||
@@ -124,8 +124,13 @@
 | 
			
		||||
#define TOOL_LENGTH_OFFSET_ENABLE_DYNAMIC 1 // G43.1
 | 
			
		||||
 | 
			
		||||
// Modal Group M9: Override control
 | 
			
		||||
#define OVERRIDE_DISABLED  0 // None (Default: Must be zero)
 | 
			
		||||
#define OVERRIDE_PARKING_MOTION 1 // G56 (Default: Must be zero)
 | 
			
		||||
#ifdef DEACTIVATE_PARKING_UPON_INIT
 | 
			
		||||
  #define OVERRIDE_DISABLED  0 // (Default: Must be zero)
 | 
			
		||||
  #define OVERRIDE_PARKING_MOTION 1 // M56
 | 
			
		||||
#else
 | 
			
		||||
  #define OVERRIDE_PARKING_MOTION 0 // M56 (Default: Must be zero)
 | 
			
		||||
  #define OVERRIDE_DISABLED  1 // Parking disabled.
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
// Modal Group G12: Active work coordinate system
 | 
			
		||||
// N/A: Stores coordinate system value (54-59) to change to.
 | 
			
		||||
 
 | 
			
		||||
@@ -23,7 +23,7 @@
 | 
			
		||||
 | 
			
		||||
// Grbl versioning system
 | 
			
		||||
#define GRBL_VERSION "1.1f"
 | 
			
		||||
#define GRBL_VERSION_BUILD "20170128"
 | 
			
		||||
#define GRBL_VERSION_BUILD "20170129"
 | 
			
		||||
 | 
			
		||||
// Define standard libraries used by Grbl.
 | 
			
		||||
#include <avr/io.h>
 | 
			
		||||
 
 | 
			
		||||
@@ -579,7 +579,7 @@ static void protocol_exec_rt_suspend()
 | 
			
		||||
            if ((bit_istrue(settings.flags,BITFLAG_HOMING_ENABLE)) &&
 | 
			
		||||
                            (parking_target[PARKING_AXIS] < PARKING_TARGET) &&
 | 
			
		||||
                            bit_isfalse(settings.flags,BITFLAG_LASER_MODE) &&
 | 
			
		||||
                            !sys.override_ctrl) {
 | 
			
		||||
                            (sys.override_ctrl == OVERRIDE_PARKING_MOTION)) {
 | 
			
		||||
            #else
 | 
			
		||||
            if ((bit_istrue(settings.flags,BITFLAG_HOMING_ENABLE)) &&
 | 
			
		||||
                            (parking_target[PARKING_AXIS] < PARKING_TARGET) &&
 | 
			
		||||
@@ -650,7 +650,7 @@ static void protocol_exec_rt_suspend()
 | 
			
		||||
              // NOTE: State is will remain DOOR, until the de-energizing and retract is complete.
 | 
			
		||||
              #ifdef ENABLE_PARKING_OVERRIDE_CONTROL
 | 
			
		||||
              if (((settings.flags & (BITFLAG_HOMING_ENABLE|BITFLAG_LASER_MODE)) == BITFLAG_HOMING_ENABLE) &&
 | 
			
		||||
                  !sys.override_ctrl) {
 | 
			
		||||
                   (sys.override_ctrl == OVERRIDE_PARKING_MOTION)) {
 | 
			
		||||
              #else
 | 
			
		||||
              if ((settings.flags & (BITFLAG_HOMING_ENABLE|BITFLAG_LASER_MODE)) == BITFLAG_HOMING_ENABLE) {
 | 
			
		||||
              #endif
 | 
			
		||||
@@ -689,7 +689,7 @@ static void protocol_exec_rt_suspend()
 | 
			
		||||
              // Execute slow plunge motion from pull-out position to resume position.
 | 
			
		||||
              #ifdef ENABLE_PARKING_OVERRIDE_CONTROL
 | 
			
		||||
              if (((settings.flags & (BITFLAG_HOMING_ENABLE|BITFLAG_LASER_MODE)) == BITFLAG_HOMING_ENABLE) &&
 | 
			
		||||
                  !sys.override_ctrl) {
 | 
			
		||||
                   (sys.override_ctrl == OVERRIDE_PARKING_MOTION)) {
 | 
			
		||||
              #else
 | 
			
		||||
              if ((settings.flags & (BITFLAG_HOMING_ENABLE|BITFLAG_LASER_MODE)) == BITFLAG_HOMING_ENABLE) {
 | 
			
		||||
              #endif
 | 
			
		||||
 
 | 
			
		||||
@@ -328,7 +328,7 @@ void report_gcode_modes()
 | 
			
		||||
  #endif
 | 
			
		||||
 | 
			
		||||
  #ifdef ENABLE_PARKING_OVERRIDE_CONTROL
 | 
			
		||||
    if (sys.override_ctrl) { 
 | 
			
		||||
    if (sys.override_ctrl == OVERRIDE_PARKING_MOTION) { 
 | 
			
		||||
      report_util_gcode_modes_M();
 | 
			
		||||
      print_uint8_base10(56);
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user