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.

M217.cpp 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 EXTRUDERS > 1
  24. #include "../gcode.h"
  25. #include "../../module/tool_change.h"
  26. void M217_report(const bool eeprom=false) {
  27. #if ENABLED(TOOLCHANGE_FILAMENT_SWAP)
  28. serialprintPGM(eeprom ? PSTR(" M217") : PSTR("Toolchange:"));
  29. SERIAL_ECHOPAIR(" S", LINEAR_UNIT(toolchange_settings.swap_length));
  30. SERIAL_ECHOPAIR(" E", LINEAR_UNIT(toolchange_settings.extra_prime));
  31. SERIAL_ECHOPAIR(" P", LINEAR_UNIT(toolchange_settings.prime_speed));
  32. SERIAL_ECHOPAIR(" R", LINEAR_UNIT(toolchange_settings.retract_speed));
  33. #if ENABLED(TOOLCHANGE_PARK)
  34. SERIAL_ECHOPAIR(" X", LINEAR_UNIT(toolchange_settings.change_point.x));
  35. SERIAL_ECHOPAIR(" Y", LINEAR_UNIT(toolchange_settings.change_point.y));
  36. #endif
  37. #else
  38. UNUSED(eeprom);
  39. #endif
  40. SERIAL_ECHOPAIR(" Z", LINEAR_UNIT(toolchange_settings.z_raise));
  41. SERIAL_EOL();
  42. }
  43. /**
  44. * M217 - Set SINGLENOZZLE toolchange parameters
  45. *
  46. * S[linear] Swap length
  47. * E[linear] Purge length
  48. * P[linear/m] Prime speed
  49. * R[linear/m] Retract speed
  50. * X[linear] Park X (Requires TOOLCHANGE_PARK)
  51. * Y[linear] Park Y (Requires TOOLCHANGE_PARK)
  52. * Z[linear] Z Raise
  53. */
  54. void GcodeSuite::M217() {
  55. #define SPR_PARAM
  56. #define XY_PARAM
  57. #if ENABLED(TOOLCHANGE_FILAMENT_SWAP)
  58. #undef SPR_PARAM
  59. #define SPR_PARAM "SPRE"
  60. static constexpr float max_extrude =
  61. #if ENABLED(PREVENT_LENGTHY_EXTRUDE)
  62. EXTRUDE_MAXLENGTH
  63. #else
  64. 500
  65. #endif
  66. ;
  67. if (parser.seenval('S')) { const float v = parser.value_linear_units(); toolchange_settings.swap_length = constrain(v, 0, max_extrude); }
  68. if (parser.seenval('E')) { const float v = parser.value_linear_units(); toolchange_settings.extra_prime = constrain(v, 0, max_extrude); }
  69. if (parser.seenval('P')) { const int16_t v = parser.value_linear_units(); toolchange_settings.prime_speed = constrain(v, 10, 5400); }
  70. if (parser.seenval('R')) { const int16_t v = parser.value_linear_units(); toolchange_settings.retract_speed = constrain(v, 10, 5400); }
  71. #endif
  72. #if ENABLED(TOOLCHANGE_PARK)
  73. #undef XY_PARAM
  74. #define XY_PARAM "XY"
  75. if (parser.seenval('X')) { toolchange_settings.change_point.x = parser.value_linear_units(); }
  76. if (parser.seenval('Y')) { toolchange_settings.change_point.y = parser.value_linear_units(); }
  77. #endif
  78. if (parser.seenval('Z')) { toolchange_settings.z_raise = parser.value_linear_units(); }
  79. if (!parser.seen(SPR_PARAM XY_PARAM "Z")) M217_report();
  80. }
  81. #endif // EXTRUDERS > 1