diff --git a/axi/main.py b/axi/main.py index 85d8cd6..b2e56c4 100644 --- a/axi/main.py +++ b/axi/main.py @@ -7,7 +7,7 @@ TODO: axi (repl) ''' -def main(): +def main_old(): args = sys.argv[1:] if len(args) == 0: return @@ -45,5 +45,42 @@ def main(): else: pass +def main() : + parser = argparse.ArgumentParser(description='Command line utility for interacting with axidraw') + parser.add_argument('command', type=str.lower, help='Command for the axidraw') + + args = parser.parse_args() + if command == 'render': + d = axi.Drawing.load(args[0]) + d = d.rotate_and_scale_to_fit(12, 8.5, step=90) + path = args[1] if len(args) > 1 else 'out.png' + im = d.render() + im.write_to_png(path) + return + device = axi.Device() + if command == 'zero': + device.zero_position() + elif command == 'home': + device.home() + elif command == 'up': + device.pen_up() + elif command == 'down': + device.pen_down() + elif command == 'on': + device.enable_motors() + elif command == 'off': + device.disable_motors() + elif command == 'move': + dx, dy = map(float, args) + device.move(dx, dy) + elif command == 'goto': + x, y = map(float, args) + device.goto(x, y) + elif command == 'draw': + d = axi.Drawing.load(args[0]) + axi.draw(d) + else: + pass + if __name__ == '__main__': main()