#!/usr/bin/env python3 """ Brings together the different components needed to make the drawing machine chooch. """ import os import time import stream import linedraw def draw(rec_filename): """ Takes the filename received from the bluetooth server, vectorizes it and streams the resulting G-code to the GRBL controller. """ print("Vectorizing " + rec_filename + "...") then = time.time() linedraw.sketch(rec_filename) print("Done! Took", "%.3f" % (time.time() - then), "seconds") gcode_filename = rec_filename.replace("received", "converted") gcode_filename = os.path.splitext(gcode_filename)[0] + ".ngc" print("Streaming " + gcode_filename + "...") then = time.time() stream.stream(gcode_filename) print("Done! Took", "%.3f" % (time.time() - then), "seconds") if __name__ == "__main__": import argparse parser = argparse.ArgumentParser( description="Vectorizes the given image and streams the resultant" \ + "G-code to GRBL.") parser.add_argument( "filename", help="The path to the image to be drawn.") args = parser.parse_args() draw(args.filename)