From b3298d8992bde9bd206c455212eb16d4403bd1d8 Mon Sep 17 00:00:00 2001 From: Denis Ignatenko <60291791+test3210-d@users.noreply.github.com> Date: Tue, 16 Jun 2020 20:36:49 +0300 Subject: hall_filament_width_sensor: Added width logging (#2981) Signed-off-by: Denis Ignatenko deniss979@gmail.com --- klippy/extras/hall_filament_width_sensor.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'klippy/extras/hall_filament_width_sensor.py') diff --git a/klippy/extras/hall_filament_width_sensor.py b/klippy/extras/hall_filament_width_sensor.py index e065f175..d84cfd70 100644 --- a/klippy/extras/hall_filament_width_sensor.py +++ b/klippy/extras/hall_filament_width_sensor.py @@ -31,6 +31,7 @@ class HallFilamentWidthSensor: self.diameter =self.nominal_filament_dia self.is_active =config.getboolean('enable', False) self.runout_dia=config.getfloat('min_diameter', 1.0) + self.is_log =config.getboolean('logging', False) # Use the current diameter instead of nominal while the first # measurement isn't in place self.use_current_dia_while_delay = config.getboolean( @@ -63,6 +64,11 @@ class HallFilamentWidthSensor: self.cmd_M405) self.gcode.register_command('QUERY_RAW_FILAMENT_WIDTH', self.cmd_Get_Raw_Values) + self.gcode.register_command('ENABLE_FILAMENT_WIDTH_LOG', + self.cmd_log_enable) + self.gcode.register_command('DISABLE_FILAMENT_WIDTH_LOG', + self.cmd_log_disable) + self.runout_helper = filament_switch_sensor.RunoutHelper(config) # Initialization def handle_ready(self): @@ -97,6 +103,10 @@ class HallFilamentWidthSensor: if next_reading_position <= (last_epos + self.measurement_delay): self.filament_array.append([last_epos + self.measurement_delay, self.diameter]) + if self.is_log: + self.gcode.respond_info("Filament width:%.3f" % + ( self.diameter )) + else: # add first item to array self.filament_array.append([self.measurement_delay + last_epos, @@ -190,6 +200,13 @@ class HallFilamentWidthSensor: 'Raw':(self.lastFilamentWidthReading+ self.lastFilamentWidthReading2), 'is_active':self.is_active} + def cmd_log_enable(self, gcmd): + self.is_log = True + gcmd.respond_info("Filament width logging Turned On") + + def cmd_log_disable(self, gcmd): + self.is_log = False + gcmd.respond_info("Filament width logging Turned Off") def load_config(config): return HallFilamentWidthSensor(config) -- cgit v1.2.3-70-g09d2