Backlash cleanup (#13659)

…And save backlash, fil. sensor, ExtUI userdata to EEPROM.
This commit is contained in:
Marcio Teixeira
2019-05-03 22:53:15 -06:00
committed by Scott Lahteine
parent 0181e57417
commit 15357af67c
22 changed files with 645 additions and 293 deletions

View File

@@ -78,6 +78,11 @@ class TFilamentMonitor : public FilamentMonitorBase {
response.filament_present(extruder);
}
#ifdef FILAMENT_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; }
#endif
// Handle a block completion. RunoutResponseDelayed uses this to
// add up the length of filament moved while the filament is out.
static inline void block_completed(const block_t* const b) {
@@ -90,13 +95,13 @@ class TFilamentMonitor : public FilamentMonitorBase {
// Give the response a chance to update its counter.
static inline void run() {
if (enabled && !filament_ran_out && (IS_SD_PRINTING() || print_job_timer.isRunning() || did_pause_print)) {
#if FILAMENT_RUNOUT_DISTANCE_MM > 0
#ifdef FILAMENT_RUNOUT_DISTANCE_MM
cli(); // Prevent RunoutResponseDelayed::block_completed from accumulating here
#endif
response.run();
sensor.run();
const bool ran_out = response.has_run_out();
#if FILAMENT_RUNOUT_DISTANCE_MM > 0
#ifdef FILAMENT_RUNOUT_DISTANCE_MM
sei();
#endif
if (ran_out) {
@@ -272,7 +277,7 @@ class FilamentSensorBase {
/********************************* RESPONSE TYPE *********************************/
#if FILAMENT_RUNOUT_DISTANCE_MM > 0
#ifdef FILAMENT_RUNOUT_DISTANCE_MM
// RunoutResponseDelayed triggers a runout event only if the length
// of filament specified by FILAMENT_RUNOUT_DISTANCE_MM has been fed
@@ -347,11 +352,12 @@ class FilamentSensorBase {
/********************************* TEMPLATE SPECIALIZATION *********************************/
typedef TFilamentMonitor<
#if FILAMENT_RUNOUT_DISTANCE_MM > 0
#ifdef FILAMENT_RUNOUT_DISTANCE_MM
RunoutResponseDelayed,
#if ENABLED(FILAMENT_MOTION_SENSOR)
RunoutResponseDelayed, FilamentSensorEncoder
FilamentSensorEncoder
#else
RunoutResponseDelayed, FilamentSensorSwitch
FilamentSensorSwitch
#endif
#else
RunoutResponseDebounced, FilamentSensorSwitch