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) { turnFanOn(fanSpeed) {
this._isFanOn = true; this._isFanOn = true;
const gcode = { [M_COMMAND]: 106 } const gcode = { [M_COMMAND]: 106 };
if (typeof fanSpeed !== 'undefined') gcode[FAN_SPEED] = fanSpeed; if (typeof fanSpeed !== 'undefined') gcode[FAN_SPEED] = fanSpeed;
this._addGCode(gcode); this._addGCode(gcode);

View File

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

View File

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