mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2024-11-26 21:36:21 +00:00
🎨 Clean up tool change with tool sensor
This commit is contained in:
parent
e458aa41fc
commit
8ba6e8a74d
@ -385,65 +385,59 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0.
|
||||
|
||||
#endif // PARKING_EXTRUDER
|
||||
|
||||
#if ENABLED(SWITCHING_TOOLHEAD)
|
||||
#if ENABLED(TOOL_SENSOR)
|
||||
|
||||
bool tool_sensor_disabled; // = false
|
||||
|
||||
// Return a bitmask of tool sensor states
|
||||
inline uint8_t poll_tool_sensor_pins() {
|
||||
return (0
|
||||
#if ENABLED(TOOL_SENSOR)
|
||||
#if PIN_EXISTS(TOOL_SENSOR1)
|
||||
| (READ(TOOL_SENSOR1_PIN) << 0)
|
||||
#endif
|
||||
#if PIN_EXISTS(TOOL_SENSOR2)
|
||||
| (READ(TOOL_SENSOR2_PIN) << 1)
|
||||
#endif
|
||||
#if PIN_EXISTS(TOOL_SENSOR3)
|
||||
| (READ(TOOL_SENSOR3_PIN) << 2)
|
||||
#endif
|
||||
#if PIN_EXISTS(TOOL_SENSOR4)
|
||||
| (READ(TOOL_SENSOR4_PIN) << 3)
|
||||
#endif
|
||||
#if PIN_EXISTS(TOOL_SENSOR5)
|
||||
| (READ(TOOL_SENSOR5_PIN) << 4)
|
||||
#endif
|
||||
#if PIN_EXISTS(TOOL_SENSOR6)
|
||||
| (READ(TOOL_SENSOR6_PIN) << 5)
|
||||
#endif
|
||||
#if PIN_EXISTS(TOOL_SENSOR7)
|
||||
| (READ(TOOL_SENSOR7_PIN) << 6)
|
||||
#endif
|
||||
#if PIN_EXISTS(TOOL_SENSOR8)
|
||||
| (READ(TOOL_SENSOR8_PIN) << 7)
|
||||
#endif
|
||||
#if PIN_EXISTS(TOOL_SENSOR1)
|
||||
| (READ(TOOL_SENSOR1_PIN) << 0)
|
||||
#endif
|
||||
#if PIN_EXISTS(TOOL_SENSOR2)
|
||||
| (READ(TOOL_SENSOR2_PIN) << 1)
|
||||
#endif
|
||||
#if PIN_EXISTS(TOOL_SENSOR3)
|
||||
| (READ(TOOL_SENSOR3_PIN) << 2)
|
||||
#endif
|
||||
#if PIN_EXISTS(TOOL_SENSOR4)
|
||||
| (READ(TOOL_SENSOR4_PIN) << 3)
|
||||
#endif
|
||||
#if PIN_EXISTS(TOOL_SENSOR5)
|
||||
| (READ(TOOL_SENSOR5_PIN) << 4)
|
||||
#endif
|
||||
#if PIN_EXISTS(TOOL_SENSOR6)
|
||||
| (READ(TOOL_SENSOR6_PIN) << 5)
|
||||
#endif
|
||||
#if PIN_EXISTS(TOOL_SENSOR7)
|
||||
| (READ(TOOL_SENSOR7_PIN) << 6)
|
||||
#endif
|
||||
#if PIN_EXISTS(TOOL_SENSOR8)
|
||||
| (READ(TOOL_SENSOR8_PIN) << 7)
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
#if ENABLED(TOOL_SENSOR)
|
||||
|
||||
bool tool_sensor_disabled; // = false
|
||||
|
||||
uint8_t check_tool_sensor_stats(const uint8_t tool_index, const bool kill_on_error/*=false*/, const bool disable/*=false*/) {
|
||||
static uint8_t sensor_tries; // = 0
|
||||
for (;;) {
|
||||
if (poll_tool_sensor_pins() == _BV(tool_index)) {
|
||||
sensor_tries = 0;
|
||||
return tool_index;
|
||||
}
|
||||
else if (kill_on_error && (!tool_sensor_disabled || disable)) {
|
||||
sensor_tries++;
|
||||
if (sensor_tries > 10) kill(F("Tool Sensor error"));
|
||||
safe_delay(5);
|
||||
}
|
||||
else {
|
||||
sensor_tries++;
|
||||
if (sensor_tries > 10) return -1;
|
||||
safe_delay(5);
|
||||
}
|
||||
uint8_t check_tool_sensor_stats(const uint8_t tool_index, const bool kill_on_error/*=false*/, const bool disable/*=false*/) {
|
||||
static uint8_t sensor_tries; // = 0
|
||||
for (;;) {
|
||||
if (poll_tool_sensor_pins() == _BV(tool_index)) {
|
||||
sensor_tries = 0;
|
||||
return tool_index;
|
||||
}
|
||||
else if (kill_on_error && (!tool_sensor_disabled || disable)) {
|
||||
sensor_tries++;
|
||||
if (sensor_tries > 10) kill(F("Tool Sensor error"));
|
||||
safe_delay(5);
|
||||
}
|
||||
else {
|
||||
sensor_tries++;
|
||||
if (sensor_tries > 10) return -1;
|
||||
safe_delay(5);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void switching_toolhead_lock(const bool locked) {
|
||||
#ifdef SWITCHING_TOOLHEAD_SERVO_ANGLES
|
||||
@ -496,9 +490,13 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0.
|
||||
switching_toolhead_lock(true);
|
||||
}
|
||||
LCD_MESSAGE_F("TC Success");
|
||||
#endif
|
||||
#endif // TOOL_SENSOR
|
||||
}
|
||||
|
||||
#endif // TOOL_SENSOR
|
||||
|
||||
#if ENABLED(SWITCHING_TOOLHEAD)
|
||||
|
||||
inline void switching_toolhead_tool_change(const uint8_t new_tool, bool no_move/*=false*/) {
|
||||
if (no_move) return;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user