diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2017-04-11 11:37:09 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2017-04-11 11:42:55 -0400 |
commit | 7b03b04c786863bc32d3b790862857061f71f072 (patch) | |
tree | 4396da5121caf1f7f6e5072115a4ddff345fa476 /klippy/toolhead.py | |
parent | 7a7b98cc31dff8cb7f1a6a1ab886362a0802be66 (diff) | |
download | kutter-7b03b04c786863bc32d3b790862857061f71f072.tar.gz kutter-7b03b04c786863bc32d3b790862857061f71f072.tar.xz kutter-7b03b04c786863bc32d3b790862857061f71f072.zip |
klippy: Support minimum/maximum value checks on configuration variables
Verify that numeric parameters are in a sane range when reading the
config.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/toolhead.py')
-rw-r--r-- | klippy/toolhead.py | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/klippy/toolhead.py b/klippy/toolhead.py index d7b677ce..bd4ccd10 100644 --- a/klippy/toolhead.py +++ b/klippy/toolhead.py @@ -188,18 +188,24 @@ class ToolHead: 'corexy': corexy.CoreXYKinematics, 'delta': delta.DeltaKinematics} self.kin = config.getchoice('kinematics', kintypes)(printer, config) - self.max_speed = config.getfloat('max_velocity') - self.max_accel = config.getfloat('max_accel') - self.max_accel_to_decel = config.getfloat('max_accel_to_decel' - , self.max_accel * 0.5) - self.junction_deviation = config.getfloat('junction_deviation', 0.02) + self.max_speed = config.getfloat('max_velocity', above=0.) + self.max_accel = config.getfloat('max_accel', above=0.) + self.max_accel_to_decel = config.getfloat( + 'max_accel_to_decel', self.max_accel * 0.5 + , above=0., maxval=self.max_accel) + self.junction_deviation = config.getfloat( + 'junction_deviation', 0.02, above=0.) self.move_queue = MoveQueue(self.extruder.lookahead) self.commanded_pos = [0., 0., 0., 0.] # Print time tracking - self.buffer_time_high = config.getfloat('buffer_time_high', 2.000) - self.buffer_time_low = config.getfloat('buffer_time_low', 1.000) - self.buffer_time_start = config.getfloat('buffer_time_start', 0.250) - self.move_flush_time = config.getfloat('move_flush_time', 0.050) + self.buffer_time_low = config.getfloat( + 'buffer_time_low', 1.000, above=0.) + self.buffer_time_high = config.getfloat( + 'buffer_time_high', 2.000, above=self.buffer_time_low) + self.buffer_time_start = config.getfloat( + 'buffer_time_start', 0.250, above=0.) + self.move_flush_time = config.getfloat( + 'move_flush_time', 0.050, above=0.) self.print_time = 0. self.need_check_stall = -1. self.print_stall = 0 @@ -208,7 +214,8 @@ class ToolHead: self.flush_timer = self.reactor.register_timer(self._flush_handler) self.move_queue.set_flush_time(self.buffer_time_high) # Motor off tracking - self.motor_off_time = config.getfloat('motor_off_time', 600.000) + self.motor_off_time = config.getfloat( + 'motor_off_time', 600.000, minval=0.) self.motor_off_timer = self.reactor.register_timer( self._motor_off_handler) # Determine the maximum velocity a cartesian axis could have |