mirror of
https://github.com/Klipper3d/klipper.git
synced 2026-03-04 17:14:38 -07:00
hall_filament_width_sensor: Add config validation to avoid possible div-by-zero exceptions
Adds two checks to prevent config settings which could lead to div-by-zero errors in specific circumstances: - `raw_dia1` and `raw_dia2` must be different to prevent a possible exception in `adc2_callback` - `max_difference` must be less than `default_nominal_filament_diameter` to prevent a possible exception in `extrude_factor_update_event` Doc is also updated. Signed-off-by: Ben Lye ben@lye.co.nz
This commit is contained in:
parent
8a2bfb5c9b
commit
8c592ee366
2 changed files with 12 additions and 3 deletions
|
|
@ -5064,15 +5064,16 @@ adc2:
|
|||
# 1.50 for cal_dia1 and 2.00 for cal_dia2.
|
||||
#raw_dia1: 9500
|
||||
#raw_dia2: 10500
|
||||
# The raw calibration values for the sensors. The default is 9500
|
||||
# for raw_dia1 and 10500 for raw_dia2.
|
||||
# The raw calibration values for the sensors. Both values must not be
|
||||
# the same. The default is 9500 for raw_dia1 and 10500 for raw_dia2.
|
||||
#default_nominal_filament_diameter: 1.75
|
||||
# The nominal filament diameter. This parameter must be provided.
|
||||
#max_difference: 0.200
|
||||
# Maximum allowed filament diameter difference in millimeters (mm).
|
||||
# If difference between nominal filament diameter and sensor output
|
||||
# is more than +- max_difference, extrusion multiplier is set back
|
||||
# to %100. The default is 0.200.
|
||||
# to %100. Must be less than default_nominal_filament_diameter.
|
||||
# The default is 0.200.
|
||||
#measurement_delay: 70
|
||||
# The distance from sensor to the melting chamber/hot-end in
|
||||
# millimeters (mm). The filament between the sensor and the hot-end
|
||||
|
|
|
|||
|
|
@ -35,6 +35,14 @@ class HallFilamentWidthSensor:
|
|||
self.is_log =config.getboolean('logging', False)
|
||||
self.enable_flow_compensation = config.getboolean(
|
||||
'enable_flow_compensation', True)
|
||||
if self.rawdia1 == self.rawdia2:
|
||||
raise config.error(
|
||||
"hall_filament_width_sensor: raw_dia1 and raw_dia2 must be"
|
||||
" different")
|
||||
if self.min_diameter <= 0:
|
||||
raise config.error(
|
||||
"hall_filament_width_sensor: max_difference must be less than"
|
||||
" default_nominal_filament_diameter")
|
||||
# Use the current diameter instead of nominal while the first
|
||||
# measurement isn't in place
|
||||
self.use_current_dia_while_delay = config.getboolean(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue