mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2024-11-28 14:24:34 +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
|
//#define FILAMENT_RUNOUT_SENSOR
|
||||||
#if ENABLED(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_ENABLED_DEFAULT true // Enable the sensor on startup. Override with M412 followed by M500.
|
||||||
#define FIL_RUNOUT_STATE LOW // Pin state indicating that filament is NOT present.
|
#define NUM_RUNOUT_SENSORS 1 // Number of sensors, up to one per extruder. Define a FIL_RUNOUT#_PIN for each.
|
||||||
#define FIL_RUNOUT_PULLUP // Use internal pullup for filament runout pins.
|
#define FIL_RUNOUT_STATE LOW // Pin state indicating that filament is NOT present.
|
||||||
//#define FIL_RUNOUT_PULLDOWN // Use internal pulldown for filament runout pins.
|
#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.
|
// Set one or more commands to execute on filament runout.
|
||||||
// (After 'M412 H' Marlin will ask the host to handle the process.)
|
// (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"
|
#include "../module/tool_change.h"
|
||||||
#endif
|
#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
|
#if HAS_FILAMENT_RUNOUT_DISTANCE
|
||||||
float RunoutResponseDelayed::runout_distance_mm = FILAMENT_RUNOUT_DISTANCE_MM;
|
float RunoutResponseDelayed::runout_distance_mm = FILAMENT_RUNOUT_DISTANCE_MM;
|
||||||
volatile float RunoutResponseDelayed::runout_mm_countdown[EXTRUDERS];
|
volatile float RunoutResponseDelayed::runout_mm_countdown[EXTRUDERS];
|
||||||
|
@ -48,6 +48,24 @@
|
|||||||
|
|
||||||
void event_filament_runout();
|
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 {
|
class FilamentMonitorBase {
|
||||||
public:
|
public:
|
||||||
static bool enabled, filament_ran_out;
|
static bool enabled, filament_ran_out;
|
||||||
@ -121,7 +139,13 @@ class TFilamentMonitor : public FilamentMonitorBase {
|
|||||||
|
|
||||||
class FilamentSensorBase {
|
class FilamentSensorBase {
|
||||||
protected:
|
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:
|
public:
|
||||||
static inline void setup() {
|
static inline void setup() {
|
||||||
@ -311,12 +335,3 @@ class FilamentSensorBase {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#endif // !HAS_FILAMENT_RUNOUT_DISTANCE
|
#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
|
#if HAS_FILAMENT_SENSOR
|
||||||
#include "../feature/runout.h"
|
#include "../feature/runout.h"
|
||||||
|
#ifndef FIL_RUNOUT_ENABLED_DEFAULT
|
||||||
|
#define FIL_RUNOUT_ENABLED_DEFAULT true
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ENABLED(EXTRA_LIN_ADVANCE_K)
|
#if ENABLED(EXTRA_LIN_ADVANCE_K)
|
||||||
@ -646,15 +649,16 @@ void MarlinSettings::postprocess() {
|
|||||||
#if HAS_FILAMENT_SENSOR
|
#if HAS_FILAMENT_SENSOR
|
||||||
const bool &runout_sensor_enabled = runout.enabled;
|
const bool &runout_sensor_enabled = runout.enabled;
|
||||||
#else
|
#else
|
||||||
constexpr bool runout_sensor_enabled = true;
|
constexpr int8_t runout_sensor_enabled = -1;
|
||||||
#endif
|
#endif
|
||||||
|
_FIELD_TEST(runout_sensor_enabled);
|
||||||
|
EEPROM_WRITE(runout_sensor_enabled);
|
||||||
|
|
||||||
#if HAS_FILAMENT_RUNOUT_DISTANCE
|
#if HAS_FILAMENT_RUNOUT_DISTANCE
|
||||||
const float &runout_distance_mm = runout.runout_distance();
|
const float &runout_distance_mm = runout.runout_distance();
|
||||||
#else
|
#else
|
||||||
constexpr float runout_distance_mm = 0;
|
constexpr float runout_distance_mm = 0;
|
||||||
#endif
|
#endif
|
||||||
_FIELD_TEST(runout_sensor_enabled);
|
|
||||||
EEPROM_WRITE(runout_sensor_enabled);
|
|
||||||
EEPROM_WRITE(runout_distance_mm);
|
EEPROM_WRITE(runout_distance_mm);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1518,13 +1522,12 @@ void MarlinSettings::postprocess() {
|
|||||||
// Filament Runout Sensor
|
// Filament Runout Sensor
|
||||||
//
|
//
|
||||||
{
|
{
|
||||||
#if HAS_FILAMENT_SENSOR
|
int8_t runout_sensor_enabled;
|
||||||
const bool &runout_sensor_enabled = runout.enabled;
|
|
||||||
#else
|
|
||||||
bool runout_sensor_enabled;
|
|
||||||
#endif
|
|
||||||
_FIELD_TEST(runout_sensor_enabled);
|
_FIELD_TEST(runout_sensor_enabled);
|
||||||
EEPROM_READ(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());
|
TERN_(HAS_FILAMENT_SENSOR, if (runout.enabled) runout.reset());
|
||||||
|
|
||||||
@ -2476,7 +2479,7 @@ void MarlinSettings::reset() {
|
|||||||
//
|
//
|
||||||
|
|
||||||
#if HAS_FILAMENT_SENSOR
|
#if HAS_FILAMENT_SENSOR
|
||||||
runout.enabled = true;
|
runout.enabled = FIL_RUNOUT_ENABLED_DEFAULT;
|
||||||
runout.reset();
|
runout.reset();
|
||||||
TERN_(HAS_FILAMENT_RUNOUT_DISTANCE, runout.set_runout_distance(FILAMENT_RUNOUT_DISTANCE_MM));
|
TERN_(HAS_FILAMENT_RUNOUT_DISTANCE, runout.set_runout_distance(FILAMENT_RUNOUT_DISTANCE_MM));
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user