Browse Source

Adjustable Z probe offset, via custom M-code

Gabe Rosenhouse 11 years ago
parent
commit
b0aeac117f
2 changed files with 45 additions and 0 deletions
  1. 9
    0
      Marlin/Configuration.h
  2. 36
    0
      Marlin/Marlin_main.cpp

+ 9
- 0
Marlin/Configuration.h View File

@@ -459,6 +459,15 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
459 459
 //=============================Additional Features===========================
460 460
 //===========================================================================
461 461
 
462
+// Custom M code points
463
+#define CUSTOM_M_CODES
464
+#ifdef CUSTOM_M_CODES
465
+  #define CUSTOM_M_CODE_SET_Z_PROBE_OFFSET 851
466
+  #define Z_PROBE_OFFSET_RANGE_MIN -2
467
+  #define Z_PROBE_OFFSET_RANGE_MAX 0
468
+#endif
469
+
470
+
462 471
 // EEPROM
463 472
 // The microcontroller can store settings in the EEPROM, e.g. max velocity...
464 473
 // M500 - stores parameters in EEPROM

+ 36
- 0
Marlin/Marlin_main.cpp View File

@@ -2719,6 +2719,42 @@ void process_commands()
2719 2719
     }
2720 2720
     break;
2721 2721
     #endif
2722
+
2723
+    #ifdef CUSTOM_M_CODE_SET_Z_PROBE_OFFSET
2724
+    case CUSTOM_M_CODE_SET_Z_PROBE_OFFSET:
2725
+    {
2726
+      float value;
2727
+      if (code_seen('Z'))
2728
+      {
2729
+        value = code_value();
2730
+        if ((Z_PROBE_OFFSET_RANGE_MIN <= value) && (value <= Z_PROBE_OFFSET_RANGE_MAX))
2731
+        {
2732
+          zprobe_zoffset = -value; // compare w/ line 278 of ConfigurationStore.cpp
2733
+          SERIAL_ECHO_START;
2734
+          SERIAL_ECHOLNPGM("Z probe offset has been set");
2735
+          SERIAL_PROTOCOLLN("");
2736
+        }
2737
+        else
2738
+        {
2739
+          SERIAL_ECHO_START;
2740
+          SERIAL_ECHOPGM("Invalid z-probe value.  Must be between ");
2741
+          SERIAL_ECHO(Z_PROBE_OFFSET_RANGE_MIN);
2742
+          SERIAL_ECHOPGM(" and ");
2743
+          SERIAL_ECHO(Z_PROBE_OFFSET_RANGE_MAX);
2744
+          SERIAL_PROTOCOLLN("");
2745
+        }
2746
+      }
2747
+      else
2748
+      {
2749
+          SERIAL_ECHO_START;
2750
+          SERIAL_ECHOLNPGM("Z probe offset is currently ");
2751
+          SERIAL_ECHO(-zprobe_zoffset);
2752
+          SERIAL_PROTOCOLLN("");
2753
+      }
2754
+      break;
2755
+    }
2756
+    #endif // CUSTOM_M_CODE_SET_Z_PROBE_OFFSET
2757
+
2722 2758
     #ifdef FILAMENTCHANGEENABLE
2723 2759
     case 600: //Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal]
2724 2760
     {

Loading…
Cancel
Save