mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2024-11-24 20:43:32 +00:00
Default Filament Runout Sensor enabled state (#19013)
This commit is contained in:
parent
5a7979b435
commit
16c1e80491
@ -1178,10 +1178,11 @@
|
||||
*/
|
||||
//#define FILAMENT_RUNOUT_SENSOR
|
||||
#if ENABLED(FILAMENT_RUNOUT_SENSOR)
|
||||
#define NUM_RUNOUT_SENSORS 1 // Number of sensors, up to one per extruder. Define a FIL_RUNOUT#_PIN for each.
|
||||
#define FIL_RUNOUT_STATE LOW // Pin state indicating that filament is NOT present.
|
||||
#define FIL_RUNOUT_PULLUP // Use internal pullup for filament runout pins.
|
||||
//#define FIL_RUNOUT_PULLDOWN // Use internal pulldown for filament runout pins.
|
||||
#define FIL_RUNOUT_ENABLED_DEFAULT true // Enable the sensor on startup. Override with M412 followed by M500.
|
||||
#define NUM_RUNOUT_SENSORS 1 // Number of sensors, up to one per extruder. Define a FIL_RUNOUT#_PIN for each.
|
||||
#define FIL_RUNOUT_STATE LOW // Pin state indicating that filament is NOT present.
|
||||
#define FIL_RUNOUT_PULLUP // Use internal pullup for filament runout pins.
|
||||
//#define FIL_RUNOUT_PULLDOWN // Use internal pulldown for filament runout pins.
|
||||
|
||||
// Set one or more commands to execute on filament runout.
|
||||
// (After 'M412 H' Marlin will ask the host to handle the process.)
|
||||
|
@ -44,14 +44,6 @@ bool FilamentMonitorBase::enabled = true,
|
||||
#include "../module/tool_change.h"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Called by FilamentSensorSwitch::run when filament is detected.
|
||||
* Called by FilamentSensorEncoder::block_completed when motion is detected.
|
||||
*/
|
||||
void FilamentSensorBase::filament_present(const uint8_t extruder) {
|
||||
runout.filament_present(extruder); // calls response.filament_present(extruder)
|
||||
}
|
||||
|
||||
#if HAS_FILAMENT_RUNOUT_DISTANCE
|
||||
float RunoutResponseDelayed::runout_distance_mm = FILAMENT_RUNOUT_DISTANCE_MM;
|
||||
volatile float RunoutResponseDelayed::runout_mm_countdown[EXTRUDERS];
|
||||
|
@ -48,6 +48,24 @@
|
||||
|
||||
void event_filament_runout();
|
||||
|
||||
template<class RESPONSE_T, class SENSOR_T>
|
||||
class TFilamentMonitor;
|
||||
class FilamentSensorEncoder;
|
||||
class FilamentSensorSwitch;
|
||||
class RunoutResponseDelayed;
|
||||
class RunoutResponseDebounced;
|
||||
|
||||
/********************************* TEMPLATE SPECIALIZATION *********************************/
|
||||
|
||||
typedef TFilamentMonitor<
|
||||
TERN(HAS_FILAMENT_RUNOUT_DISTANCE, RunoutResponseDelayed, RunoutResponseDebounced),
|
||||
TERN(FILAMENT_MOTION_SENSOR, FilamentSensorEncoder, FilamentSensorSwitch)
|
||||
> FilamentMonitor;
|
||||
|
||||
extern FilamentMonitor runout;
|
||||
|
||||
/*******************************************************************************************/
|
||||
|
||||
class FilamentMonitorBase {
|
||||
public:
|
||||
static bool enabled, filament_ran_out;
|
||||
@ -121,7 +139,13 @@ class TFilamentMonitor : public FilamentMonitorBase {
|
||||
|
||||
class FilamentSensorBase {
|
||||
protected:
|
||||
static void filament_present(const uint8_t extruder);
|
||||
/**
|
||||
* Called by FilamentSensorSwitch::run when filament is detected.
|
||||
* Called by FilamentSensorEncoder::block_completed when motion is detected.
|
||||
*/
|
||||
static inline void filament_present(const uint8_t extruder) {
|
||||
runout.filament_present(extruder); // ...which calls response.filament_present(extruder)
|
||||
}
|
||||
|
||||
public:
|
||||
static inline void setup() {
|
||||
@ -311,12 +335,3 @@ class FilamentSensorBase {
|
||||
};
|
||||
|
||||
#endif // !HAS_FILAMENT_RUNOUT_DISTANCE
|
||||
|
||||
/********************************* TEMPLATE SPECIALIZATION *********************************/
|
||||
|
||||
typedef TFilamentMonitor<
|
||||
TERN(HAS_FILAMENT_RUNOUT_DISTANCE, RunoutResponseDelayed, RunoutResponseDebounced),
|
||||
TERN(FILAMENT_MOTION_SENSOR, FilamentSensorEncoder, FilamentSensorSwitch)
|
||||
> FilamentMonitor;
|
||||
|
||||
extern FilamentMonitor runout;
|
||||
|
@ -106,6 +106,9 @@
|
||||
|
||||
#if HAS_FILAMENT_SENSOR
|
||||
#include "../feature/runout.h"
|
||||
#ifndef FIL_RUNOUT_ENABLED_DEFAULT
|
||||
#define FIL_RUNOUT_ENABLED_DEFAULT true
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if ENABLED(EXTRA_LIN_ADVANCE_K)
|
||||
@ -646,15 +649,16 @@ void MarlinSettings::postprocess() {
|
||||
#if HAS_FILAMENT_SENSOR
|
||||
const bool &runout_sensor_enabled = runout.enabled;
|
||||
#else
|
||||
constexpr bool runout_sensor_enabled = true;
|
||||
constexpr int8_t runout_sensor_enabled = -1;
|
||||
#endif
|
||||
_FIELD_TEST(runout_sensor_enabled);
|
||||
EEPROM_WRITE(runout_sensor_enabled);
|
||||
|
||||
#if HAS_FILAMENT_RUNOUT_DISTANCE
|
||||
const float &runout_distance_mm = runout.runout_distance();
|
||||
#else
|
||||
constexpr float runout_distance_mm = 0;
|
||||
#endif
|
||||
_FIELD_TEST(runout_sensor_enabled);
|
||||
EEPROM_WRITE(runout_sensor_enabled);
|
||||
EEPROM_WRITE(runout_distance_mm);
|
||||
}
|
||||
|
||||
@ -1518,13 +1522,12 @@ void MarlinSettings::postprocess() {
|
||||
// Filament Runout Sensor
|
||||
//
|
||||
{
|
||||
#if HAS_FILAMENT_SENSOR
|
||||
const bool &runout_sensor_enabled = runout.enabled;
|
||||
#else
|
||||
bool runout_sensor_enabled;
|
||||
#endif
|
||||
int8_t runout_sensor_enabled;
|
||||
_FIELD_TEST(runout_sensor_enabled);
|
||||
EEPROM_READ(runout_sensor_enabled);
|
||||
#if HAS_FILAMENT_SENSOR
|
||||
runout.enabled = runout_sensor_enabled < 0 ? FIL_RUNOUT_ENABLED_DEFAULT : runout_sensor_enabled;
|
||||
#endif
|
||||
|
||||
TERN_(HAS_FILAMENT_SENSOR, if (runout.enabled) runout.reset());
|
||||
|
||||
@ -2476,7 +2479,7 @@ void MarlinSettings::reset() {
|
||||
//
|
||||
|
||||
#if HAS_FILAMENT_SENSOR
|
||||
runout.enabled = true;
|
||||
runout.enabled = FIL_RUNOUT_ENABLED_DEFAULT;
|
||||
runout.reset();
|
||||
TERN_(HAS_FILAMENT_RUNOUT_DISTANCE, runout.set_runout_distance(FILAMENT_RUNOUT_DISTANCE_MM));
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user