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

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