From 7bf2190f03228666fdec3e1f8f0d8548a1ab2e95 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 4 Feb 2020 08:32:43 -0600 Subject: [PATCH] Fix CALIBRATION_GCODE pin handling --- Marlin/Configuration_adv.h | 4 ++-- Marlin/src/HAL/HAL_DUE/EepromEmulation.cpp | 21 ++++++++++++++++ Marlin/src/gcode/calibrate/G425.cpp | 16 +++++++------ Marlin/src/inc/Conditionals_post.h | 1 - Marlin/src/lcd/language/language_tr.h | 2 +- Marlin/src/module/endstops.cpp | 2 +- Marlin/src/pins/sam/pins_CNCONTROLS_15D.h | 28 +++++++++++++++++++++- 7 files changed, 61 insertions(+), 13 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index aea9656971..51a6b4508b 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -840,8 +840,8 @@ // Define the pin to read during calibration #ifndef CALIBRATION_PIN - #define CALIBRATION_PIN -1 // Override in pins.h or set to -1 to use your Z endstop - #define CALIBRATION_PIN_INVERTING false // Set to true to invert the pin + //#define CALIBRATION_PIN -1 // Define here to override the default pin + #define CALIBRATION_PIN_INVERTING false // Set to true to invert the custom pin //#define CALIBRATION_PIN_PULLDOWN #define CALIBRATION_PIN_PULLUP #endif diff --git a/Marlin/src/HAL/HAL_DUE/EepromEmulation.cpp b/Marlin/src/HAL/HAL_DUE/EepromEmulation.cpp index c7b7007053..9263079358 100644 --- a/Marlin/src/HAL/HAL_DUE/EepromEmulation.cpp +++ b/Marlin/src/HAL/HAL_DUE/EepromEmulation.cpp @@ -1,3 +1,24 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ /* EEPROM emulation over flash with reduced wear * diff --git a/Marlin/src/gcode/calibrate/G425.cpp b/Marlin/src/gcode/calibrate/G425.cpp index c0a410fcc4..d2db4ce308 100644 --- a/Marlin/src/gcode/calibrate/G425.cpp +++ b/Marlin/src/gcode/calibrate/G425.cpp @@ -128,13 +128,15 @@ inline void park_above_object(measurements_t &m, const float uncertainty) { #endif inline bool read_calibration_pin() { - #if HAS_CALIBRATION_PIN - return (READ(CALIBRATION_PIN) != CALIBRATION_PIN_INVERTING); - #elif ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) - return (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING); - #else - return (READ(Z_MIN_PROBE_PIN) != Z_MIN_PROBE_ENDSTOP_INVERTING); - #endif + return ( + #if PIN_EXISTS(CALIBRATION) + READ(CALIBRATION_PIN) != CALIBRATION_PIN_INVERTING + #elif HAS_CUSTOM_PROBE_PIN + READ(Z_MIN_PROBE_PIN) != Z_MIN_PROBE_ENDSTOP_INVERTING + #else + READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING + #endif + ); } /** diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 3b8393dafe..ef7df41a1c 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -1443,7 +1443,6 @@ #define HAS_Z4_MIN (PIN_EXISTS(Z4_MIN)) #define HAS_Z4_MAX (PIN_EXISTS(Z4_MAX)) #define HAS_Z_MIN_PROBE_PIN (HAS_CUSTOM_PROBE_PIN && PIN_EXISTS(Z_MIN_PROBE)) -#define HAS_CALIBRATION_PIN (PIN_EXISTS(CALIBRATION)) // // ADC Temp Sensors (Thermistor or Thermocouple with amplifier ADC interface) diff --git a/Marlin/src/lcd/language/language_tr.h b/Marlin/src/lcd/language/language_tr.h index 5b7aeb9c56..5ddc72df17 100644 --- a/Marlin/src/lcd/language/language_tr.h +++ b/Marlin/src/lcd/language/language_tr.h @@ -1,4 +1,4 @@ - /** +/** * Marlin 3D Printer Firmware * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] * diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index 47ccc5d567..f3f73f3da1 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -256,7 +256,7 @@ void Endstops::init() { #endif #endif - #if HAS_CALIBRATION_PIN + #if PIN_EXISTS(CALIBRATION) #if ENABLED(CALIBRATION_PIN_PULLUP) SET_INPUT_PULLUP(CALIBRATION_PIN); #elif ENABLED(CALIBRATION_PIN_PULLDOWN) diff --git a/Marlin/src/pins/sam/pins_CNCONTROLS_15D.h b/Marlin/src/pins/sam/pins_CNCONTROLS_15D.h index 6238b82588..69fb2a3dfc 100644 --- a/Marlin/src/pins/sam/pins_CNCONTROLS_15D.h +++ b/Marlin/src/pins/sam/pins_CNCONTROLS_15D.h @@ -1,3 +1,25 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + /** * CNControls V15 for HMS434 with DUE pin assignments */ @@ -92,6 +114,10 @@ //#define PWM_2_PIN 13 //#define SPARE_IO 17 #define BEEPER_PIN 13 -#define CALIBRATION_PIN 66 #define STAT_LED_BLUE_PIN -1 #define STAT_LED_RED_PIN 31 + +// G425 CALIBRATION_GCODE default pin +#ifndef CALIBRATION_PIN + #define CALIBRATION_PIN 66 +#endif