|
@@ -385,65 +385,59 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0.
|
385
|
385
|
|
386
|
386
|
#endif // PARKING_EXTRUDER
|
387
|
387
|
|
388
|
|
-#if ENABLED(SWITCHING_TOOLHEAD)
|
|
388
|
+#if ENABLED(TOOL_SENSOR)
|
|
389
|
+
|
|
390
|
+ bool tool_sensor_disabled; // = false
|
389
|
391
|
|
390
|
392
|
// Return a bitmask of tool sensor states
|
391
|
393
|
inline uint8_t poll_tool_sensor_pins() {
|
392
|
394
|
return (0
|
393
|
|
- #if ENABLED(TOOL_SENSOR)
|
394
|
|
- #if PIN_EXISTS(TOOL_SENSOR1)
|
395
|
|
- | (READ(TOOL_SENSOR1_PIN) << 0)
|
396
|
|
- #endif
|
397
|
|
- #if PIN_EXISTS(TOOL_SENSOR2)
|
398
|
|
- | (READ(TOOL_SENSOR2_PIN) << 1)
|
399
|
|
- #endif
|
400
|
|
- #if PIN_EXISTS(TOOL_SENSOR3)
|
401
|
|
- | (READ(TOOL_SENSOR3_PIN) << 2)
|
402
|
|
- #endif
|
403
|
|
- #if PIN_EXISTS(TOOL_SENSOR4)
|
404
|
|
- | (READ(TOOL_SENSOR4_PIN) << 3)
|
405
|
|
- #endif
|
406
|
|
- #if PIN_EXISTS(TOOL_SENSOR5)
|
407
|
|
- | (READ(TOOL_SENSOR5_PIN) << 4)
|
408
|
|
- #endif
|
409
|
|
- #if PIN_EXISTS(TOOL_SENSOR6)
|
410
|
|
- | (READ(TOOL_SENSOR6_PIN) << 5)
|
411
|
|
- #endif
|
412
|
|
- #if PIN_EXISTS(TOOL_SENSOR7)
|
413
|
|
- | (READ(TOOL_SENSOR7_PIN) << 6)
|
414
|
|
- #endif
|
415
|
|
- #if PIN_EXISTS(TOOL_SENSOR8)
|
416
|
|
- | (READ(TOOL_SENSOR8_PIN) << 7)
|
417
|
|
- #endif
|
|
395
|
+ #if PIN_EXISTS(TOOL_SENSOR1)
|
|
396
|
+ | (READ(TOOL_SENSOR1_PIN) << 0)
|
|
397
|
+ #endif
|
|
398
|
+ #if PIN_EXISTS(TOOL_SENSOR2)
|
|
399
|
+ | (READ(TOOL_SENSOR2_PIN) << 1)
|
|
400
|
+ #endif
|
|
401
|
+ #if PIN_EXISTS(TOOL_SENSOR3)
|
|
402
|
+ | (READ(TOOL_SENSOR3_PIN) << 2)
|
|
403
|
+ #endif
|
|
404
|
+ #if PIN_EXISTS(TOOL_SENSOR4)
|
|
405
|
+ | (READ(TOOL_SENSOR4_PIN) << 3)
|
|
406
|
+ #endif
|
|
407
|
+ #if PIN_EXISTS(TOOL_SENSOR5)
|
|
408
|
+ | (READ(TOOL_SENSOR5_PIN) << 4)
|
|
409
|
+ #endif
|
|
410
|
+ #if PIN_EXISTS(TOOL_SENSOR6)
|
|
411
|
+ | (READ(TOOL_SENSOR6_PIN) << 5)
|
|
412
|
+ #endif
|
|
413
|
+ #if PIN_EXISTS(TOOL_SENSOR7)
|
|
414
|
+ | (READ(TOOL_SENSOR7_PIN) << 6)
|
|
415
|
+ #endif
|
|
416
|
+ #if PIN_EXISTS(TOOL_SENSOR8)
|
|
417
|
+ | (READ(TOOL_SENSOR8_PIN) << 7)
|
418
|
418
|
#endif
|
419
|
419
|
);
|
420
|
420
|
}
|
421
|
421
|
|
422
|
|
- #if ENABLED(TOOL_SENSOR)
|
423
|
|
-
|
424
|
|
- bool tool_sensor_disabled; // = false
|
425
|
|
-
|
426
|
|
- uint8_t check_tool_sensor_stats(const uint8_t tool_index, const bool kill_on_error/*=false*/, const bool disable/*=false*/) {
|
427
|
|
- static uint8_t sensor_tries; // = 0
|
428
|
|
- for (;;) {
|
429
|
|
- if (poll_tool_sensor_pins() == _BV(tool_index)) {
|
430
|
|
- sensor_tries = 0;
|
431
|
|
- return tool_index;
|
432
|
|
- }
|
433
|
|
- else if (kill_on_error && (!tool_sensor_disabled || disable)) {
|
434
|
|
- sensor_tries++;
|
435
|
|
- if (sensor_tries > 10) kill(F("Tool Sensor error"));
|
436
|
|
- safe_delay(5);
|
437
|
|
- }
|
438
|
|
- else {
|
439
|
|
- sensor_tries++;
|
440
|
|
- if (sensor_tries > 10) return -1;
|
441
|
|
- safe_delay(5);
|
442
|
|
- }
|
|
422
|
+ uint8_t check_tool_sensor_stats(const uint8_t tool_index, const bool kill_on_error/*=false*/, const bool disable/*=false*/) {
|
|
423
|
+ static uint8_t sensor_tries; // = 0
|
|
424
|
+ for (;;) {
|
|
425
|
+ if (poll_tool_sensor_pins() == _BV(tool_index)) {
|
|
426
|
+ sensor_tries = 0;
|
|
427
|
+ return tool_index;
|
|
428
|
+ }
|
|
429
|
+ else if (kill_on_error && (!tool_sensor_disabled || disable)) {
|
|
430
|
+ sensor_tries++;
|
|
431
|
+ if (sensor_tries > 10) kill(F("Tool Sensor error"));
|
|
432
|
+ safe_delay(5);
|
|
433
|
+ }
|
|
434
|
+ else {
|
|
435
|
+ sensor_tries++;
|
|
436
|
+ if (sensor_tries > 10) return -1;
|
|
437
|
+ safe_delay(5);
|
443
|
438
|
}
|
444
|
439
|
}
|
445
|
|
-
|
446
|
|
- #endif
|
|
440
|
+ }
|
447
|
441
|
|
448
|
442
|
inline void switching_toolhead_lock(const bool locked) {
|
449
|
443
|
#ifdef SWITCHING_TOOLHEAD_SERVO_ANGLES
|
|
@@ -496,9 +490,13 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0.
|
496
|
490
|
switching_toolhead_lock(true);
|
497
|
491
|
}
|
498
|
492
|
LCD_MESSAGE_F("TC Success");
|
499
|
|
- #endif
|
|
493
|
+ #endif // TOOL_SENSOR
|
500
|
494
|
}
|
501
|
495
|
|
|
496
|
+#endif // TOOL_SENSOR
|
|
497
|
+
|
|
498
|
+#if ENABLED(SWITCHING_TOOLHEAD)
|
|
499
|
+
|
502
|
500
|
inline void switching_toolhead_tool_change(const uint8_t new_tool, bool no_move/*=false*/) {
|
503
|
501
|
if (no_move) return;
|
504
|
502
|
|