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.

tool_change.h 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. #pragma once
  23. #include "../inc/MarlinConfig.h"
  24. //#define DEBUG_TOOLCHANGE_MIGRATION_FEATURE
  25. #if HAS_MULTI_EXTRUDER
  26. typedef struct {
  27. #if ENABLED(TOOLCHANGE_FILAMENT_SWAP)
  28. float swap_length; // M217 S
  29. float extra_prime; // M217 E
  30. float extra_resume; // M217 B
  31. int16_t prime_speed; // M217 P
  32. int16_t retract_speed; // M217 R
  33. int16_t unretract_speed; // M217 U
  34. uint8_t fan_speed; // M217 F
  35. uint8_t fan_time; // M217 D
  36. #endif
  37. #if ENABLED(TOOLCHANGE_PARK)
  38. bool enable_park; // M217 W
  39. xyz_pos_t change_point; // M217 X Y I J K C H O
  40. #endif
  41. float z_raise; // M217 Z
  42. } toolchange_settings_t;
  43. extern toolchange_settings_t toolchange_settings;
  44. #if ENABLED(TOOLCHANGE_FS_PRIME_FIRST_USED)
  45. extern bool enable_first_prime; // M217 V
  46. #endif
  47. #if ENABLED(TOOLCHANGE_FILAMENT_SWAP)
  48. void tool_change_prime(); // Prime the currently selected extruder
  49. #endif
  50. #if ENABLED(TOOLCHANGE_FS_INIT_BEFORE_SWAP)
  51. extern Flags<EXTRUDERS> toolchange_extruder_ready;
  52. #endif
  53. #if ENABLED(TOOLCHANGE_MIGRATION_FEATURE)
  54. typedef struct {
  55. uint8_t target, last;
  56. bool automode, in_progress;
  57. } migration_settings_t;
  58. constexpr migration_settings_t migration_defaults = { 0, 0, false, false };
  59. extern migration_settings_t migration;
  60. bool extruder_migration();
  61. #endif
  62. #endif
  63. #if DO_SWITCH_EXTRUDER
  64. void move_extruder_servo(const uint8_t e);
  65. #endif
  66. #if ENABLED(SWITCHING_NOZZLE)
  67. #if SWITCHING_NOZZLE_TWO_SERVOS
  68. void lower_nozzle(const uint8_t e);
  69. void raise_nozzle(const uint8_t e);
  70. #else
  71. void move_nozzle_servo(const uint8_t angle_index);
  72. #endif
  73. #endif
  74. #if ENABLED(PARKING_EXTRUDER)
  75. void pe_solenoid_set_pin_state(const uint8_t extruder_num, const uint8_t state);
  76. #define PE_MAGNET_ON_STATE TERN_(PARKING_EXTRUDER_SOLENOIDS_INVERT, !)PARKING_EXTRUDER_SOLENOIDS_PINS_ACTIVE
  77. inline void pe_solenoid_magnet_on(const uint8_t extruder_num) { pe_solenoid_set_pin_state(extruder_num, PE_MAGNET_ON_STATE); }
  78. inline void pe_solenoid_magnet_off(const uint8_t extruder_num) { pe_solenoid_set_pin_state(extruder_num, !PE_MAGNET_ON_STATE); }
  79. void pe_solenoid_init();
  80. extern bool extruder_parked;
  81. inline void parking_extruder_set_parked(const bool parked) { extruder_parked = parked; }
  82. bool parking_extruder_unpark_after_homing(const uint8_t final_tool, bool homed_towards_final_tool);
  83. #elif ENABLED(MAGNETIC_PARKING_EXTRUDER)
  84. typedef struct MPESettings {
  85. float parking_xpos[2], // M951 L R
  86. grab_distance; // M951 I
  87. feedRate_t slow_feedrate, // M951 J
  88. fast_feedrate; // M951 H
  89. float travel_distance, // M951 D
  90. compensation_factor; // M951 C
  91. } mpe_settings_t;
  92. extern mpe_settings_t mpe_settings;
  93. void mpe_settings_init();
  94. #endif
  95. #if ENABLED(ELECTROMAGNETIC_SWITCHING_TOOLHEAD)
  96. void est_init();
  97. #elif ENABLED(SWITCHING_TOOLHEAD)
  98. void swt_init();
  99. #endif
  100. #if ENABLED(TOOL_SENSOR)
  101. uint8_t check_tool_sensor_stats(const uint8_t active_tool, const bool kill_on_error=false, const bool disable=false);
  102. #else
  103. inline uint8_t check_tool_sensor_stats(const uint8_t, const bool=false, const bool=false) { return 0; }
  104. #endif
  105. /**
  106. * Perform a tool-change, which may result in moving the
  107. * previous tool out of the way and the new tool into place.
  108. */
  109. void tool_change(const uint8_t tmp_extruder, bool no_move=false);