From 4d2fd182ee0d95a0facb995dfa4681139f57ca63 Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Sun, 13 Mar 2022 13:48:18 -0400 Subject: [PATCH] M591 Cleanup and tweaks --- Marlin/src/gcode/feature/runout/M591.cpp | 2 +- Marlin/src/module/endstops.cpp | 15 ++++++----- Marlin/src/module/settings.cpp | 32 ++++++++++++------------ 3 files changed, 26 insertions(+), 23 deletions(-) diff --git a/Marlin/src/gcode/feature/runout/M591.cpp b/Marlin/src/gcode/feature/runout/M591.cpp index e80252677a..e4a7e5b59d 100644 --- a/Marlin/src/gcode/feature/runout/M591.cpp +++ b/Marlin/src/gcode/feature/runout/M591.cpp @@ -70,7 +70,7 @@ void GcodeSuite::M591() { if (parser.seen('L')) runout.set_runout_distance(parser.value_linear_units(), tool); if (parser.seen('P')) { uint8_t tmp_mode = parser.value_int(); - if(tmp_mode > 3 || tmp_mode==7) { + if(tmp_mode < 3 || tmp_mode==7) { runout.mode[tool] = tmp_mode; runout.reset(); } diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index 57476d89f6..4fae1d4ad2 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -583,21 +583,24 @@ void _O2 Endstops::report_states() { default: continue; REPEAT_1(NUM_RUNOUT_SENSORS, _CASE_RUNOUT) } - if(runout.mode[i]==1) + if(runout.mode[i-1]==1) state = HIGH; else state = LOW; SERIAL_ECHOPGM(STR_FILAMENT); if (i > 1) SERIAL_CHAR(' ', '0' + i); - print_es_state(extDigitalRead(pin) != state); SERIAL_ECHOPGM(": "); - if(runout.mode[i]==0) - SERIAL_ECHOLNF(F("Sensor Disabled")); + if(runout.mode[i-1]==0) + SERIAL_ECHOLNF(F("DISABLED")); + else if(runout.mode[i-1]==7) { + SERIAL_ECHOF(F("MOTION : ")); + print_es_state(extDigitalRead(pin) != state); + } else if(extDigitalRead(pin) != state) - SERIAL_ECHOLNF(F("Fil Present")); + SERIAL_ECHOLNF(F("PRESENT")); else - SERIAL_ECHOLNF(F("Fil Missing")); + SERIAL_ECHOLNF(F("MISSING")); } #undef _CASE_RUNOUT #endif diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 1dccdb905e..20f480faa2 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -36,7 +36,7 @@ */ // Change EEPROM version if the structure changes -#define EEPROM_VERSION "V86" +#define EEPROM_VERSION "V87" #define EEPROM_OFFSET 100 // Check the integrity of data offsets. @@ -794,18 +794,18 @@ void MarlinSettings::postprocess() { // { #if HAS_FILAMENT_SENSOR - LOOP_S_L_N(e, 1, HOTENDS) + LOOP_S_L_N(e, 0, HOTENDS) EEPROM_WRITE(runout.enabled[e]); - LOOP_S_L_N(e, 1, HOTENDS) + LOOP_S_L_N(e, 0, HOTENDS) EEPROM_WRITE(runout.runout_distance(e)); - LOOP_S_L_N(e, 1, HOTENDS) + LOOP_S_L_N(e, 0, HOTENDS) EEPROM_WRITE(runout.mode[e]); #else - LOOP_S_L_N(e, 1, HOTENDS) + LOOP_S_L_N(e, 0, HOTENDS) EEPROM_WRITE((int8_t)-1)); - LOOP_S_L_N(e, 1, HOTENDS) + LOOP_S_L_N(e, 0, HOTENDS) EEPROM_WRITE((float)-0.0f)); - LOOP_S_L_N(e, 1, HOTENDS) + LOOP_S_L_N(e, 0, HOTENDS) EEPROM_WRITE((uint8_t)0)); #endif } @@ -1715,21 +1715,21 @@ void MarlinSettings::postprocess() { { int8_t runout_sensor_enabled[HOTENDS]; _FIELD_TEST(runout_sensor_enabled); - LOOP_S_L_N(e, 1, HOTENDS) + LOOP_S_L_N(e, 0, HOTENDS) EEPROM_READ(runout_sensor_enabled); float runout_distance_mm[HOTENDS]; - LOOP_S_L_N(e, 1, HOTENDS) + LOOP_S_L_N(e, 0, HOTENDS) EEPROM_READ(runout_distance_mm[e]); uint8_t runout_mode[HOTENDS]; - LOOP_S_L_N(e, 1, HOTENDS) + LOOP_S_L_N(e, 0, HOTENDS) EEPROM_READ(runout_mode[e]); #if HAS_FILAMENT_SENSOR - LOOP_S_L_N(e, 1, HOTENDS) + LOOP_S_L_N(e, 0, HOTENDS) runout.enabled[e] = runout_sensor_enabled[e] < 0 ? FIL_RUNOUT_ENABLED_DEFAULT : runout_sensor_enabled[e]; - LOOP_S_L_N(e, 1, HOTENDS) + LOOP_S_L_N(e, 0, HOTENDS) if (!validating) runout.set_runout_distance(runout_distance_mm[e], e); - LOOP_S_L_N(e, 1, HOTENDS) + LOOP_S_L_N(e, 0, HOTENDS) if (!validating) runout.mode[e] = runout_mode[e]; runout.reset(); #endif @@ -2798,11 +2798,11 @@ void MarlinSettings::reset() { // #if HAS_FILAMENT_SENSOR - LOOP_S_L_N(e, 1, HOTENDS) + LOOP_S_L_N(e, 0, HOTENDS) runout.enabled[e] = FIL_RUNOUT_ENABLED_DEFAULT; - LOOP_S_L_N(e, 1, HOTENDS) + LOOP_S_L_N(e, 0, HOTENDS) runout.set_runout_distance(FILAMENT_RUNOUT_DISTANCE_MM, e); - LOOP_S_L_N(e, 1, HOTENDS) + LOOP_S_L_N(e, 0, HOTENDS) runout.mode[e] = FILAMENT_RUNOUT_DEFAULT_MODE; runout.reset();