Skip to content
This repository has been archived by the owner on Jan 29, 2018. It is now read-only.

Remove unnedded G1 commands #228

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions public/js/laserraster.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ var endgcode;
var isLaserOn = false;
var speed;
var IsG1FSet = false;
var LastwasG1 = false;

// add MAP function to the Numbers function
Number.prototype.map = function(in_min, in_max, out_min, out_max) {
Expand Down Expand Up @@ -224,6 +225,7 @@ Rasterizer.prototype.rasterRow = function(y) {
var gcodey = (this.config.imgheight * this.config.spotSize1) - posy;
gcodey = gcodey.toFixed(3);
this.result += 'G0 Y{0}\n'.format(gcodey);
LastwasG1 = false;

// Clear grayscale values on each line change
var lastGrey = -1;
Expand Down Expand Up @@ -290,16 +292,27 @@ Rasterizer.prototype.rasterRow = function(y) {
if (laseron) {
this.result += laseron
this.result += '\n'
LastwasG1 = false; //Just in case
}
isLaserOn = true;
}
if (lastFeed != speed || IsG1FSet != true) {
// console.log("DIFF " + lastFeed + " " + speed)
this.result += 'G1 X{0} S{2} F{3}\n'.format(posx, gcodey, lastIntensity, speed);
if (LastwasG1 != true) {
this.result += 'G1 X{0} S{2} F{3}\n'.format(posx, gcodey, lastIntensity, speed);
} else {
this.result += 'X{0} S{2} F{3}\n'.format(posx, gcodey, lastIntensity, speed);
}
IsG1FSet = true;
LastwasG1 = true;
} else {
// console.log("SAME " + lastFeed + " " + speed)
this.result += 'G1 X{0} S{2}\n'.format(posx, gcodey, lastIntensity);
if (LastwasG1 != true) {
this.result += 'G1 X{0} S{2}\n'.format(posx, gcodey, lastIntensity);
} else {
this.result += 'X{0} S{2}\n'.format(posx, gcodey, lastIntensity);
}
LastwasG1 = true;
}
// if (laseroff) {
// this.result += laseroff
Expand All @@ -313,8 +326,10 @@ Rasterizer.prototype.rasterRow = function(y) {
this.result += '\n'
}
isLaserOn = false;
LastwasG1 = false; //Just in case
}
this.result += 'G0 X{0} S0\n'.format(posx, gcodey);
LastwasG1 = false;

}
}
Expand All @@ -335,6 +350,7 @@ Rasterizer.prototype.rasterRow = function(y) {
if (laseroff) {
this.result += laseroff
this.result += '\n'
LastwasG1 = false; //Just in case
}
isLaserOn = false;
this.dir = -this.dir; // Reverse direction for next row - makes us move in a more efficient zig zag down the image
Expand Down