Skip to content

Commit

Permalink
Fix wrong extrusion calculation.
Browse files Browse the repository at this point in the history
I noticed the test used the wrong filament diameter before (175 instead of 1750). That confused me. Now I corrected the test and also the extrusion calculation.
  • Loading branch information
aligator committed Feb 14, 2021
1 parent 88552fc commit cbe1f62
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gcode/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (g *Builder) String() string {

func (g *Builder) SetExtrusion(layerThickness, lineWidth data.Micrometer) {
filamentArea := math.Pi * (g.filamentDiameter.ToMillimeter() / 2.0) * (g.filamentDiameter.ToMillimeter() / 2.0)
g.extrusionPerMM = (layerThickness.ToMillimeter() * lineWidth.ToMillimeter() / filamentArea) * (data.Millimeter(g.extrusionMultiplier))
g.extrusionPerMM = (layerThickness.ToMillimeter() * lineWidth.ToMillimeter() / filamentArea) * (data.Millimeter(g.extrusionMultiplier) / 100)
}

func (g *Builder) SetMoveSpeed(moveSpeed data.Millimeter) {
Expand Down
6 changes: 3 additions & 3 deletions gcode/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func TestGCodeBuilder(t *testing.T) {
test.Ok(t, err)
},
expected: "G0 X0.00 Y0.00\n" +
"G1 X0.00 Y10.00 E33.2601\n",
"G1 X0.00 Y10.00 E0.3326\n",
},

"set extrusion with over extrusion": {
Expand All @@ -181,7 +181,7 @@ func TestGCodeBuilder(t *testing.T) {
test.Ok(t, err)
},
expected: "G0 X0.00 Y0.00\n" +
"G1 X0.00 Y10.00 E49.8902\n",
"G1 X0.00 Y10.00 E0.4989\n",
},

"set extrusion with under extrusion": {
Expand All @@ -195,7 +195,7 @@ func TestGCodeBuilder(t *testing.T) {
test.Ok(t, err)
},
expected: "G0 X0.00 Y0.00\n" +
"G1 X0.00 Y10.00 E16.6301\n",
"G1 X0.00 Y10.00 E0.1663\n",
},
}

Expand Down

0 comments on commit cbe1f62

Please sign in to comment.