My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. *
  5. * Based on Sprinter and grbl.
  6. * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #include "../../inc/MarlinConfig.h"
  23. #if HAS_BED_PROBE
  24. #include "../gcode.h"
  25. #include "../../feature/bedlevel/bedlevel.h"
  26. #include "../../module/probe.h"
  27. extern const char SP_Y_STR[], SP_Z_STR[];
  28. /**
  29. * M851: Set the nozzle-to-probe offsets in current units
  30. */
  31. void GcodeSuite::M851() {
  32. // Show usage with no parameters
  33. if (!parser.seen("XYZ")) {
  34. SERIAL_ECHOLNPAIR_P(
  35. #if HAS_PROBE_XY_OFFSET
  36. PSTR(STR_PROBE_OFFSET " X"), probe.offset_xy.x, SP_Y_STR, probe.offset_xy.y, SP_Z_STR
  37. #else
  38. PSTR(STR_PROBE_OFFSET " X0 Y0 Z")
  39. #endif
  40. , probe.offset.z
  41. );
  42. return;
  43. }
  44. // Start with current offsets and modify
  45. xyz_pos_t offs = probe.offset;
  46. // Assume no errors
  47. bool ok = true;
  48. if (parser.seenval('X')) {
  49. const float x = parser.value_float();
  50. #if HAS_PROBE_XY_OFFSET
  51. if (WITHIN(x, -(X_BED_SIZE), X_BED_SIZE))
  52. offs.x = x;
  53. else {
  54. SERIAL_ECHOLNPAIR("?X out of range (-", int(X_BED_SIZE), " to ", int(X_BED_SIZE), ")");
  55. ok = false;
  56. }
  57. #else
  58. if (x) SERIAL_ECHOLNPAIR("?X must be 0 (NOZZLE_AS_PROBE)."); // ...but let 'ok' stay true
  59. #endif
  60. }
  61. if (parser.seenval('Y')) {
  62. const float y = parser.value_float();
  63. #if HAS_PROBE_XY_OFFSET
  64. if (WITHIN(y, -(Y_BED_SIZE), Y_BED_SIZE))
  65. offs.y = y;
  66. else {
  67. SERIAL_ECHOLNPAIR("?Y out of range (-", int(Y_BED_SIZE), " to ", int(Y_BED_SIZE), ")");
  68. ok = false;
  69. }
  70. #else
  71. if (y) SERIAL_ECHOLNPAIR("?Y must be 0 (NOZZLE_AS_PROBE)."); // ...but let 'ok' stay true
  72. #endif
  73. }
  74. if (parser.seenval('Z')) {
  75. const float z = parser.value_float();
  76. if (WITHIN(z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX))
  77. offs.z = z;
  78. else {
  79. SERIAL_ECHOLNPAIR("?Z out of range (", int(Z_PROBE_OFFSET_RANGE_MIN), " to ", int(Z_PROBE_OFFSET_RANGE_MAX), ")");
  80. ok = false;
  81. }
  82. }
  83. // Save the new offsets
  84. if (ok) probe.offset = offs;
  85. }
  86. #endif // HAS_BED_PROBE