Пример #1
0
def scan():
    pylab.ion()
    pylab.figure(1)


    with Communicate('', None, debug=True) as serial:
        serial.timeout = 0.0001
        camera = Camera()
        camera.setupmeasure()

        controller = Controller(serial)
        controller.setupscan()

        out = []
        for x,y in controller.scan():
            camera.update()
            camera.interact()

            z = camera.measure()
            out.append([x,y,z])

            if camera.status == 'quit':
                break
            camera.show()

            if len(out) > 0:
                pylab.cla()
                tmp = zip(*out)
                sc = pylab.scatter(tmp[0],tmp[1],s=tmp[2], c=tmp[2], vmin=0, vmax=400)
                print '{: 8.3f} {: 8.3f} {: 8.3f}'.format(x,y,z)

        pylab.ioff()
        pylab.show()
Пример #2
0
def findcircles():
    '''Find the current circle closest to the center of the screen.
    this will show all circles on the screen.'''
    with Communicate('', None, debug=True) as serial:
        camera = Camera()
        controller = Controller(serial)

        while True:
            camera.update()
            camera.interact()

            # camera.status = controller.run(camera.status)
            # camera.status = controller.position(camera.status)
            if camera.status == 'quit':
                break
            else:
                camera.display(camera.status)
                camera.status = 'circle'
                camera.circle()
            #
            #
            camera.addoverlay()
            camera.show()
Пример #3
0
# Initialize the args
args = argv.arg(description='Simple python GRBL streamer', 
                getFile=True)

# Let go!
start = datetime.now()
puts(colored.blue(' Starting file: %s \n at %s'%(args.gcode.name, start)))

# read the full file and then close so that it cannot change.
# I am pretty sure even at 1M lines, I should be able to hold this in mem
lines = args.gcode.readlines()
args.gcode.close()

# get a serial device and wake up the grbl, by sending it some enters
with Communicate(args.device, args.speed, timeout=args.timeout,
                 debug=args.debug, quiet=args.quiet) as serial:

  inBuf = [] # array of length of lines in buffer
  for i,line in enumerate(progress.bar(lines)):
    # Strip comments/spaces/new line, capitalize, and add line ending
    l = re.sub('\s|\(.*?\)','',line.strip()).upper()+'\n'  

    # if 'M' in l:
    #   continue

    
    # if this was a comment or blank line just go to the next one
    if len(l.strip()) == 0:
      continue
    
    out = ''