This commit is contained in:
Casper Lamboo 2018-04-03 11:38:49 +02:00
parent 701d736cc0
commit 6be1291923
3 changed files with 9 additions and 19 deletions

View File

@ -38,7 +38,7 @@ export default class GCode {
turnFanOn(fanSpeed) {
this._isFanOn = true;
const gcode = { [M_COMMAND]: 106 }
const gcode = { [M_COMMAND]: 106 };
if (typeof fanSpeed !== 'undefined') gcode[FAN_SPEED] = fanSpeed;
this._addGCode(gcode);

View File

@ -14,19 +14,11 @@ import { hslToRgb } from './helpers/color.js';
// // import removePrecision from './removePrecision.js';
export default function(settings, geometry, openObjectIndexes, constructLinePreview, onProgress) {
const totalStages = 11;
let current = -1;
const updateProgress = (action) => {
current ++;
if (typeof onProgress !== 'undefined') {
onProgress({
progress: {
done: current,
total: totalStages,
action
}
});
}
const total = 11;
let done = -1;
const updateProgress = action => {
done ++;
if (onProgress) onProgress({ progress: { done, total, action } });
};
updateProgress('Constructing unique lines from geometry');
@ -70,9 +62,9 @@ export default function(settings, geometry, openObjectIndexes, constructLinePrev
return gcode;
}
const PRECISION_INVERSE = 1000;
const PRECISION = 1000;
function toFixedTrimmed(value) {
return (Math.round(value * PRECISION_INVERSE) / PRECISION_INVERSE).toString();
return (Math.round(value * PRECISION) / PRECISION).toString();
}
function gcodeToString(gcode) {

View File

@ -96,9 +96,7 @@ function sliceAsync(settings, geometry, openObjectIndexes, constructLinePreview,
break;
}
case 'PROGRESS': {
if (typeof onProgress !== 'undefined') {
onProgress(data);
}
if (typeof onProgress !== 'undefined') onProgress(data);
break;
}
}