Skip to content

Commit

Permalink
Enhance support for firmware retraction for issue #195.
Browse files Browse the repository at this point in the history
  • Loading branch information
FormerLurker committed Jul 17, 2018
1 parent ae34d85 commit cb949a0
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 9 deletions.
14 changes: 13 additions & 1 deletion octoprint_octolapse/gcode_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ class Commands(object):

M207 = Command(
"M207",
"Set retract listance"
"Set retract length"
"M207 - Set retract length",
parameters={
"S": CommandParameter("S", CommandParameter.parse_float, 1),
Expand All @@ -405,6 +405,17 @@ class Commands(object):
}
)

M208 = Command(
"M208",
"Set detract length"
"M208 - Set detract length",
parameters={
"S": CommandParameter("S", CommandParameter.parse_float, 1),
"F": CommandParameter("F", CommandParameter.parse_float, 2),

}
)

M400 = Command(
"M400",
"Wait for moves to finish",
Expand Down Expand Up @@ -440,6 +451,7 @@ class Commands(object):
M190.Command: M190,
M191.Command: M191,
M207.Command: M207,
M208.Command: M208,
M400.Command: M400
}

Expand Down
36 changes: 30 additions & 6 deletions octoprint_octolapse/position.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,25 @@ def __init__(self, printer, octoprint_printer_profile, pos=None):
self.InPathPosition = False if pos is None else pos.InPathPosition
self.IsTravelOnly = False if pos is None else pos.IsTravelOnly

# Firmware Retraction Tracking
self.FirmwareRetractionLength = None if pos is None else pos.FirmwareRetractionLength
self.FirmwareUnretractionAdditionalLength = None if pos is None else pos.FirmwareUnretractionAdditionalLength
self.FirmwareRetractionFeedrate = None if pos is None else pos.FirmwareRetractionFeedrate
self.FirmwareUnretractionFeedrate = None if pos is None else pos.FirmwareUnretractionFeedrate
self.FirmwareZLift = None if pos is None else pos.FirmwareZLift
# default firmware retraction length and feedrate if default_firmware_retractions isenabled
if pos is None and printer.default_firmware_retractions:
self.FirmwareRetractionLength = printer.retract_length
self.FirmwareUnretractionAdditionalLength = None # todo: add this setting
self.FirmwareRetractionFeedrate = printer.retract_speed
self.FirmwareUnretractionFeedrate = printer.detract_speed

else:
self.FirmwareRetractionLength = None if pos is None else pos.FirmwareRetractionLength
self.FirmwareUnretractionAdditionalLength = None if pos is None else pos.FirmwareUnretractionAdditionalLength
self.FirmwareRetractionFeedrate = None if pos is None else pos.FirmwareRetractionFeedrate
self.FirmwareUnretractionFeedrate = None if pos is None else pos.FirmwareUnretractionFeedrate

# default firmware retraction zlift if default_firmware_retractions_zhop is enabled
if pos is None and printer.default_firmware_retractions_zhop:
self.FirmwareZLift = printer.z_hop
else:
self.FirmwareZLift = None if pos is None else pos.FirmwareZLift


# State Flags
self.IsLayerChange = False if pos is None else pos.IsLayerChange
Expand Down Expand Up @@ -1049,6 +1062,17 @@ def update(self, gcode, cmd, parameters):
if "Z" in parameters:
pos.FirmwareZLift = parameters["Z"]

elif cmd == "M208":
self.Settings.current_debug_profile().log_position_command_received(
"Received M207 - setting firmware detraction values"
)
# Firmware Retraction Tracking
if "S" in parameters:
pos.FirmwareUnretractionAdditionalLength = parameters["S"]
if "F" in parameters:
pos.FirmwareUnretractionFeedrate = parameters["F"]


elif cmd == "G92":
# Set Position (offset)

Expand Down
16 changes: 15 additions & 1 deletion octoprint_octolapse/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ def __init__(self, printer=None, name="New Printer", guid=None):
self.xyz_axes_default_mode = 'require-explicit' # other values are 'relative' and 'absolute'
self.units_default = 'millimeters'
self.axis_speed_display_units = 'mm-min'
self.default_firmware_retractions = False
self.default_firmware_retractions_zhop = False
if printer is not None:
if isinstance(printer, Printer):
self.guid = printer.guid
Expand Down Expand Up @@ -103,6 +105,9 @@ def __init__(self, printer=None, name="New Printer", guid=None):
self.xyz_axes_default_mode = printer.xyz_axes_default_mode
self.units_default = printer.units_default
self.axis_speed_display_units = printer.axis_speed_display_units
self.default_firmware_retractions = printer.default_firmware_retractions
self.default_firmware_retractions_zhop = printer.default_firmware_retractions_zhop

else:
self.update(printer)

Expand Down Expand Up @@ -191,6 +196,14 @@ def update(self, changes):
self.axis_speed_display_units = utility.get_string(
changes["axis_speed_display_units"], self.axis_speed_display_units
)
if "default_firmware_retractions" in changes.keys():
self.default_firmware_retractions = utility.get_bool(
changes["default_firmware_retractions"], self.default_firmware_retractions
)
if "default_firmware_retractions_zhop" in changes.keys():
self.default_firmware_retractions_zhop = utility.get_bool(
changes["default_firmware_retractions_zhop"], self.default_firmware_retractions_zhop
)

def to_dict(self):
return {
Expand Down Expand Up @@ -224,7 +237,8 @@ def to_dict(self):
'xyz_axes_default_mode': self.xyz_axes_default_mode,
'units_default': self.units_default,
'axis_speed_display_units': self.axis_speed_display_units,

'default_firmware_retractions': self.default_firmware_retractions,
'default_firmware_retractions_zhop': self.default_firmware_retractions_zhop
}


Expand Down
2 changes: 2 additions & 0 deletions octoprint_octolapse/static/js/octolapse.profiles.printer.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ $(function() {
self.xyz_axes_default_mode = ko.observable(values.xyz_axes_default_mode);
self.units_default = ko.observable(values.units_default);
self.axis_speed_display_units = ko.observable(values.axis_speed_display_units);
self.default_firmware_retractions = ko.observable(values.default_firmware_retractions);
self.default_firmware_retractions_zhop = ko.observable(values.default_firmware_retractions_zhop);

// get the time component of the axis speed units (min/mm)
self.getAxisSpeedTimeUnit = ko.pureComputed(function () {
Expand Down
22 changes: 21 additions & 1 deletion octoprint_octolapse/templates/octolapse_profiles_printer.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,27 @@
<span class="help-inline">Some slicers prime quite far from the printer bed. This can adversly affect layer/height tracking. This setting will prevent layer detection if extrusion has not happend BELOW the selected height. Set to 0 to turn off.</span>
</div>
</div>

<div class="control-group">
<label class="control-label">Use Retraction/Detraction settings for Firmware Retract/Detract</label>
<div class="controls">
<label class="checkbox">
<input name="default_firmware_retractions" type="checkbox" data-bind="checked: default_firmware_retractions" title="Use Retraction/Detraction settings for Firmware Retract/Detract"/>Enabled
</label>
<span class="help-inline">When enabled Octolapse will assume that your firmware is set to use the same retraction/detraction settings (except z-lift) as your Octolapse profile. It is always a good idea to include an M207 and or M208 in your start gcode if you are using firmware retract/detract so that Octolapse knows what values to use when tracking position.</span>
</div>
</div>
<div class="control-group">
<label class="control-label">Use Z-Hop (Z-Lift) settings for Firmware Retract/Detract</label>
<div class="controls">
<label class="checkbox">
<input name="default_firmware_retractions_zhop" type="checkbox" data-bind="checked: default_firmware_retractions_zhop" title="Use Retraction/Detraction settings for Firmware Retract/Detract"/>Enabled
</label>
<span class="help-inline">When enabled Octolapse will assume that your firmware is set to use the same zlift value for retraction/detraction settings as your Octolapse profile. It is always a good idea to include an M207 and or M208 in your start gcode if you are using firmware retract/detract so that Octolapse knows what values to use when tracking position.</span>
<p>
<span class="label label-important">Attention</span> If this setting ONLY if you are using firmware zlift! If your gcode is performing zlift manually (g0/g1) using absolute coordinates, your nozzle may crash into your part. When in doubt, leave this unchecked!.
</p>
</div>
</div>
</div>

</script>
Expand Down

0 comments on commit cb949a0

Please sign in to comment.