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

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