Example #1
0
    elif o in ('-p', '--port'):
        port = a

# Show initial parameters
print "Initial parameters"
print "Steps per mm:    %3d steps" % k
print "Length extruded: %3d mm" % n
print
print "Serial port:     %s" % (port if port else 'auto')

p = None
try:
    # Connect to printer
    w("Connecting to printer..")
    try:
        p = printcore(port, 115200)
    except:
        print 'Error.'
        raise
    while not p.online:
        time.sleep(1)
        w('.')
    print " connected."

    heatup(p, temp)

    # Calibration loop
    while n != m:
        heatup(p, temp, True)
        p.send_now("G92 E0")  # Reset e axis
        p.send_now("G1 E%d F%d" % (n, s))  # Extrude length of filament
    elif o in ('-p', '--port'):
        port = a

#Show initial parameters
print "Initial parameters"
print "Steps per mm:    %3d steps" % k
print "Length extruded: %3d mm" % n
print
print "Serial port:     %s" % (port if port else 'auto')

p = None
try:
    #Connect to printer
    w("Connecting to printer..")
    try:
        p = printcore(port, 115200)
    except:
        print 'Error.'
        raise
    while not p.online:
        time.sleep(1)
        w('.')
    print " connected."

    heatup(p, temp)

    #Calibration loop
    while n != m:
        heatup(p, temp, True)
        p.send_now("G92 E0")  #Reset e axis
        p.send_now("G1 E%d F%d" % (n, s))  #Extrude length of filament
## Step 0: Present warning
w("Quality Control sometimes involves surprising printer behaviour.")
w("Localize the power plug and be ready to pull it in case uncontrolled movements or heating occurs.")
# Present "Okay" button with callback argument 0
step_completed(0)
## End of Step 0
## Step 1: Connect to printer
p = None
try:
    if not os.path.exists(port):
        prompt_for_new_port(port);
    # Present drop down menus for port and baud here
    # On try-button1 click event do:
    w("Connecting to printer..")
    try:
        p = printcore(port, baud)
    except: # Detecting the type of error here would be _really_ nice.
        print 'Unable to connect. Try again with alternative ports and bauds or contact instructor.'
        raise
    while not p.online:
        time.sleep(1)
        w('.')
    print " Success! Connected!"
    step_completed(1)
    ## End of Step 1

    ## Step 2: Move X-axis 10 mm to the right at controlled speed
    # On try-button2 click event do:
      p.send_now('G1 X10 F500')
      # Present "Yes, print head moved 10 mm to the right"-button with callback step_completed(2)
    ## End of Step 2