|
1 import argparse |
|
2 |
|
3 def gen_speedtest(args): |
|
4 fd = open(args.file, 'wb') |
|
5 |
|
6 if args.axis.lowercase() == 'x': |
|
7 pos = [0, args.dx] |
|
8 print(fd, "G0 y%i F%i" % ( |
|
9 args.dy / 2, args.min * 60)) |
|
10 else: |
|
11 pos = [0, args.dy] |
|
12 print(fd, "G0 x%i F%i" % ( |
|
13 args.dx / 2, args.min * 60)) |
|
14 |
|
15 loops = (args.max - args.min) / args.increment |
|
16 speed = args.min |
|
17 for loop in range(loops): |
|
18 print(fd, "G0 %s%i F%i" % ( |
|
19 args.axis, pos[0], speed * 60)) |
|
20 print(fd, "G0 %s%i F%i" % ( |
|
21 args.axis, pos[1], speed * 60)) |
|
22 |
|
23 speed += args.inc |
|
24 |
|
25 fd.close() |
|
26 |
|
27 |
|
28 def main(): |
|
29 parser = argparse.ArgumentParser() |
|
30 parser.add_argument("axis", help="Define X or Y axis") |
|
31 parser.add_argument("file", help="Output gcode filename") |
|
32 parser.add_argument("--min", type=int, default=100, help="Minimum speed mm/s (100)") |
|
33 parser.add_argument("--max", type=int, default=200, help="Maximum speed mm/s (200)") |
|
34 parser.add_argument("--dx", type=int, default=200, help="Maximum X dimension (200)") |
|
35 parser.add_argument("--dy", type=int, default=200, help="Maximum Y dimension (200)") |
|
36 parser.add_argument("--inc", type=int, default=10, help="Speed increment after each line") |
|
37 |
|
38 args = parser.parse_args() |
|
39 |
|
40 gen_speedtest(args) |
|
41 |
|
42 if __name__ == '__main__': |
|
43 main() |