|
@ -84,7 +84,7 @@ class TFilamentMonitor : public FilamentMonitorBase { |
|
|
response.filament_present(extruder); |
|
|
response.filament_present(extruder); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
#ifdef FILAMENT_RUNOUT_DISTANCE_MM |
|
|
#if HAS_FILAMENT_RUNOUT_DISTANCE |
|
|
static inline float& runout_distance() { return response.runout_distance_mm; } |
|
|
static inline float& runout_distance() { return response.runout_distance_mm; } |
|
|
static inline void set_runout_distance(const float &mm) { response.runout_distance_mm = mm; } |
|
|
static inline void set_runout_distance(const float &mm) { response.runout_distance_mm = mm; } |
|
|
#endif |
|
|
#endif |
|
@ -103,15 +103,11 @@ class TFilamentMonitor : public FilamentMonitorBase { |
|
|
if ( enabled && !filament_ran_out |
|
|
if ( enabled && !filament_ran_out |
|
|
&& (printingIsActive() || TERN0(ADVANCED_PAUSE_FEATURE, did_pause_print)) |
|
|
&& (printingIsActive() || TERN0(ADVANCED_PAUSE_FEATURE, did_pause_print)) |
|
|
) { |
|
|
) { |
|
|
#ifdef FILAMENT_RUNOUT_DISTANCE_MM |
|
|
TERN_(HAS_FILAMENT_RUNOUT_DISTANCE, cli()); // Prevent RunoutResponseDelayed::block_completed from accumulating here
|
|
|
cli(); // Prevent RunoutResponseDelayed::block_completed from accumulating here
|
|
|
|
|
|
#endif |
|
|
|
|
|
response.run(); |
|
|
response.run(); |
|
|
sensor.run(); |
|
|
sensor.run(); |
|
|
const bool ran_out = response.has_run_out(); |
|
|
const bool ran_out = response.has_run_out(); |
|
|
#ifdef FILAMENT_RUNOUT_DISTANCE_MM |
|
|
TERN_(HAS_FILAMENT_RUNOUT_DISTANCE, sei()); |
|
|
sei(); |
|
|
|
|
|
#endif |
|
|
|
|
|
if (ran_out) { |
|
|
if (ran_out) { |
|
|
filament_ran_out = true; |
|
|
filament_ran_out = true; |
|
|
event_filament_runout(); |
|
|
event_filament_runout(); |
|
@ -242,7 +238,7 @@ class FilamentSensorBase { |
|
|
|
|
|
|
|
|
/********************************* RESPONSE TYPE *********************************/ |
|
|
/********************************* RESPONSE TYPE *********************************/ |
|
|
|
|
|
|
|
|
#ifdef FILAMENT_RUNOUT_DISTANCE_MM |
|
|
#if HAS_FILAMENT_RUNOUT_DISTANCE |
|
|
|
|
|
|
|
|
// RunoutResponseDelayed triggers a runout event only if the length
|
|
|
// RunoutResponseDelayed triggers a runout event only if the length
|
|
|
// of filament specified by FILAMENT_RUNOUT_DISTANCE_MM has been fed
|
|
|
// of filament specified by FILAMENT_RUNOUT_DISTANCE_MM has been fed
|
|
@ -293,7 +289,7 @@ class FilamentSensorBase { |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
#else // !FILAMENT_RUNOUT_DISTANCE_MM
|
|
|
#else // !HAS_FILAMENT_RUNOUT_DISTANCE
|
|
|
|
|
|
|
|
|
// RunoutResponseDebounced triggers a runout event after a runout
|
|
|
// RunoutResponseDebounced triggers a runout event after a runout
|
|
|
// condition has been detected runout_threshold times in a row.
|
|
|
// condition has been detected runout_threshold times in a row.
|
|
@ -310,17 +306,13 @@ class FilamentSensorBase { |
|
|
static inline void filament_present(const uint8_t) { runout_count = runout_threshold; } |
|
|
static inline void filament_present(const uint8_t) { runout_count = runout_threshold; } |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
#endif // !FILAMENT_RUNOUT_DISTANCE_MM
|
|
|
#endif // !HAS_FILAMENT_RUNOUT_DISTANCE
|
|
|
|
|
|
|
|
|
/********************************* TEMPLATE SPECIALIZATION *********************************/ |
|
|
/********************************* TEMPLATE SPECIALIZATION *********************************/ |
|
|
|
|
|
|
|
|
typedef TFilamentMonitor< |
|
|
typedef TFilamentMonitor< |
|
|
#ifdef FILAMENT_RUNOUT_DISTANCE_MM |
|
|
TERN(HAS_FILAMENT_RUNOUT_DISTANCE, RunoutResponseDelayed, RunoutResponseDebounced), |
|
|
RunoutResponseDelayed, |
|
|
TERN(FILAMENT_MOTION_SENSOR, FilamentSensorEncoder, FilamentSensorSwitch) |
|
|
TERN(FILAMENT_MOTION_SENSOR, FilamentSensorEncoder, FilamentSensorSwitch) |
|
|
> FilamentMonitor; |
|
|
#else |
|
|
|
|
|
RunoutResponseDebounced, FilamentSensorSwitch |
|
|
|
|
|
#endif |
|
|
|
|
|
> FilamentMonitor; |
|
|
|
|
|
|
|
|
|
|
|
extern FilamentMonitor runout; |
|
|
extern FilamentMonitor runout; |
|
|