aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/extras/hall_filament_width_sensor.py
diff options
context:
space:
mode:
authormatpab <31384634+matpab@users.noreply.github.com>2020-06-06 20:19:00 +0200
committerGitHub <noreply@github.com>2020-06-06 14:19:00 -0400
commit967fe1c01c759724c52ec4fefbb95fb8a58840a6 (patch)
treeee1f50f58709e378b27687f8eb43dc84b3ee39cd /klippy/extras/hall_filament_width_sensor.py
parenta6f2fc7179c0bf00827bc252fab5685efcad16f9 (diff)
downloadkutter-967fe1c01c759724c52ec4fefbb95fb8a58840a6.tar.gz
kutter-967fe1c01c759724c52ec4fefbb95fb8a58840a6.tar.xz
kutter-967fe1c01c759724c52ec4fefbb95fb8a58840a6.zip
HallFilamentWidthSensor: Use current width instead of nomal width while delay is not over (#2907)
Option for using the current diameter instead of nominal while the first measurement isn't in place Signed-off-by: Matthias Pabel <matthias.pabel@hs-augsburg.de>
Diffstat (limited to 'klippy/extras/hall_filament_width_sensor.py')
-rw-r--r--klippy/extras/hall_filament_width_sensor.py21
1 files changed, 14 insertions, 7 deletions
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 = []