From 4482bf1f7349f08bd6baa7d90010dbbe0add2a0a Mon Sep 17 00:00:00 2001 From: casperlamboo Date: Mon, 29 Jan 2018 15:15:27 +0100 Subject: [PATCH] compensate for higher layer height --- src/constants.js | 2 +- src/sliceActions/helpers/GCode.js | 11 ++++++++--- src/sliceActions/slicesToGCode.js | 8 +++----- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/constants.js b/src/constants.js index f1ec128..17803b6 100644 --- a/src/constants.js +++ b/src/constants.js @@ -2,4 +2,4 @@ export const PRECISION = 0.01; export const VERSION = '0.0.18'; export const LOCAL_STORAGE_KEY = 'PRINTER_SETTINGS'; export const MIN_AREA = 1; // holes smaller as 1mm2 get removed -export const Z_OFFSET = 0.15; +export const Z_OFFSET = 0.3; diff --git a/src/sliceActions/helpers/GCode.js b/src/sliceActions/helpers/GCode.js index ea51272..233a5f9 100644 --- a/src/sliceActions/helpers/GCode.js +++ b/src/sliceActions/helpers/GCode.js @@ -11,9 +11,8 @@ export const POSITION_Y = 'Y'; export const POSITION_Z = 'Z'; export default class { - constructor(nozzleToFilamentRatio) { - this._nozzleToFilamentRatio = nozzleToFilamentRatio; - + constructor(layerHeight) { + this._nozzleToFilamentRatio = 1; this._gcode = [`; Generated with Doodle3D Slicer V${VERSION}`]; this._currentValues = {}; this._nozzlePosition = new THREE.Vector2(0, 0); @@ -27,6 +26,12 @@ export default class { this._gcode.push(command); } + updateLayerHeight(layerHeight, nozzleDiameter, filamentThickness) { + const filamentSurfaceArea = Math.pow((filamentThickness / 2), 2) * Math.PI; + const lineSurfaceArea = nozzleDiameter * layerHeight; + this._nozzleToFilamentRatio = lineSurfaceArea / filamentSurfaceArea; + } + turnFanOn(fanSpeed) { this._isFanOn = true; diff --git a/src/sliceActions/slicesToGCode.js b/src/sliceActions/slicesToGCode.js index e794499..1b7aa98 100644 --- a/src/sliceActions/slicesToGCode.js +++ b/src/sliceActions/slicesToGCode.js @@ -15,11 +15,8 @@ export default function slicesToGCode(slices, settings) { combing } = settings; - const filamentSurfaceArea = Math.pow((filamentThickness / 2), 2) * Math.PI; - const lineSurfaceArea = nozzleDiameter * layerHeight; - const nozzleToFilamentRatio = lineSurfaceArea / filamentSurfaceArea; - - const gcode = new GCode(nozzleToFilamentRatio); + const gcode = new GCode(); + gcode.updateLayerHeight(Z_OFFSET, nozzleDiameter, filamentThickness) if (settings.startCode) gcode.addGCode(settings.startCode, settings); @@ -34,6 +31,7 @@ export default function slicesToGCode(slices, settings) { const z = layer * layerHeight + Z_OFFSET; if (layer === 1) { + gcode.updateLayerHeight(layerHeight, nozzleDiameter, filamentThickness); gcode.turnFanOn(); isFirstLayer = false; }