forked from JesseScott/OriginalGCode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgcode.pde
49 lines (45 loc) · 1.77 KB
/
gcode.pde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//-----------------------------------------------------------------------------------------
// Parse Blob Vertices to GCode via txt file
void gc() {
if (detect == true) {
Blob b;
EdgeVertex gcA,gcB;
for (int n = 0 ; n < theBlobDetection.getBlobNb() ; n++) {
if (blbs[n] == true){
b = theBlobDetection.getBlob(n);
if (b!=null) {
for (int m = 0; m < b.getEdgeNb(); m++) {
gcA = b.getEdgeVertexA(m);
gcB = b.getEdgeVertexB(m);
if (gcA != null && gcB != null) {
if(export == true) {
frameRate(1);
// Mirror Horizontal
float revX = 1 - gcA.x;
// XY
if(m == 0) {
// Move to the First Point
output.println("G0" + " " + "X " + revX * cam.width + " " + "Y " + gcA.y * cam.height);
// Move Laser Down
output.println("G1 Z " + gcZDN);
// Set Feed Rate of CNC
output.println("F" + gcFeed);
}
else if(m > 0) {
// This is the main body of the path
output.println("G1" + " " + "X " + revX * cam.width + " " + "Y " + gcA.y * cam.height);
}
}
frameRate(30);
}
}
// Bring Laser Up
output.println("G1 Z " + gcZUP);
output.println("G0 Z " + gcZUP);
output.println(" "); // Give a space so we can easily read where shapes end
}
}
}
}
}
//-----------------------------------------------------------------------------------------