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.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2019 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/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_START(); SERIAL_ECHOLNPAIR("L: Left parking :", mpe_settings.parking_xpos[0]);
  31. SERIAL_ECHO_START(); SERIAL_ECHOLNPAIR("R: Right parking :", mpe_settings.parking_xpos[1]);
  32. SERIAL_ECHO_START(); SERIAL_ECHOLNPAIR("I: Grab Offset :", mpe_settings.grab_distance);
  33. SERIAL_ECHO_START(); SERIAL_ECHOLNPAIR("J: Normal speed :", long(MMS_TO_MMM(mpe_settings.slow_feedrate)));
  34. SERIAL_ECHO_START(); SERIAL_ECHOLNPAIR("H: High speed :", long(MMS_TO_MMM(mpe_settings.fast_feedrate)));
  35. SERIAL_ECHO_START(); SERIAL_ECHOLNPAIR("D: Distance trav.:", mpe_settings.travel_distance);
  36. SERIAL_ECHO_START(); SERIAL_ECHOLNPAIR("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. #if HAS_HOME_OFFSET
  44. set_home_offset(X_AXIS, mpe_settings.grab_distance * -1);
  45. #endif
  46. mpe_settings.slow_feedrate = MMM_TO_MMS(MPE_SLOW_SPEED); // M951 J
  47. mpe_settings.fast_feedrate = MMM_TO_MMS(MPE_FAST_SPEED); // M951 H
  48. mpe_settings.travel_distance = MPE_TRAVEL_DISTANCE; // M951 D
  49. mpe_settings.compensation_factor = MPE_COMPENSATION; // M951 C
  50. mpe_settings_report();
  51. }
  52. void GcodeSuite::M951() {
  53. if (parser.seenval('L')) mpe_settings.parking_xpos[0] = parser.value_linear_units();
  54. if (parser.seenval('R')) mpe_settings.parking_xpos[1] = parser.value_linear_units();
  55. if (parser.seenval('I')) {
  56. mpe_settings.grab_distance = parser.value_linear_units();
  57. #if HAS_HOME_OFFSET
  58. set_home_offset(X_AXIS, mpe_settings.grab_distance * -1);
  59. #endif
  60. }
  61. if (parser.seenval('J')) mpe_settings.slow_feedrate = MMM_TO_MMS(parser.value_linear_units());
  62. if (parser.seenval('H')) mpe_settings.fast_feedrate = MMM_TO_MMS(parser.value_linear_units());
  63. if (parser.seenval('D')) mpe_settings.travel_distance = parser.value_linear_units();
  64. if (parser.seenval('C')) mpe_settings.compensation_factor = parser.value_float();
  65. if (!parser.seen("CDHIJLR")) mpe_settings_report();
  66. }
  67. #endif // MAGNETIC_PARKING_EXTRUDER