From 1102c6c232251074c49b81758a94256d4a29e817 Mon Sep 17 00:00:00 2001 From: Len Trigg Date: Tue, 16 Apr 2019 13:11:26 +1200 Subject: [PATCH] tsl1401cl_filament_width_sensor: Fix incorrect math in filament width sensor. (#1541) The parameter to the M221 command should be the ratio of the nominal to measured filament area, rather than the ratio of the diameters. Since we are taking the ratio, most of the area calculation cancels out. Fixes #1535. Signed-off-by: Len Trigg --- klippy/extras/tsl1401cl_filament_width_sensor.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/klippy/extras/tsl1401cl_filament_width_sensor.py b/klippy/extras/tsl1401cl_filament_width_sensor.py index a564ddb0..c9f5ab17 100644 --- a/klippy/extras/tsl1401cl_filament_width_sensor.py +++ b/klippy/extras/tsl1401cl_filament_width_sensor.py @@ -93,8 +93,8 @@ class FilamentWidthSensor: filament_width = item[1] if ((filament_width <= self.max_diameter) and (filament_width >= self.min_diameter)): - percentage = round(self.nominal_filament_dia - / filament_width * 100) + 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")