def main(): platform = Platform() recipe = Recipe() # Step 0: Preform hard reset to calibrate platform position during startup #platform.hard_Reset() # Step 1: get recipe from user either from onboard gui or android app #sampleRecipe = sys.argv[1] sampleRecipe = "1,19.3,2,19.3,3,19.3,4,19.3,5,19.3,6,19.3,7,19.3,8,19.3,true" # Step 2: split recipe string to a stack of seperate ingredients recipe.initilize_Stack(sampleRecipe) # Step 3: specify the order of the recipe if recipe.isOrdered == True: recipeOrder = recipe.recipeStack else: recipeOrder = platform.get_Shortest_Path(recipe) hbridge.turnOff() time.sleep(.3) # Step 4: interate over each ingredient then move platform for ingred in recipeOrder: print "Getting %rmL of segment %r" %(ingred.mL, ingred.segNum) #segNum is NOT 0 indexed platform.move_To_Segment(platform.segList[ingred.segNum-1].name) time.sleep(WAIT) # Step 5: once platform reached its mark, pour amount hbridge.turnOn() time.sleep(.2) Actuator.actuate(Actuator.actDict[ingred.segNum-1], float(ingred.mL)) hbridge.turnOff() time.sleep(WAIT) # Step 6: repeat step 4 till stack is empty # Step 7: Move platform back to the middle print "Final offset: %r " % Platform.offset platform.reset()
def get_braille(text): global priority global def_priority global speed if (priority == 2): print("Decoding as per grade 2") braille = GD2.braille.process_word(text) if (braille == 1): priority = 1 if (priority == 1): print("Decoding as per grade 1") braille = GD1.braille.encode_braille(text) print("Given word: " + text) print("Braille converted text: ") print_braille(braille) for i in braille: Actuator.actuate(i) sleep(speed) Actuator.set_all_low() sleep(0.4 * speed) print(" ") priority = def_priority