This commit is contained in:
ChrisTerBeke 2017-11-24 10:31:30 +01:00
commit 46a575b84f
4 changed files with 47 additions and 36 deletions

View file

@ -58,6 +58,7 @@ class GCodeReader(MeshReader):
self._layer_data_builder = LayerDataBuilder.LayerDataBuilder() self._layer_data_builder = LayerDataBuilder.LayerDataBuilder()
self._center_is_zero = False self._center_is_zero = False
self._is_absolute_positioning = True # It can be absolute (G90) or relative (G91) self._is_absolute_positioning = True # It can be absolute (G90) or relative (G91)
self._is_absolute_extrusion = True # It can become absolute (M82, default) or relative (M83)
@staticmethod @staticmethod
def _getValue(line, code): def _getValue(line, code):
@ -185,11 +186,11 @@ class GCodeReader(MeshReader):
f = params.f if params.f is not None else f f = params.f if params.f is not None else f
if params.e is not None: if params.e is not None:
new_extrusion_value = params.e if self._is_absolute_positioning else e[self._extruder_number] + params.e new_extrusion_value = params.e if self._is_absolute_extrusion else e[self._extruder_number] + params.e
if new_extrusion_value > e[self._extruder_number]: if new_extrusion_value > e[self._extruder_number]:
path.append([x, y, z, f, params.e + self._extrusion_length_offset[self._extruder_number], self._layer_type]) # extrusion path.append([x, y, z, f, new_extrusion_value + self._extrusion_length_offset[self._extruder_number], self._layer_type]) # extrusion
else: else:
path.append([x, y, z, f, params.e + self._extrusion_length_offset[self._extruder_number], LayerPolygon.MoveRetractionType]) # retraction path.append([x, y, z, f, new_extrusion_value + self._extrusion_length_offset[self._extruder_number], LayerPolygon.MoveRetractionType]) # retraction
e[self._extruder_number] = new_extrusion_value e[self._extruder_number] = new_extrusion_value
# Only when extruding we can determine the latest known "layer height" which is the difference in height between extrusions # Only when extruding we can determine the latest known "layer height" which is the difference in height between extrusions
@ -201,6 +202,7 @@ class GCodeReader(MeshReader):
path.append([x, y, z, f, e[self._extruder_number] + self._extrusion_length_offset[self._extruder_number], LayerPolygon.MoveCombingType]) path.append([x, y, z, f, e[self._extruder_number] + self._extrusion_length_offset[self._extruder_number], LayerPolygon.MoveCombingType])
return self._position(x, y, z, f, e) return self._position(x, y, z, f, e)
# G0 and G1 should be handled exactly the same. # G0 and G1 should be handled exactly the same.
_gCode1 = _gCode0 _gCode1 = _gCode0
@ -209,6 +211,7 @@ class GCodeReader(MeshReader):
return self._position( return self._position(
params.x if params.x is not None else position.x, params.x if params.x is not None else position.x,
params.y if params.y is not None else position.y, params.y if params.y is not None else position.y,
0, 0,
position.f, position.f,
position.e) position.e)
@ -271,6 +274,14 @@ class GCodeReader(MeshReader):
position.e.extend([0] * (self._extruder_number - len(position.e) + 1)) position.e.extend([0] * (self._extruder_number - len(position.e) + 1))
return position return position
def _processMCode(self, m):
if m == 82:
# Set absolute extrusion mode
self._is_absolute_extrusion = True
elif m == 83:
# Set relative extrusion mode
self._is_absolute_extrusion = False
_type_keyword = ";TYPE:" _type_keyword = ";TYPE:"
_layer_keyword = ";LAYER:" _layer_keyword = ";LAYER:"
@ -407,6 +418,10 @@ class GCodeReader(MeshReader):
current_position = self._processTCode(T, line, current_position, current_path) current_position = self._processTCode(T, line, current_position, current_path)
if line.startswith("M"):
M = self._getInt(line, "M")
self._processMCode(M)
# "Flush" leftovers. Last layer paths are still stored # "Flush" leftovers. Last layer paths are still stored
if len(current_path) > 1: if len(current_path) > 1:
if self._createPolygon(self._current_layer_thickness, current_path, self._extruder_offsets.get(self._extruder_number, [0, 0])): if self._createPolygon(self._current_layer_thickness, current_path, self._extruder_offsets.get(self._extruder_number, [0, 0])):

View file

@ -8,7 +8,7 @@
"author": "Dagoma", "author": "Dagoma",
"manufacturer": "Dagoma", "manufacturer": "Dagoma",
"file_formats": "text/x-gcode", "file_formats": "text/x-gcode",
"icon": "icon_ultimaker2.png", "icon": "icon_discoeasy200.png",
"platform": "discoeasy200.stl", "platform": "discoeasy200.stl",
"platform_offset": [ 105, -59, 280] "platform_offset": [ 105, -59, 280]
}, },
@ -30,24 +30,23 @@
}, },
"machine_head_with_fans_polygon": { "machine_head_with_fans_polygon": {
"default_value": [ "default_value": [
[16, 37], [17, 70],
[16, -65], [17, -40],
[-16, -65], [-17, -40],
[16, 37] [17, 70]
] ]
}, },
"gantry_height": { "gantry_height": {
"default_value": 55 "default_value": 10
},
"machine_gcode_flavor": {
"default_value": "RepRap"
}, },
"machine_start_gcode": { "machine_start_gcode": {
"default_value": ";Gcode by Cura\nG90 ;absolute positioning\nM106 S250 ;fan on for the palpeur\nG28 X Y\nG1 X50\nM109 S180\nG28\nM104 S{print_temperature}\n;Activation palpeur\n;bloc palpeur\nG29 ;Auto level\nM107 ;start with the fan off\nG1 X100 Y20 F3000\nG1 Z0.5\nM109 S{print_temperature}\nM140 S{material_bed_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 F3000\n" "default_value": ";Gcode by Cura\nG90 ;absolute positioning\nM106 S250 ;fan on for the palpeur\nG28 X Y\nG1 X50\nM109 S180\nG28\nM104 S{material_print_temperature_layer_0}\n;Activation palpeur\n;bloc palpeur\nG29 ;Auto level\nM107 ;start with the fan off\nG1 X100 Y20 F3000\nG1 Z0.5\nM109 S{material_print_temperature_layer_0}\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 F6000"
}, },
"machine_end_gcode": { "machine_end_gcode": {
"default_value": "\nM104 S0\nM106 S255 ;start fan full power\nM140 S0 ;heated bed heater off (if you have it)\n;Home machine\nG91 ;relative positioning\nG1 E-1 F{retraction_speed} ;retract the filament a bit before lifting the nozzle, to release some of the pressure\nG1 Z+3 F3000 ;move Z up a bit and retract filament even more\nG90\nG28 X Y\n;Ventilation forcee\nM107 ;stop fan\n;Shut down motor\nM84 ;shut down motors\n" "default_value": "M104 S0\nM106 S255 ;start fan full power\nM140 S0 ;heated bed heater off (if you have it)\n;Home machine\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 F3000 ;move Z up a bit and retract filament even more\nG90\nG28 X Y\n;Ventilation forcee\nM107 ;stop fan\n;Shut down motor\nM84 ;shut down motors"
},
"material_diameter": {
"default_value": 1.75
} }
} }
} }

View file

@ -45,6 +45,14 @@ Item {
} }
} }
function sliceOrStopSlicing() {
if ([1, 5].indexOf(UM.Backend.state) != -1) {
backend.forceSlice();
} else {
backend.stopSlicing();
}
}
Label { Label {
id: statusLabel id: statusLabel
width: parent.width - 2 * UM.Theme.getSize("sidebar_margin").width width: parent.width - 2 * UM.Theme.getSize("sidebar_margin").width
@ -86,6 +94,10 @@ Item {
if (saveToButton.enabled) { if (saveToButton.enabled) {
saveToButton.clicked(); saveToButton.clicked();
} }
// prepare button
if (prepareButton.enabled) {
sliceOrStopSlicing();
}
} }
} }
@ -145,7 +157,7 @@ Item {
Button { Button {
id: prepareButton id: prepareButton
tooltip: UM.OutputDeviceManager.activeDeviceDescription; tooltip: catalog.i18nc("@info:tooltip","Slice");
// 1 = not started, 2 = Processing // 1 = not started, 2 = Processing
enabled: (base.backendState == 1 || base.backendState == 2) && base.activity == true enabled: (base.backendState == 1 || base.backendState == 2) && base.activity == true
visible: { visible: {
@ -162,11 +174,7 @@ Item {
text: [1, 5].indexOf(UM.Backend.state) != -1 ? catalog.i18nc("@label:Printjob", "Prepare") : catalog.i18nc("@label:Printjob", "Cancel") text: [1, 5].indexOf(UM.Backend.state) != -1 ? catalog.i18nc("@label:Printjob", "Prepare") : catalog.i18nc("@label:Printjob", "Cancel")
onClicked: onClicked:
{ {
if ([1, 5].indexOf(UM.Backend.state) != -1) { sliceOrStopSlicing();
backend.forceSlice();
} else {
backend.stopSlicing();
}
} }
style: ButtonStyle { style: ButtonStyle {

View file

@ -343,7 +343,6 @@ Rectangle
onEntered: onEntered:
{ {
if(base.printDuration.valid && !base.printDuration.isTotalDurationZero) if(base.printDuration.valid && !base.printDuration.isTotalDurationZero)
{ {
// All the time information for the different features is achieved // All the time information for the different features is achieved
@ -356,20 +355,10 @@ Rectangle
{ {
if(!print_time[feature].isTotalDurationZero) if(!print_time[feature].isTotalDurationZero)
{ {
var feature_name = ""; content += "<tr><td colspan='2'>" + feature + "</td></tr>" +
"<tr>" +
if (feature.length <= 11) "<td width='60%'>" + print_time[feature].getDisplayString(UM.DurationFormat.Short) + "</td>" +
{ "<td width='40%'>&nbsp;&nbsp;" + Math.round(100 * parseInt(print_time[feature].getDisplayString(UM.DurationFormat.Seconds)) / total_seconds) + "%" +
feature_name = feature
}
else{
feature_name = feature.substring(0, 8) + "..."
}
content += "<tr><td>" + feature_name + ":" +
"&nbsp;&nbsp;</td><td>" + print_time[feature].getDisplayString(UM.DurationFormat.Short) +
"&nbsp;&nbsp;</td><td>" + Math.round(100 * parseInt(print_time[feature].getDisplayString(UM.DurationFormat.Seconds)) / total_seconds) + "%" +
"</td></tr>"; "</td></tr>";
} }
} }