1 import argparse |
1 import argparse |
2 |
2 |
3 def gen_speedtest(args): |
3 def gen_speedtest(args): |
4 fd = open(args.file, 'wb') |
4 fd = open(args.file, 'wb') |
5 |
5 axis = args.axis.upper() |
6 if args.axis.lowercase() == 'x': |
6 if axis == 'X': |
7 pos = [0, args.dx] |
7 pos = [0, args.dx] |
8 print(fd, "G0 y%i F%i" % ( |
8 fd.write("G0 Y%.2f F%i\n" % ( |
9 args.dy / 2, args.min * 60)) |
9 args.dy / 2, args.min * 60)) |
10 else: |
10 else: |
11 pos = [0, args.dy] |
11 pos = [0, args.dy] |
12 print(fd, "G0 x%i F%i" % ( |
12 fd.write("G0 X%.2f F%i\n" % ( |
13 args.dx / 2, args.min * 60)) |
13 args.dx / 2, args.min * 60)) |
14 |
14 |
15 loops = (args.max - args.min) / args.increment |
15 loops = (args.max - args.min) / args.inc |
16 speed = args.min |
16 speed = args.min |
17 for loop in range(loops): |
17 for loop in range(loops): |
18 print(fd, "G0 %s%i F%i" % ( |
18 fd.write("G0 %s%.2f F%i\n" % ( |
19 args.axis, pos[0], speed * 60)) |
19 axis, pos[0], speed * 60)) |
20 print(fd, "G0 %s%i F%i" % ( |
20 fd.write("G0 %s%.2f F%i\n" % ( |
21 args.axis, pos[1], speed * 60)) |
21 axis, pos[1], speed * 60)) |
22 |
22 |
23 speed += args.inc |
23 speed += args.inc |
24 |
24 |
25 fd.close() |
25 fd.close() |
26 |
26 |
31 parser.add_argument("file", help="Output gcode filename") |
31 parser.add_argument("file", help="Output gcode filename") |
32 parser.add_argument("--min", type=int, default=100, help="Minimum speed mm/s (100)") |
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)") |
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)") |
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)") |
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") |
36 parser.add_argument("--inc", type=int, default=20, help="Speed increment after each line") |
37 |
37 |
38 args = parser.parse_args() |
38 args = parser.parse_args() |
39 |
39 |
40 gen_speedtest(args) |
40 gen_speedtest(args) |
41 |
41 |