My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

M206_M428.cpp 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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_M206_COMMAND
  24. #include "../gcode.h"
  25. #include "../../module/motion.h"
  26. #include "../../lcd/ultralcd.h"
  27. #include "../../libs/buzzer.h"
  28. /**
  29. * M206: Set Additional Homing Offset (X Y Z). SCARA aliases T=X, P=Y
  30. *
  31. * *** @thinkyhead: I recommend deprecating M206 for SCARA in favor of M665.
  32. * *** M206 for SCARA will remain enabled in 1.1.x for compatibility.
  33. * *** In the 2.0 release, it will simply be disabled by default.
  34. */
  35. void GcodeSuite::M206() {
  36. LOOP_XYZ(i)
  37. if (parser.seen(axis_codes[i]))
  38. set_home_offset((AxisEnum)i, parser.value_linear_units());
  39. #if ENABLED(MORGAN_SCARA)
  40. if (parser.seen('T')) set_home_offset(A_AXIS, parser.value_float()); // Theta
  41. if (parser.seen('P')) set_home_offset(B_AXIS, parser.value_float()); // Psi
  42. #endif
  43. report_current_position();
  44. }
  45. /**
  46. * M428: Set home_offset based on the distance between the
  47. * current_position and the nearest "reference point."
  48. * If an axis is past center its endstop position
  49. * is the reference-point. Otherwise it uses 0. This allows
  50. * the Z offset to be set near the bed when using a max endstop.
  51. *
  52. * M428 can't be used more than 2cm away from 0 or an endstop.
  53. *
  54. * Use M206 to set these values directly.
  55. */
  56. void GcodeSuite::M428() {
  57. if (axis_unhomed_error()) return;
  58. xyz_float_t diff;
  59. LOOP_XYZ(i) {
  60. diff[i] = base_home_pos((AxisEnum)i) - current_position[i];
  61. if (!WITHIN(diff[i], -20, 20) && home_dir((AxisEnum)i) > 0)
  62. diff[i] = -current_position[i];
  63. if (!WITHIN(diff[i], -20, 20)) {
  64. SERIAL_ERROR_MSG(STR_ERR_M428_TOO_FAR);
  65. LCD_ALERTMESSAGEPGM_P(PSTR("Err: Too far!"));
  66. BUZZ(200, 40);
  67. return;
  68. }
  69. }
  70. LOOP_XYZ(i) set_home_offset((AxisEnum)i, diff[i]);
  71. report_current_position();
  72. LCD_MESSAGEPGM(MSG_HOME_OFFSETS_APPLIED);
  73. BUZZ(100, 659);
  74. BUZZ(100, 698);
  75. }
  76. #endif // HAS_M206_COMMAND