2018-03-21 11:06:44 -04:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
"""
|
|
|
|
Brings together the different components needed to make the drawing
|
|
|
|
machine chooch.
|
|
|
|
"""
|
|
|
|
import os
|
2018-03-28 22:43:26 -04:00
|
|
|
import time
|
2018-03-21 11:06:44 -04:00
|
|
|
|
|
|
|
import stream
|
2018-03-21 12:00:46 -04:00
|
|
|
import linedraw
|
2018-03-21 11:06:44 -04:00
|
|
|
|
|
|
|
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 + "...")
|
2018-03-28 22:43:26 -04:00
|
|
|
then = time.time()
|
2018-03-21 11:06:44 -04:00
|
|
|
linedraw.sketch(rec_filename)
|
2018-03-28 22:43:26 -04:00
|
|
|
print("Done! Took", "%.3f" % (time.time() - then), "seconds")
|
2018-03-21 11:06:44 -04:00
|
|
|
gcode_filename = rec_filename.replace("received", "converted")
|
|
|
|
gcode_filename = os.path.splitext(gcode_filename)[0] + ".ngc"
|
|
|
|
print("Streaming " + gcode_filename + "...")
|
2018-03-28 22:43:26 -04:00
|
|
|
then = time.time()
|
2018-03-21 11:06:44 -04:00
|
|
|
stream.stream(gcode_filename)
|
2018-03-28 22:43:26 -04:00
|
|
|
print("Done! Took", "%.3f" % (time.time() - then), "seconds")
|
2018-03-21 11:06:44 -04:00
|
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|