From 6f51701c344fece9476cba5a47d33ca8801691b4 Mon Sep 17 00:00:00 2001 From: Jamie Date: Sun, 16 Aug 2020 15:26:10 -0500 Subject: [PATCH] Fix wonky generation on retraction prints Was subtracting only integer part of gcode, which inverts the fractional part and produces jagged lines whenever X or Y becomes negative. --- js/gcodeprocessing.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/js/gcodeprocessing.js b/js/gcodeprocessing.js index 35a8669..15d550d 100644 --- a/js/gcodeprocessing.js +++ b/js/gcodeprocessing.js @@ -234,17 +234,17 @@ function processRetraction(){ if(centre == true){ var retractionArray = retraction.split(/\n/g); - var regexp = /X\d+/; + var regexp = /X[0-9\.]+/; retractionArray.forEach(function(index, item){ if(retractionArray[item].search(/X/) > -1){ - var value = parseInt(retractionArray[item].match(regexp)[0].substring(1)) - 50; + var value = parseFloat(retractionArray[item].match(regexp)[0].substring(1)) - 50; retractionArray[item] = retractionArray[item].replace(regexp, "X"+String(value)); } }); - var regexp = /Y\d+/; + var regexp = /Y[0-9\.]+/; retractionArray.forEach(function(index, item){ if(retractionArray[item].search(/Y/) > -1){ - var value = parseInt(retractionArray[item].match(regexp)[0].substring(1)) - 50; + var value = parseFloat(retractionArray[item].match(regexp)[0].substring(1)) - 50; retractionArray[item] = retractionArray[item].replace(regexp, "Y"+String(value)) } }); @@ -537,4 +537,4 @@ function processAcceleration(){ acceleration = acceleration.replace(/j6/g, "M205 J"+f4); } downloadFile('acceleration.gcode', acceleration); -} \ No newline at end of file +}