Browse Source

Merge pull request #804 from MissionSt/adjustable-z-probe-offset

Adjustable Z probe offset via custom M-code
nothinman 10 years ago
parent
commit
2fa51f8920
2 changed files with 46 additions and 0 deletions
  1. 9
    0
      Marlin/Configuration.h
  2. 37
    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 -15
467
+  #define Z_PROBE_OFFSET_RANGE_MAX -5
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

+ 37
- 0
Marlin/Marlin_main.cpp View File

@@ -2719,6 +2719,43 @@ 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(MSG_ZPROBE_ZOFFSET " " MSG_OK);
2735
+          SERIAL_PROTOCOLLN("");
2736
+        }
2737
+        else
2738
+        {
2739
+          SERIAL_ECHO_START;
2740
+          SERIAL_ECHOPGM(MSG_ZPROBE_ZOFFSET);
2741
+          SERIAL_ECHOPGM(MSG_Z_MIN);
2742
+          SERIAL_ECHO(Z_PROBE_OFFSET_RANGE_MIN);
2743
+          SERIAL_ECHOPGM(MSG_Z_MAX);
2744
+          SERIAL_ECHO(Z_PROBE_OFFSET_RANGE_MAX);
2745
+          SERIAL_PROTOCOLLN("");
2746
+        }
2747
+      }
2748
+      else
2749
+      {
2750
+          SERIAL_ECHO_START;
2751
+          SERIAL_ECHOLNPGM(MSG_ZPROBE_ZOFFSET " : ");
2752
+          SERIAL_ECHO(-zprobe_zoffset);
2753
+          SERIAL_PROTOCOLLN("");
2754
+      }
2755
+      break;
2756
+    }
2757
+    #endif // CUSTOM_M_CODE_SET_Z_PROBE_OFFSET
2758
+
2722 2759
     #ifdef FILAMENTCHANGEENABLE
2723 2760
     case 600: //Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal]
2724 2761
     {

Loading…
Cancel
Save