tools/axis_speedtest.py

Wed, 20 Jan 2021 10:17:01 +0100

author
mdd
date
Wed, 20 Jan 2021 10:17:01 +0100
changeset 47
dcc64b767b64
parent 41
08d027d2a532
permissions
-rw-r--r--

updated pronterface.py losing my own changes

import argparse

def gen_speedtest(args):
    fd = open(args.file, 'wb')
    axis = args.axis.upper()
    if axis == 'X':
        pos = [0, args.dx]
        fd.write("G0 Y%.2f F%i\n" % (
            args.dy / 2, args.min * 60))
    else:
        pos = [0, args.dy]
        fd.write("G0 X%.2f F%i\n" % (
            args.dx / 2, args.min * 60))

    loops = (args.max - args.min) / args.inc
    speed = args.min
    for loop in range(loops):
        fd.write("G0 %s%.2f F%i\n" % (
            axis, pos[0], speed * 60))
        fd.write("G0 %s%.2f F%i\n" % (
            axis, pos[1], speed * 60))

        speed += args.inc

    fd.close()


def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("axis", help="Define X or Y axis")
    parser.add_argument("file", help="Output gcode filename")
    parser.add_argument("--min", type=int, default=100, help="Minimum speed mm/s (100)")
    parser.add_argument("--max", type=int, default=200, help="Maximum speed mm/s (200)")
    parser.add_argument("--dx", type=int, default=200, help="Maximum X dimension (200)")
    parser.add_argument("--dy", type=int, default=200, help="Maximum Y dimension (200)")
    parser.add_argument("--inc", type=int, default=20, help="Speed increment after each line")

    args = parser.parse_args()

    gen_speedtest(args)

if __name__ == '__main__':
    main()

mercurial