After reading the first item of self.filament_array, filament_width is updated back to self.nominal_filament_dia or self.diameter instead of retaining the value until next pending_position. Updated Filament Menu Template. Signed-off-by: Nicola Falciani <nicola.fal@gmail.com>
This commit is contained in:
parent
bc904dd431
commit
1bdf705524
|
@ -92,26 +92,17 @@ Sensor generates two analog output based on calculated filament width. Sum of ou
|
||||||
**hall_filament_width_sensor.is_active** Sensor on or off
|
**hall_filament_width_sensor.is_active** Sensor on or off
|
||||||
|
|
||||||
## Template for menu variables
|
## Template for menu variables
|
||||||
[menu __filament_width_current]
|
[menu __main __filament __width_current]
|
||||||
type: item
|
type: command
|
||||||
name: "Dia:{0:4.2f} mm"
|
enable: {'hall_filament_width_sensor' in printer}
|
||||||
parameter: hall_filament_width_sensor.Diameter
|
name: Dia: {'%.2F' % printer.hall_filament_width_sensor.Diameter}
|
||||||
|
index: 0
|
||||||
|
|
||||||
[menu __filament_raw_width_current]
|
[menu __main __filament __raw_width_current]
|
||||||
type: item
|
type: command
|
||||||
name: "RAW:{0:4.0f}"
|
enable: {'hall_filament_width_sensor' in printer}
|
||||||
parameter: hall_filament_width_sensor.Raw
|
name: Raw: {'%4.0F' % printer.hall_filament_width_sensor.Raw}
|
||||||
|
index: 1
|
||||||
[menu __filament]
|
|
||||||
type: list
|
|
||||||
name: Filament
|
|
||||||
items:
|
|
||||||
__temp __hotend0_current, __temp __hotend0_target
|
|
||||||
.__unload
|
|
||||||
.__load
|
|
||||||
.__feed
|
|
||||||
__filament_width_current
|
|
||||||
__filament_raw_width_current
|
|
||||||
|
|
||||||
## Calibration procedure
|
## Calibration procedure
|
||||||
Insert first calibration rod (1.5 mm size) get first raw sensor value
|
Insert first calibration rod (1.5 mm size) get first raw sensor value
|
||||||
|
|
|
@ -40,6 +40,8 @@ class HallFilamentWidthSensor:
|
||||||
self.filament_array = []
|
self.filament_array = []
|
||||||
self.lastFilamentWidthReading = 0
|
self.lastFilamentWidthReading = 0
|
||||||
self.lastFilamentWidthReading2 = 0
|
self.lastFilamentWidthReading2 = 0
|
||||||
|
self.firstExtruderUpdatePosition = 0
|
||||||
|
self.filament_width = self.nominal_filament_dia
|
||||||
# printer objects
|
# printer objects
|
||||||
self.toolhead = self.ppins = self.mcu_adc = None
|
self.toolhead = self.ppins = self.mcu_adc = None
|
||||||
self.printer.register_event_handler("klippy:ready", self.handle_ready)
|
self.printer.register_event_handler("klippy:ready", self.handle_ready)
|
||||||
|
@ -112,6 +114,8 @@ class HallFilamentWidthSensor:
|
||||||
# add first item to array
|
# add first item to array
|
||||||
self.filament_array.append([self.measurement_delay + last_epos,
|
self.filament_array.append([self.measurement_delay + last_epos,
|
||||||
self.diameter])
|
self.diameter])
|
||||||
|
self.firstExtruderUpdatePosition = (self.measurement_delay
|
||||||
|
+ last_epos)
|
||||||
|
|
||||||
def extrude_factor_update_event(self, eventtime):
|
def extrude_factor_update_event(self, eventtime):
|
||||||
# Update extrude factor
|
# Update extrude factor
|
||||||
|
@ -130,15 +134,18 @@ class HallFilamentWidthSensor:
|
||||||
if pending_position <= last_epos:
|
if pending_position <= last_epos:
|
||||||
# Get first item in filament_array queue
|
# Get first item in filament_array queue
|
||||||
item = self.filament_array.pop(0)
|
item = self.filament_array.pop(0)
|
||||||
filament_width = item[1]
|
self.filament_width = item[1]
|
||||||
elif self.use_current_dia_while_delay:
|
|
||||||
filament_width = self.diameter
|
|
||||||
else:
|
else:
|
||||||
filament_width = self.nominal_filament_dia
|
if ((self.use_current_dia_while_delay)
|
||||||
if ((filament_width <= self.max_diameter)
|
and (self.firstExtruderUpdatePosition
|
||||||
and (filament_width >= self.min_diameter)):
|
== pending_position)):
|
||||||
|
self.filament_width = self.diameter
|
||||||
|
elif self.firstExtruderUpdatePosition == pending_position:
|
||||||
|
self.filament_width = self.nominal_filament_dia
|
||||||
|
if ((self.filament_width <= self.max_diameter)
|
||||||
|
and (self.filament_width >= self.min_diameter)):
|
||||||
percentage = round(self.nominal_filament_dia**2
|
percentage = round(self.nominal_filament_dia**2
|
||||||
/ filament_width**2 * 100)
|
/ self.filament_width**2 * 100)
|
||||||
self.gcode.run_script("M221 S" + str(percentage))
|
self.gcode.run_script("M221 S" + str(percentage))
|
||||||
else:
|
else:
|
||||||
self.gcode.run_script("M221 S100")
|
self.gcode.run_script("M221 S100")
|
||||||
|
|
Loading…
Reference in New Issue