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.

M951.cpp 3.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 <https://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #include "../../inc/MarlinConfigPre.h"
  23. #if ENABLED(MAGNETIC_PARKING_EXTRUDER)
  24. #include "../gcode.h"
  25. #include "../../module/tool_change.h"
  26. #include "../../module/motion.h"
  27. mpe_settings_t mpe_settings;
  28. inline void mpe_settings_report() {
  29. SERIAL_ECHO_MSG("Magnetic Parking Extruder");
  30. SERIAL_ECHO_MSG("L: Left parking :", mpe_settings.parking_xpos[0]);
  31. SERIAL_ECHO_MSG("R: Right parking :", mpe_settings.parking_xpos[1]);
  32. SERIAL_ECHO_MSG("I: Grab Offset :", mpe_settings.grab_distance);
  33. SERIAL_ECHO_MSG("J: Normal speed :", long(MMS_TO_MMM(mpe_settings.slow_feedrate)));
  34. SERIAL_ECHO_MSG("H: High speed :", long(MMS_TO_MMM(mpe_settings.fast_feedrate)));
  35. SERIAL_ECHO_MSG("D: Distance trav.:", mpe_settings.travel_distance);
  36. SERIAL_ECHO_MSG("C: Compenstion :", mpe_settings.compensation_factor);
  37. }
  38. void mpe_settings_init() {
  39. constexpr float pex[2] = PARKING_EXTRUDER_PARKING_X;
  40. mpe_settings.parking_xpos[0] = pex[0]; // M951 L
  41. mpe_settings.parking_xpos[1] = pex[1]; // M951 R
  42. mpe_settings.grab_distance = PARKING_EXTRUDER_GRAB_DISTANCE; // M951 I
  43. TERN_(HAS_HOME_OFFSET, set_home_offset(X_AXIS, mpe_settings.grab_distance * -1));
  44. mpe_settings.slow_feedrate = MMM_TO_MMS(MPE_SLOW_SPEED); // M951 J
  45. mpe_settings.fast_feedrate = MMM_TO_MMS(MPE_FAST_SPEED); // M951 H
  46. mpe_settings.travel_distance = MPE_TRAVEL_DISTANCE; // M951 D
  47. mpe_settings.compensation_factor = MPE_COMPENSATION; // M951 C
  48. mpe_settings_report();
  49. }
  50. void GcodeSuite::M951() {
  51. if (parser.seenval('L')) mpe_settings.parking_xpos[0] = parser.value_linear_units();
  52. if (parser.seenval('R')) mpe_settings.parking_xpos[1] = parser.value_linear_units();
  53. if (parser.seenval('I')) {
  54. mpe_settings.grab_distance = parser.value_linear_units();
  55. TERN_(HAS_HOME_OFFSET, set_home_offset(X_AXIS, mpe_settings.grab_distance * -1));
  56. }
  57. if (parser.seenval('J')) mpe_settings.slow_feedrate = MMM_TO_MMS(parser.value_linear_units());
  58. if (parser.seenval('H')) mpe_settings.fast_feedrate = MMM_TO_MMS(parser.value_linear_units());
  59. if (parser.seenval('D')) mpe_settings.travel_distance = parser.value_linear_units();
  60. if (parser.seenval('C')) mpe_settings.compensation_factor = parser.value_float();
  61. if (!parser.seen("CDHIJLR")) mpe_settings_report();
  62. }
  63. #endif // MAGNETIC_PARKING_EXTRUDER