Skip to content

Commit

Permalink
definition: fix speed travel base unit in GCode
Browse files Browse the repository at this point in the history
See Ultimaker/Cura#1507 for more info
  • Loading branch information
ubitux committed Mar 8, 2017
1 parent db24918 commit 5422ba2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def _get_gcode_field(section, field_name):
field_map = {
# old name new name
'{print_temperature}': '{material_print_temperature}',
'{travel_speed}': '{speed_travel}',
'{travel_speed}': "' + str(speed_travel * 60) + '",
'{z_offset}': '0.5', # FIXME
}

Expand All @@ -29,7 +29,7 @@ def _get_gcode_field(section, field_name):

lines.append(line.strip())

return {'default_value': '\n'.join(lines)}
return {'value': "'%s'" % '\\n'.join(lines)}

def _get_default_dict(xml_node, field_name, field_type=str):
return {'default_value': field_type(xml_node.find(field_name).text)}
Expand Down Expand Up @@ -203,10 +203,12 @@ def _pp_definition(definition_data):

overrides = {}
for key, data in definition_data['overrides'].items():
if key in ('machine_start_gcode', 'machine_end_gcode'):
overrides[key] = data
continue
if default_values[key] != data['default_value']:
overrides[key] = data
if key not in ('machine_start_gcode', 'machine_end_gcode'):
print('{}: {} -> {}'.format(key, default_values[key], data['default_value']))
print('{}: {} -> {}'.format(key, default_values[key], data['default_value']))
definition_data['overrides'] = overrides
return definition_data

Expand Down
4 changes: 2 additions & 2 deletions output/definitions/dagoma_discoeasy200.def.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@
]
},
"machine_start_gcode": {
"default_value": "G90 ;absolute positioning\nM106 S250 ;fan on for the palpeur\nG28 X Y\nG1 X50\nM109 S180\nG28\nM104 S{material_print_temperature}\nM107 ;start with the fan off\nG1 X100 Y20 F3000\nG1 Z0.5\nM109 S{material_print_temperature}\nM82 ;set extruder to absolute mode\nG92 E0 ;zero the extruded length\nG1 F200 E10 ;extrude 10mm of feed stock\nG92 E0 ;zero the extruded length again\nG1 Z3\nG1 F{speed_travel}"
"value": "'G90 ;absolute positioning\\nM106 S250 ;fan on for the palpeur\\nG28 X Y\\nG1 X50\\nM109 S180\\nG28\\nM104 S{material_print_temperature}\\nM107 ;start with the fan off\\nG1 X100 Y20 F3000\\nG1 Z0.5\\nM109 S{material_print_temperature}\\nM82 ;set extruder to absolute mode\\nG92 E0 ;zero the extruded length\\nG1 F200 E10 ;extrude 10mm of feed stock\\nG92 E0 ;zero the extruded length again\\nG1 Z3\\nG1 F' + str(speed_travel * 60) + ''"
},
"machine_end_gcode": {
"default_value": "M104 S0\nM106 S255 ;start fan full power\nM140 S0 ;heated bed heater off (if you have it)\nG91 ;relative positioning\nG1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure\nG1 Z+3 F{speed_travel} ;move Z up a bit and retract filament even more\nG90\nG28 X Y\nM107 ;stop fan\nM84 ;shut down motors"
"value": "'M104 S0\\nM106 S255 ;start fan full power\\nM140 S0 ;heated bed heater off (if you have it)\\nG91 ;relative positioning\\nG1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure\\nG1 Z+3 F' + str(speed_travel * 60) + ' ;move Z up a bit and retract filament even more\\nG90\\nG28 X Y\\nM107 ;stop fan\\nM84 ;shut down motors'"
},
"retraction_speed": {
"default_value": 50
Expand Down

0 comments on commit 5422ba2

Please sign in to comment.