From b0aeac117f301223903bc90c391000f43c690e96 Mon Sep 17 00:00:00 2001 From: Gabe Rosenhouse Date: Wed, 19 Feb 2014 14:59:10 -0800 Subject: [PATCH 1/3] Adjustable Z probe offset, via custom M-code --- Marlin/Configuration.h | 9 +++++++++ Marlin/Marlin_main.cpp | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 714bb3e634..a98e2d9fc1 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -459,6 +459,15 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of //=============================Additional Features=========================== //=========================================================================== +// Custom M code points +#define CUSTOM_M_CODES +#ifdef CUSTOM_M_CODES + #define CUSTOM_M_CODE_SET_Z_PROBE_OFFSET 851 + #define Z_PROBE_OFFSET_RANGE_MIN -2 + #define Z_PROBE_OFFSET_RANGE_MAX 0 +#endif + + // EEPROM // The microcontroller can store settings in the EEPROM, e.g. max velocity... // M500 - stores parameters in EEPROM diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index b45ca1a90d..f3cb293001 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -2719,6 +2719,42 @@ void process_commands() } break; #endif + + #ifdef CUSTOM_M_CODE_SET_Z_PROBE_OFFSET + case CUSTOM_M_CODE_SET_Z_PROBE_OFFSET: + { + float value; + if (code_seen('Z')) + { + value = code_value(); + if ((Z_PROBE_OFFSET_RANGE_MIN <= value) && (value <= Z_PROBE_OFFSET_RANGE_MAX)) + { + zprobe_zoffset = -value; // compare w/ line 278 of ConfigurationStore.cpp + SERIAL_ECHO_START; + SERIAL_ECHOLNPGM("Z probe offset has been set"); + SERIAL_PROTOCOLLN(""); + } + else + { + SERIAL_ECHO_START; + SERIAL_ECHOPGM("Invalid z-probe value. Must be between "); + SERIAL_ECHO(Z_PROBE_OFFSET_RANGE_MIN); + SERIAL_ECHOPGM(" and "); + SERIAL_ECHO(Z_PROBE_OFFSET_RANGE_MAX); + SERIAL_PROTOCOLLN(""); + } + } + else + { + SERIAL_ECHO_START; + SERIAL_ECHOLNPGM("Z probe offset is currently "); + SERIAL_ECHO(-zprobe_zoffset); + SERIAL_PROTOCOLLN(""); + } + break; + } + #endif // CUSTOM_M_CODE_SET_Z_PROBE_OFFSET + #ifdef FILAMENTCHANGEENABLE case 600: //Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal] { From d3f305332a37fc830cbfd9d8bb9a09c793b526e0 Mon Sep 17 00:00:00 2001 From: Gabe Rosenhouse Date: Mon, 24 Feb 2014 10:06:12 -0800 Subject: [PATCH 2/3] Allowable range now includes default value --- Marlin/Configuration.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index a98e2d9fc1..32ce5b7dbb 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -463,8 +463,8 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of #define CUSTOM_M_CODES #ifdef CUSTOM_M_CODES #define CUSTOM_M_CODE_SET_Z_PROBE_OFFSET 851 - #define Z_PROBE_OFFSET_RANGE_MIN -2 - #define Z_PROBE_OFFSET_RANGE_MAX 0 + #define Z_PROBE_OFFSET_RANGE_MIN -15 + #define Z_PROBE_OFFSET_RANGE_MAX -5 #endif From 27a7cf9fcff436f1d30451c26db1fe4f8c442c36 Mon Sep 17 00:00:00 2001 From: Gabe Rosenhouse Date: Sun, 6 Apr 2014 19:43:46 -0500 Subject: [PATCH 3/3] use existing strings --- Marlin/Marlin_main.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index f3cb293001..618e906b88 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -2731,15 +2731,16 @@ void process_commands() { zprobe_zoffset = -value; // compare w/ line 278 of ConfigurationStore.cpp SERIAL_ECHO_START; - SERIAL_ECHOLNPGM("Z probe offset has been set"); + SERIAL_ECHOLNPGM(MSG_ZPROBE_ZOFFSET " " MSG_OK); SERIAL_PROTOCOLLN(""); } else { SERIAL_ECHO_START; - SERIAL_ECHOPGM("Invalid z-probe value. Must be between "); + SERIAL_ECHOPGM(MSG_ZPROBE_ZOFFSET); + SERIAL_ECHOPGM(MSG_Z_MIN); SERIAL_ECHO(Z_PROBE_OFFSET_RANGE_MIN); - SERIAL_ECHOPGM(" and "); + SERIAL_ECHOPGM(MSG_Z_MAX); SERIAL_ECHO(Z_PROBE_OFFSET_RANGE_MAX); SERIAL_PROTOCOLLN(""); } @@ -2747,7 +2748,7 @@ void process_commands() else { SERIAL_ECHO_START; - SERIAL_ECHOLNPGM("Z probe offset is currently "); + SERIAL_ECHOLNPGM(MSG_ZPROBE_ZOFFSET " : "); SERIAL_ECHO(-zprobe_zoffset); SERIAL_PROTOCOLLN(""); }