2017-09-06 13:28:31 +02:00
|
|
|
/**
|
|
|
|
* Marlin 3D Printer Firmware
|
2020-02-03 15:00:57 +01:00
|
|
|
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
2017-09-06 13:28:31 +02:00
|
|
|
*
|
|
|
|
* Based on Sprinter and grbl.
|
2019-06-28 06:57:50 +02:00
|
|
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
2017-09-06 13:28:31 +02:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2020-07-23 05:20:14 +02:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2017-09-06 13:28:31 +02:00
|
|
|
*
|
|
|
|
*/
|
2018-10-10 16:45:20 +02:00
|
|
|
#pragma once
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2021-03-04 03:48:05 +01:00
|
|
|
#include "../inc/MarlinConfig.h"
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2020-10-19 11:24:57 +02:00
|
|
|
//#define DEBUG_TOOLCHANGE_MIGRATION_FEATURE
|
|
|
|
|
2020-09-21 01:29:08 +02:00
|
|
|
#if HAS_MULTI_EXTRUDER
|
2018-10-17 18:11:41 +02:00
|
|
|
|
|
|
|
typedef struct {
|
2018-11-07 04:52:20 +01:00
|
|
|
#if ENABLED(TOOLCHANGE_FILAMENT_SWAP)
|
2022-04-10 07:24:07 +02:00
|
|
|
float swap_length; // M217 S
|
|
|
|
float extra_prime; // M217 E
|
|
|
|
float extra_resume; // M217 B
|
|
|
|
int16_t prime_speed; // M217 P
|
|
|
|
int16_t retract_speed; // M217 R
|
|
|
|
int16_t unretract_speed; // M217 U
|
|
|
|
uint8_t fan_speed; // M217 F
|
|
|
|
uint8_t fan_time; // M217 D
|
2020-04-23 04:03:28 +02:00
|
|
|
#endif
|
|
|
|
#if ENABLED(TOOLCHANGE_PARK)
|
2022-04-10 07:24:07 +02:00
|
|
|
bool enable_park; // M217 W
|
2022-04-29 22:21:15 +02:00
|
|
|
xyz_pos_t change_point; // M217 X Y I J K C H O
|
2018-11-07 04:52:20 +01:00
|
|
|
#endif
|
2022-04-10 07:24:07 +02:00
|
|
|
float z_raise; // M217 Z
|
2018-10-17 18:11:41 +02:00
|
|
|
} toolchange_settings_t;
|
|
|
|
|
|
|
|
extern toolchange_settings_t toolchange_settings;
|
|
|
|
|
2022-04-10 07:24:07 +02:00
|
|
|
#if ENABLED(TOOLCHANGE_FS_PRIME_FIRST_USED)
|
|
|
|
extern bool enable_first_prime; // M217 V
|
2020-04-23 04:03:28 +02:00
|
|
|
#endif
|
|
|
|
|
2022-04-10 07:24:07 +02:00
|
|
|
#if ENABLED(TOOLCHANGE_FILAMENT_SWAP)
|
|
|
|
void tool_change_prime(); // Prime the currently selected extruder
|
2020-04-23 04:03:28 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if ENABLED(TOOLCHANGE_FS_INIT_BEFORE_SWAP)
|
2022-04-03 23:14:02 +02:00
|
|
|
extern Flags<EXTRUDERS> toolchange_extruder_ready;
|
2020-04-23 04:03:28 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if ENABLED(TOOLCHANGE_MIGRATION_FEATURE)
|
|
|
|
typedef struct {
|
|
|
|
uint8_t target, last;
|
|
|
|
bool automode, in_progress;
|
|
|
|
} migration_settings_t;
|
|
|
|
constexpr migration_settings_t migration_defaults = { 0, 0, false, false };
|
|
|
|
extern migration_settings_t migration;
|
2020-06-28 04:57:01 +02:00
|
|
|
bool extruder_migration();
|
2020-04-23 04:03:28 +02:00
|
|
|
#endif
|
2018-10-17 18:11:41 +02:00
|
|
|
#endif
|
|
|
|
|
2018-05-18 20:16:59 +02:00
|
|
|
#if DO_SWITCH_EXTRUDER
|
2017-09-06 13:28:31 +02:00
|
|
|
void move_extruder_servo(const uint8_t e);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if ENABLED(SWITCHING_NOZZLE)
|
2019-02-04 07:19:56 +01:00
|
|
|
#if SWITCHING_NOZZLE_TWO_SERVOS
|
|
|
|
void lower_nozzle(const uint8_t e);
|
|
|
|
void raise_nozzle(const uint8_t e);
|
|
|
|
#else
|
|
|
|
void move_nozzle_servo(const uint8_t angle_index);
|
|
|
|
#endif
|
2017-09-06 13:28:31 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if ENABLED(PARKING_EXTRUDER)
|
|
|
|
|
2021-01-05 06:09:35 +01:00
|
|
|
void pe_solenoid_set_pin_state(const uint8_t extruder_num, const uint8_t state);
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2021-04-16 15:02:31 +02:00
|
|
|
#define PE_MAGNET_ON_STATE TERN_(PARKING_EXTRUDER_SOLENOIDS_INVERT, !)PARKING_EXTRUDER_SOLENOIDS_PINS_ACTIVE
|
2021-01-05 06:09:35 +01:00
|
|
|
inline void pe_solenoid_magnet_on(const uint8_t extruder_num) { pe_solenoid_set_pin_state(extruder_num, PE_MAGNET_ON_STATE); }
|
|
|
|
inline void pe_solenoid_magnet_off(const uint8_t extruder_num) { pe_solenoid_set_pin_state(extruder_num, !PE_MAGNET_ON_STATE); }
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2019-02-06 13:30:53 +01:00
|
|
|
void pe_solenoid_init();
|
2017-09-18 08:05:44 +02:00
|
|
|
|
2021-01-05 06:48:42 +01:00
|
|
|
extern bool extruder_parked;
|
|
|
|
inline void parking_extruder_set_parked(const bool parked) { extruder_parked = parked; }
|
2021-01-01 21:54:44 +01:00
|
|
|
bool parking_extruder_unpark_after_homing(const uint8_t final_tool, bool homed_towards_final_tool);
|
|
|
|
|
2019-02-06 13:30:53 +01:00
|
|
|
#elif ENABLED(MAGNETIC_PARKING_EXTRUDER)
|
|
|
|
|
|
|
|
typedef struct MPESettings {
|
2019-09-26 08:28:09 +02:00
|
|
|
float parking_xpos[2], // M951 L R
|
|
|
|
grab_distance; // M951 I
|
|
|
|
feedRate_t slow_feedrate, // M951 J
|
|
|
|
fast_feedrate; // M951 H
|
|
|
|
float travel_distance, // M951 D
|
|
|
|
compensation_factor; // M951 C
|
2019-02-06 13:30:53 +01:00
|
|
|
} mpe_settings_t;
|
|
|
|
|
|
|
|
extern mpe_settings_t mpe_settings;
|
|
|
|
|
|
|
|
void mpe_settings_init();
|
|
|
|
|
|
|
|
#endif
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2021-03-24 11:40:28 +01:00
|
|
|
#if ENABLED(ELECTROMAGNETIC_SWITCHING_TOOLHEAD)
|
|
|
|
void est_init();
|
|
|
|
#elif ENABLED(SWITCHING_TOOLHEAD)
|
|
|
|
void swt_init();
|
|
|
|
#endif
|
2020-03-08 22:13:41 +01:00
|
|
|
|
2021-04-16 15:02:31 +02:00
|
|
|
#if ENABLED(TOOL_SENSOR)
|
|
|
|
uint8_t check_tool_sensor_stats(const uint8_t active_tool, const bool kill_on_error=false, const bool disable=false);
|
|
|
|
#else
|
|
|
|
inline uint8_t check_tool_sensor_stats(const uint8_t, const bool=false, const bool=false) { return 0; }
|
|
|
|
#endif
|
|
|
|
|
2017-09-06 13:28:31 +02:00
|
|
|
/**
|
|
|
|
* Perform a tool-change, which may result in moving the
|
|
|
|
* previous tool out of the way and the new tool into place.
|
|
|
|
*/
|
2019-06-24 03:00:48 +02:00
|
|
|
void tool_change(const uint8_t tmp_extruder, bool no_move=false);
|