M591 Configurable Filament Runout Sensor#28445
Open
thinkyhead wants to merge 7 commits into
Open
Conversation
- Add M591 G-code for per-extruder runout sensor configuration - Add RunoutMode enum: RM_NONE (0), RM_OUT_ON_LOW (1), RM_OUT_ON_HIGH (2), RM_MOTION_SENSOR (7) - Per-sensor enabled[], mode[] arrays replace single bool runout.enabled - EEPROM saves/restores per-sensor enabled, distance, and mode - M412 preserved as a backward-compatible shim using M591 infrastructure - FIL_RUNOUT_STATE accepted for backward compat (auto-mapped to FIL_RUNOUT_MODE) - FIL_RUNOUT_ENABLED_DEFAULT, FILAMENT_MOTION_SENSOR, FILAMENT_SWITCH_AND_MOTION accepted for backward compat (SanityCheck informs users of new array syntax) - FIL_RUNOUT_MODE[] and FIL_RUNOUT_ENABLED[] arrays for new per-sensor config - SanityCheck updated with migration guidance for deprecated options Based on InsanityAutomation/M591_RRFRunoutParity
There was a problem hiding this comment.
Pull request overview
This PR introduces M591 as a new G-code to configure filament runout behavior per runout sensor / extruder, including per-sensor enable state, runout distance, and a new runout mode enum (switch polarity vs motion sensor). It also updates EEPROM persistence and keeps M412 as a backward-compatibility shim intended to reuse the new infrastructure.
Changes:
- Add
M591/M591_reportand route G-code dispatch forM591(withM412treated as an alias/shim). - Convert filament runout configuration from single values to per-sensor arrays and persist them via EEPROM (bumping EEPROM version).
- Add conditional-layer shims/migration logic for legacy config defines and update runout logic to consult a per-sensor mode.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 19 comments.
Show a summary per file
| File | Description |
|---|---|
| Marlin/src/module/settings.cpp | Bumps EEPROM version and changes EEPROM save/load/reset/M503 reporting to use per-sensor runout arrays and M591 reporting. |
| Marlin/src/inc/SanityCheck.h | Adds migration/deprecation checks for legacy runout config defines. |
| Marlin/src/inc/Conditionals-4-adv.h | Forces HAS_FILAMENT_RUNOUT_DISTANCE to be defined when runout is enabled. |
| Marlin/src/inc/Conditionals-3-etc.h | Adds shims to derive new array-based runout config from legacy defines; ensures distance/state defaults exist. |
| Marlin/src/gcode/gcode.h | Declares M591 / M591_report. |
| Marlin/src/gcode/gcode.cpp | Dispatches M-code 591 to GcodeSuite::M591() and annotates M412 as alias. |
| Marlin/src/gcode/feature/runout/M591.cpp | Implements M591 parameter handling and reporting. |
| Marlin/src/gcode/feature/runout/M412.cpp | Reworks M412 to behave as a shim over M591. |
| Marlin/src/feature/runout.h | Introduces RunoutMode, converts enable/mode/runout-distance handling to per-sensor arrays, and updates polling logic. |
| Marlin/src/feature/runout.cpp | Updates static storage for per-sensor enabled/mode/runout-distance. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
d1c2f81 to
eee3ab4
Compare
1a3d1c4 to
2dfda67
Compare
2dfda67 to
0dd0797
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Built using Hermes Agent with Sonnet 4.6 and "marlin-fork-harvesting" skill to import and update code from https://github.com/InsanityAutomation/Marlin/tree/M591_RRFRunoutParity by @InsanityAutomation
Not a bad starting-point but no doubt needs manual fixup. Since
M412is retained it does not necessarily need to be a separate option, but if doing so would save some space then it should be done.M591G-code for per-extruder runout sensor configurationRM_NONE(0),RM_OUT_ON_LOW(1),RM_OUT_ON_HIGH(2),RM_MOTION_SENSOR(7)enabled[],mode[]arrays replace single boolrunout.enabledM412preserved as a backward-compatible shim usingM591infrastructureFIL_RUNOUT_STATEmapped toFIL_RUNOUT_MODEFIL_RUNOUT_ENABLED_DEFAULT,FILAMENT_MOTION_SENSOR,FILAMENT_SWITCH_AND_MOTIONaccepted for backward compat (SanityCheck informs users of new array syntax)FIL_RUNOUT_MODEandFIL_RUNOUT_ENABLEDarrays for new per-sensor config