aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config/example-extras.cfg2
-rw-r--r--docs/HallFilamentWidthSensor.md2
-rw-r--r--klippy/extras/hall_filament_width_sensor.py21
3 files changed, 18 insertions, 7 deletions
diff --git a/config/example-extras.cfg b/config/example-extras.cfg
index 7591645b..ca36c969 100644
--- a/config/example-extras.cfg
+++ b/config/example-extras.cfg
@@ -2016,6 +2016,8 @@
#Virtual filament_switch_sensor support. Create sensor named hall_filament_width_sensor.
#min_diameter:1.0
#Minimal diameter for trigger virtual filament_switch_sensor.
+#use_current_dia_while_delay: False
+# Use the current diameter instead of the nominal diamenter while the measurement delay has not run through.
#Values from filament_switch_sensor.
#See [filament_switch_sensor] for a description of these parameters.
#pause_on_runout: True
diff --git a/docs/HallFilamentWidthSensor.md b/docs/HallFilamentWidthSensor.md
index 4123f474..5867662d 100644
--- a/docs/HallFilamentWidthSensor.md
+++ b/docs/HallFilamentWidthSensor.md
@@ -52,6 +52,8 @@ Sensor generates two analog output based on calculated filament width. Sum of ou
#
#min_diameter:1.0
#Minimal diameter for trigger virtual filament_switch_sensor.
+ #use_current_dia_while_delay: False
+ # Use the current diameter instead of the nominal diamenter while the measurement delay has not run through.
#
#Values from filament_switch_sensor. See the "filament_switch_sensor" section for information on these parameters.
#
diff --git a/klippy/extras/hall_filament_width_sensor.py b/klippy/extras/hall_filament_width_sensor.py
index d93d9e2e..50669482 100644
--- a/klippy/extras/hall_filament_width_sensor.py
+++ b/klippy/extras/hall_filament_width_sensor.py
@@ -31,6 +31,8 @@ class HallFilamentWidthSensor:
self.diameter =self.nominal_filament_dia
self.is_active =config.getboolean('enable', False)
self.runout_dia=config.getfloat('min_diameter', 1.0)
+ # Use the current diameter instead of nominal while the first measurement isn't in place
+ self.use_current_dia_while_delay = config.getboolean('use_current_dia_while_delay', False)
# filament array [position, filamentWidth]
self.filament_array = []
self.lastFilamentWidthReading = 0
@@ -116,13 +118,18 @@ class HallFilamentWidthSensor:
# Get first item in filament_array queue
item = self.filament_array.pop(0)
filament_width = item[1]
- if ((filament_width <= self.max_diameter)
- and (filament_width >= self.min_diameter)):
- percentage = round(self.nominal_filament_dia**2
- / filament_width**2 * 100)
- self.gcode.run_script("M221 S" + str(percentage))
- else:
- self.gcode.run_script("M221 S100")
+ elif self.use_current_dia_while_delay:
+ filament_width = self.diameter
+ else:
+ filament_width = self.nominal_filament_dia
+
+ if ((filament_width <= self.max_diameter)
+ and (filament_width >= self.min_diameter)):
+ percentage = round(self.nominal_filament_dia**2
+ / filament_width**2 * 100)
+ self.gcode.run_script("M221 S" + str(percentage))
+ else:
+ self.gcode.run_script("M221 S100")
else:
self.gcode.run_script("M221 S100")
self.filament_array = []