From cd53016a22b85913fe6644f5e6f85fd10d0b0bfb Mon Sep 17 00:00:00 2001 From: Zeanon Date: Wed, 3 Apr 2024 11:57:35 +0200 Subject: [PATCH] Added doc and fixed reset behaviour --- docs/Config_Reference.md | 8 ++++++++ docs/G-Codes.md | 21 +++++++++++++-------- klippy/extras/filament_motion_sensor.py | 2 +- klippy/extras/filament_switch_sensor.py | 12 ++++++++---- 4 files changed, 30 insertions(+), 13 deletions(-) diff --git a/docs/Config_Reference.md b/docs/Config_Reference.md index 7077274f8..a027ca4c4 100644 --- a/docs/Config_Reference.md +++ b/docs/Config_Reference.md @@ -4807,6 +4807,13 @@ more information. # If set to true the sensor will use the virtual_sd_card module to determine # whether the printer is printing which is more reliable but will not work # when streaming a print over usb or similar. +#always_fire_events: +# If set to true, runout events will always fire no matter whether the sensor +# is enabled or disabled. Usefull for MMUs +#check_on_print_start: +# If set to true, the sensor will be reevaluated when a print starts and if +# no filament is detected the runout_gcode will be run no matter the defined +# runout_distance(immediate_runout_gcode will not be run in this case) ``` ### [filament_motion_sensor] @@ -4834,6 +4841,7 @@ switch_pin: #event_delay: #pause_delay: #smart: +#always_fire_events: # See the "filament_switch_sensor" section for a description of the # above parameters. ``` diff --git a/docs/G-Codes.md b/docs/G-Codes.md index 94091aaa1..c501d7e89 100644 --- a/docs/G-Codes.md +++ b/docs/G-Codes.md @@ -549,29 +549,34 @@ depend on the sensor type defined in the configuration. #### SET_FILAMENT_SENSOR ###### For filament_switch_sensor: `SET_FILAMENT_SENSOR SENSOR= [ENABLE=0|1] [RESET=0|1] -[RUNOUT_DISTANCE=] [SMART=0|1]`: Sets values for the -filament sensor. If all parameters are omitted, the current stats will -be reported.
+[RUNOUT_DISTANCE=] [SMART=0|1] [ALWAYS_FIRE_EVENTS=0|1] [CHECK_ON_PRINT_START=0|1]`: +Sets values for the filament sensor. +If all parameters are omitted, the current stats will be reported.
ENABLE sets the filament sensor on/off. If ENABLE is set to 0, the filament sensor will be disabled, if set to 1 it is enabled. If the state of the sensor changes, a reset will be triggered.
RESET removes all pending runout_gcodes and pauses and force a reevaluation of the sensor state.
RUNOUT_DISTANCE sets the runout_distance.
-SMART sets the smart parameter. +SMART sets the smart parameter.
+ALWAYS_FIRE_EVENTS sets the always_fire_events parameter, if set to true, +a reset of the sensor will be triggered.
+CHECK_ON_PRINT_START sets the check_on_print_start parameter. ###### For filament_motion_sensor: `SET_FILAMENT_SENSOR SENSOR= [ENABLE=0|1] [RESET=0|1] -[DETECTION_LENGTH=] [SMART=0|1]`: Sets values for the -filament sensor. If all parameters are omitted, the current stats will -be reported.
+[DETECTION_LENGTH=] [SMART=0|1] [ALWAYS_FIRE_EVENTS=0|1]`: +Sets values for the filament sensor. +If all parameters are omitted, the current stats will be reported.
ENABLE sets the filament sensor on/off. If ENABLE is set to 0, the filament sensor will be disabled, if set to 1 it is enabled. If the sensor was previously disabled and gets enabled, a reset will be triggered.
RESET resets the state of the sensor and sets it to filament detected.
DETECTION_LENGTH sets the detection_length, if the new detection length is different from the old one, a reset will be triggered.
-SMART sets the smart parameter. +SMART sets the smart parameter.
+ALWAYS_FIRE_EVENTS sets the always_fire_events parameter, no reset will +be triggered. ### [firmware_retraction] diff --git a/klippy/extras/filament_motion_sensor.py b/klippy/extras/filament_motion_sensor.py index b094e3673..226e0cf48 100644 --- a/klippy/extras/filament_motion_sensor.py +++ b/klippy/extras/filament_motion_sensor.py @@ -120,7 +120,7 @@ def get_info(self, gcmd): return True return False - def reset_needed(self, enable): + def reset_needed(self, enable=None, always_fire_events=None): if enable and not self.runout_helper.sensor_enabled: return True return False diff --git a/klippy/extras/filament_switch_sensor.py b/klippy/extras/filament_switch_sensor.py index 41d19f3fe..a1f439cfc 100644 --- a/klippy/extras/filament_switch_sensor.py +++ b/klippy/extras/filament_switch_sensor.py @@ -210,8 +210,6 @@ def cmd_SET_FILAMENT_SENSOR(self, gcmd): ): return if enable is not None: - if self.defined_sensor.reset_needed(enable): - reset_needed = True self.sensor_enabled = enable if reset is not None and reset: reset_needed = True @@ -221,6 +219,10 @@ def cmd_SET_FILAMENT_SENSOR(self, gcmd): self.always_fire_events = always_fire_events if self.defined_sensor.set_filament_sensor(gcmd): reset_needed = True + if self.defined_sensor.reset_needed( + enable=enable, always_fire_events=always_fire_events + ): + reset_needed = True if reset_needed: self.defined_sensor.reset() @@ -306,8 +308,10 @@ def get_info(self, gcmd): return True return False - def reset_needed(self, enable): - if enable != self.runout_helper.sensor_enabled: + def reset_needed(self, enable=None, always_fire_events=None): + if enable is not None and enable != self.runout_helper.sensor_enabled: + return True + if always_fire_events is not None and always_fire_events: return True return False