Skip to content

Commit 04642e3

Browse files
committed
t
1 parent e98ed9a commit 04642e3

File tree

11 files changed

+715
-837
lines changed

11 files changed

+715
-837
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
*.o
33
*.obj
44

5-
5+
win/
6+
winbin/
67
Unity/
78
BK/
89
ggcode
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
2+
// // GGcode test file
3+
let id = 2345
4+
5+
note {
6+
╔═╗╔═╗┌─┐┌─┐┌┬┐┌─┐ File compiled : [ggcode_file_name]
7+
║ ╦║ ╦│ │ │ ││├┤ Timestamp : [time]
8+
╚═╝╚═╝└─┘└─┘─┴┘└─┘ Program ID: [id]
9+
10+
Basic Square Pocket - ontinuous Spiral Cut
11+
}
12+
13+
G90 G94 G17
14+
G20
15+
G53 G0 Z0
16+
T1 M6
17+
S6000 M3
18+
G54
19+
M8
20+
21+
let pocket_width = 20 // total width of pocket
22+
let pocket_height = 20 // total height of pocket
23+
let step_over = 1 // tool stepover per inward pass
24+
let z_safe = 5
25+
let z_cut = -1
26+
let feed = 300
27+
let round_eps = 0.0001
28+
29+
// === Rounding helpers ===
30+
function r3(n) {
31+
return floor(n * 1000 + 0.5) / 1000
32+
}
33+
function rz(n) {
34+
if (abs(n) < round_eps) { return 0 }
35+
return r3(n)
36+
}
37+
38+
// === Pocket Bounds (centered) ===
39+
let min_x = -pocket_width / 2
40+
let max_x = pocket_width / 2
41+
let min_y = -pocket_height / 2
42+
let max_y = pocket_height / 2
43+
44+
// === Move to start ===
45+
G0 Z[z_safe]
46+
G0 X[rz(min_x)] Y[rz(min_y)]
47+
G1 Z[z_cut] F[feed]
48+
49+
// === Continuous Spiral Path ===
50+
while ((max_x - min_x > step_over * 2) && (max_y - min_y > step_over * 2)) {
51+
52+
G1 X[rz(max_x)] Y[rz(min_y)] F[feed]
53+
G1 X[rz(max_x)] Y[rz(max_y)] F[feed]
54+
G1 X[rz(min_x)] Y[rz(max_y)] F[feed]
55+
G1 X[rz(min_x)] Y[rz(min_y)] F[feed]
56+
57+
min_x = min_x + step_over
58+
max_x = max_x - step_over
59+
min_y = min_y + step_over
60+
max_y = max_y - step_over
61+
}
62+
63+
// === End ===
64+
G0 Z[z_safe]
65+
G0 X0 Y0
66+
67+
68+
69+
70+
71+
72+
73+
74+
75+
76+
77+

examples/Cube Grid.ggcode

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
// // GGcode test file
2+
// /* This GGcode comment does not get compiled */
3+
let id = 22222
4+
let test = 69
5+
6+
note {
7+
╔═╗╔═╗┌─┐┌─┐┌┬┐┌─┐ File compiled : [ggcode_file_name]
8+
║ ╦║ ╦│ │ │ ││├┤ Timestamp : [time]
9+
╚═╝╚═╝└─┘└─┘─┴┘└─┘ Program ID: [id]
10+
Test Value: [test]
11+
}
12+
13+
let baseX = 1
14+
let baseY = 1
15+
let size = 2
16+
let offset = 3
17+
let z_start = 0
18+
let z_step = -0.05
19+
let z_final = -0.5
20+
let liftZ = 1
21+
let feed = 120
22+
23+
// G90 G94 G17
24+
// G20
25+
// G53 G0 Z0
26+
// T1 M6
27+
// S6000 M3
28+
// G54
29+
// M8
30+
31+
note {EXPECT: Loop 30 x 10 grid, each with 30 Z-depth passes}
32+
33+
for j = 0..10 {
34+
for i = 0..10 {
35+
x = baseX + i * offset
36+
y = baseY + j * offset
37+
38+
note {Start square [i],[j] at X[x] Y[y]}
39+
G0 X[x] Y[y]
40+
G43 Z[0] H[1]
41+
G0 Z[liftZ]
42+
43+
for pass = 1..30 {
44+
let z = z_start + pass * z_step
45+
note {Pass [pass] > Z[z]}
46+
G1 Z[z] F[feed]
47+
G1 X[x + size] Y[y]
48+
G1 X[x + size] Y[y + size]
49+
G1 X[x] Y[y + size]
50+
G1 X[x] Y[y]
51+
G0 Z[liftZ]
52+
}
53+
54+
note {Final finish pass on square [i],[j]}
55+
G1 Z[z_final] F[feed]
56+
G1 X[x + size] Y[y]
57+
G1 X[x + size] Y[y + size]
58+
G1 X[x] Y[y + size]
59+
G1 X[x] Y[y]
60+
G0 Z[liftZ]
61+
}
62+
}
63+
64+
65+
66+
67+
68+
69+
70+
71+
72+
73+
74+
75+
76+
77+
78+
79+
80+
81+
82+
83+
84+
85+
86+
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
2+
// // GGcode test file
3+
let id = 2345
4+
5+
note {
6+
╔═╗╔═╗┌─┐┌─┐┌┬┐┌─┐ File compiled : [ggcode_file_name]
7+
║ ╦║ ╦│ │ │ ││├┤ Timestamp : [time]
8+
╚═╝╚═╝└─┘└─┘─┴┘└─┘ Program ID: [id]
9+
10+
Accurate Flower of Life - Pure Hex Packing
11+
}
12+
13+
G90 G94 G17
14+
G20
15+
G53 G0 Z0
16+
T1 M6
17+
S6000 M3
18+
G54
19+
M8
20+
21+
22+
23+
note {Accurate Flower of Life - Pure Hex Packing Without Modulo}
24+
25+
let radius = 5
26+
let z_safe = 5
27+
let z_cut = -1
28+
let feed = 300
29+
let step_deg = 10
30+
let deg_to_rad = DEG_TO_RAD
31+
let round_eps = 0.0001
32+
33+
let step_angle = step_deg
34+
let spacing_x = radius * 1.0
35+
let spacing_y = radius * sqrt(3) / 2
36+
37+
let cols = 13
38+
let rows = 13
39+
40+
G0 Z[z_safe]
41+
42+
// Loop rows and columns
43+
for row = 0..4 {
44+
for col = 0..4 {
45+
// Offset every other row by half-x spacing (using math instead of mod)
46+
half_shift = (row - floor(row / 2) * 2) * 0.5 * spacing_x
47+
48+
cx = (col * spacing_x) + half_shift - (cols * spacing_x / 2)
49+
cy = (row * spacing_y) - (rows * spacing_y / 2)
50+
51+
// Draw circle at (cx, cy)
52+
angle = 0
53+
raw_x = cx + radius * cos(angle * deg_to_rad)
54+
raw_y = cy + radius * sin(angle * deg_to_rad)
55+
x = floor(raw_x * 1000 + 0.5) / 1000
56+
y = floor(raw_y * 1000 + 0.5) / 1000
57+
G0 X[x] Y[y]
58+
G1 Z[z_cut] F[feed]
59+
60+
for i = 1..360 {
61+
angle = i * step_angle
62+
raw_x = cx + radius * cos(angle * deg_to_rad)
63+
raw_y = cy + radius * sin(angle * deg_to_rad)
64+
x = floor(raw_x * 1000 + 0.5) / 1000
65+
y = floor(raw_y * 1000 + 0.5) / 1000
66+
if (abs(x) < round_eps) { x = 0 }
67+
if (abs(y) < round_eps) { y = 0 }
68+
G1 X[x] Y[y] F[feed]
69+
}
70+
71+
G0 Z[z_safe]
72+
}
73+
}
74+
75+
76+
77+

0 commit comments

Comments
 (0)