-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcorrected_text_printer.ggcode
More file actions
93 lines (80 loc) · 2.78 KB
/
corrected_text_printer.ggcode
File metadata and controls
93 lines (80 loc) · 2.78 KB
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
50
51
52
53
54
55
56
57
58
59
60
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
87
88
89
90
91
92
93
// Corrected Function-Based Text Printer
// Simple function approach that should work with GGCODE
note {=== Corrected Text Printer ===}
let safe_z = 2
// Simple text printing function
function print_text(pos_x, pos_y, message, char_size, char_gap) {
note {Printing text: [message]}
note {Position: X[pos_x] Y[pos_y]}
note {Size: [char_size], Gap: [char_gap]}
let current_x = pos_x
let width = char_size
let height = char_size * 1.5
for letter in message {
note {Drawing: [letter]}
if letter == "H" {
// Draw H
G0 Z[safe_z] X[current_x - width/2] Y[pos_y - height/2]
G0 Z[0]
G1 X[current_x - width/2] Y[pos_y + height/2]
G0 Z[safe_z]
G0 X[current_x + width/2] Y[pos_y - height/2]
G0 Z[0]
G1 X[current_x + width/2] Y[pos_y + height/2]
G0 Z[safe_z]
G0 X[current_x - width/2] Y[pos_y]
G0 Z[0]
G1 X[current_x + width/2] Y[pos_y]
G0 Z[safe_z]
}
if letter == "E" {
// Draw E
G0 Z[safe_z] X[current_x - width/2] Y[pos_y - height/2]
G0 Z[0]
G1 X[current_x - width/2] Y[pos_y + height/2]
G1 X[current_x + width/2] Y[pos_y + height/2]
G0 Z[safe_z]
G0 X[current_x - width/2] Y[pos_y]
G0 Z[0]
G1 X[current_x + width/2] Y[pos_y]
G0 Z[safe_z]
G0 X[current_x - width/2] Y[pos_y - height/2]
G0 Z[0]
G1 X[current_x + width/2] Y[pos_y - height/2]
G0 Z[safe_z]
}
if letter == "L" {
// Draw L
G0 Z[safe_z] X[current_x - width/2] Y[pos_y - height/2]
G0 Z[0]
G1 X[current_x - width/2] Y[pos_y + height/2]
G0 Z[safe_z]
G0 X[current_x - width/2] Y[pos_y - height/2]
G0 Z[0]
G1 X[current_x + width/2] Y[pos_y - height/2]
G0 Z[safe_z]
}
if letter == "O" {
// Draw O
G0 Z[safe_z] X[current_x - width/2] Y[pos_y - height/2]
G0 Z[0]
G1 X[current_x - width/2] Y[pos_y + height/2]
G1 X[current_x + width/2] Y[pos_y + height/2]
G1 X[current_x + width/2] Y[pos_y - height/2]
G1 X[current_x - width/2] Y[pos_y - height/2]
G0 Z[safe_z]
}
if letter == " " {
// Space - no drawing
note {Space}
}
// Move to next position
current_x = current_x + width + char_gap
}
}
// Test the function
note {=== Testing Function ===}
print_text(0, 0, "HELLO", 8, 2)
// Return to safe position
G0 Z[safe_z] X[0] Y[0]
note {=== Complete ===}