2017-09-06 11:28:31 +00:00
|
|
|
/**
|
|
|
|
* Marlin 3D Printer Firmware
|
2019-06-28 04:57:50 +00:00
|
|
|
* Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
2017-09-06 11:28:31 +00:00
|
|
|
*
|
|
|
|
* Based on Sprinter and grbl.
|
2019-06-28 04:57:50 +00:00
|
|
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
2017-09-06 11:28:31 +00:00
|
|
|
*
|
|
|
|
* 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 <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2017-09-17 07:25:52 +00:00
|
|
|
#include "../../inc/MarlinConfig.h"
|
|
|
|
|
2019-02-06 10:59:22 +00:00
|
|
|
#if ENABLED(DELTA) || HAS_EXTRA_ENDSTOPS
|
2017-09-17 07:25:52 +00:00
|
|
|
|
|
|
|
#include "../gcode.h"
|
|
|
|
|
2017-09-06 11:28:31 +00:00
|
|
|
#if ENABLED(DELTA)
|
|
|
|
|
2017-09-17 07:25:52 +00:00
|
|
|
#include "../../module/delta.h"
|
|
|
|
#include "../../module/motion.h"
|
|
|
|
|
2019-03-14 07:25:42 +00:00
|
|
|
#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
#include "../../core/debug_out.h"
|
|
|
|
|
2017-09-06 11:28:31 +00:00
|
|
|
/**
|
|
|
|
* M666: Set delta endstop adjustment
|
|
|
|
*/
|
2017-09-17 07:25:52 +00:00
|
|
|
void GcodeSuite::M666() {
|
2019-03-14 07:25:42 +00:00
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM(">>> M666");
|
2017-09-06 11:28:31 +00:00
|
|
|
LOOP_XYZ(i) {
|
|
|
|
if (parser.seen(axis_codes[i])) {
|
2017-09-24 07:18:15 +00:00
|
|
|
const float v = parser.value_linear_units();
|
|
|
|
if (v * Z_HOME_DIR <= 0) delta_endstop_adj[i] = v;
|
2019-03-14 07:25:42 +00:00
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("delta_endstop_adj[", axis_codes[i], "] = ", delta_endstop_adj[i]);
|
2017-09-06 11:28:31 +00:00
|
|
|
}
|
|
|
|
}
|
2019-03-14 07:25:42 +00:00
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("<<< M666");
|
2017-09-06 11:28:31 +00:00
|
|
|
}
|
|
|
|
|
2019-02-06 10:59:22 +00:00
|
|
|
#elif HAS_EXTRA_ENDSTOPS
|
2017-09-06 11:28:31 +00:00
|
|
|
|
2017-09-18 10:56:10 +00:00
|
|
|
#include "../../module/endstops.h"
|
2017-09-17 07:25:52 +00:00
|
|
|
|
2017-09-06 11:28:31 +00:00
|
|
|
/**
|
2018-03-10 11:55:25 +00:00
|
|
|
* M666: Set Dual Endstops offsets for X, Y, and/or Z.
|
|
|
|
* With no parameters report current offsets.
|
2018-06-19 16:55:49 +00:00
|
|
|
*
|
2020-01-20 05:35:07 +00:00
|
|
|
* For Triple / Quad Z Endstops:
|
2018-06-19 16:55:49 +00:00
|
|
|
* Set Z2 Only: M666 S2 Z<offset>
|
|
|
|
* Set Z3 Only: M666 S3 Z<offset>
|
2020-01-20 05:35:07 +00:00
|
|
|
* Set Z4 Only: M666 S4 Z<offset>
|
|
|
|
* Set All: M666 Z<offset>
|
2017-09-06 11:28:31 +00:00
|
|
|
*/
|
2018-03-11 03:40:45 +00:00
|
|
|
void GcodeSuite::M666() {
|
2017-10-29 08:43:44 +00:00
|
|
|
#if ENABLED(X_DUAL_ENDSTOPS)
|
2018-11-03 06:16:37 +00:00
|
|
|
if (parser.seenval('X')) endstops.x2_endstop_adj = parser.value_linear_units();
|
2017-10-29 08:43:44 +00:00
|
|
|
#endif
|
|
|
|
#if ENABLED(Y_DUAL_ENDSTOPS)
|
2018-11-03 06:16:37 +00:00
|
|
|
if (parser.seenval('Y')) endstops.y2_endstop_adj = parser.value_linear_units();
|
2017-10-29 08:43:44 +00:00
|
|
|
#endif
|
2020-01-20 05:35:07 +00:00
|
|
|
#if ENABLED(Z_MULTI_ENDSTOPS)
|
2018-11-03 06:16:37 +00:00
|
|
|
if (parser.seenval('Z')) {
|
2020-01-20 05:35:07 +00:00
|
|
|
#if NUM_Z_STEPPER_DRIVERS >= 3
|
|
|
|
const float z_adj = parser.value_linear_units();
|
|
|
|
const int ind = parser.intval('S');
|
|
|
|
if (!ind || ind == 2) endstops.z2_endstop_adj = z_adj;
|
|
|
|
if (!ind || ind == 3) endstops.z3_endstop_adj = z_adj;
|
|
|
|
#if NUM_Z_STEPPER_DRIVERS >= 4
|
|
|
|
if (!ind || ind == 4) endstops.z4_endstop_adj = z_adj;
|
|
|
|
#endif
|
|
|
|
#else
|
|
|
|
endstops.z2_endstop_adj = parser.value_linear_units();
|
|
|
|
#endif
|
2018-06-19 16:55:49 +00:00
|
|
|
}
|
2017-10-29 08:43:44 +00:00
|
|
|
#endif
|
2018-11-03 06:16:37 +00:00
|
|
|
if (!parser.seen("XYZ")) {
|
2018-03-10 11:55:25 +00:00
|
|
|
SERIAL_ECHOPGM("Dual Endstop Adjustment (mm): ");
|
|
|
|
#if ENABLED(X_DUAL_ENDSTOPS)
|
2018-06-19 16:55:49 +00:00
|
|
|
SERIAL_ECHOPAIR(" X2:", endstops.x2_endstop_adj);
|
2018-03-10 11:55:25 +00:00
|
|
|
#endif
|
|
|
|
#if ENABLED(Y_DUAL_ENDSTOPS)
|
2018-06-19 16:55:49 +00:00
|
|
|
SERIAL_ECHOPAIR(" Y2:", endstops.y2_endstop_adj);
|
|
|
|
#endif
|
2020-01-20 05:35:07 +00:00
|
|
|
#if ENABLED(Z_MULTI_ENDSTOPS)
|
2020-02-02 03:00:53 +00:00
|
|
|
#define _ECHO_ZADJ(N) SERIAL_ECHOPAIR(" Z" STRINGIFY(N) ":", endstops.z##N##_endstop_adj);
|
|
|
|
REPEAT_S(2, INCREMENT(NUM_Z_STEPPER_DRIVERS), _ECHO_ZADJ)
|
2018-03-10 11:55:25 +00:00
|
|
|
#endif
|
|
|
|
SERIAL_EOL();
|
|
|
|
}
|
2017-09-06 11:28:31 +00:00
|
|
|
}
|
|
|
|
|
2019-02-06 10:59:22 +00:00
|
|
|
#endif // HAS_EXTRA_ENDSTOPS
|
2017-09-17 07:25:52 +00:00
|
|
|
|
2019-02-06 10:59:22 +00:00
|
|
|
#endif // DELTA || HAS_EXTRA_ENDSTOPS
|