Exemple #1
0
		"sin^4":servo.fourth,"sin^6":servo.sixth}
	return switcher.get(arg,"invalid")

if __name__=='__main__':
	servo = servofunctions() #creates object to control robot
	func = servo.absolute #initializes breathing pattern
	root = tk.Tk() #creates window for tkinter
	Window = MainWindow(root) #creates object to control tkinter


	# Main Loop
	while(1): 
		if(Window.UpdateCheck==1): #runs if update or start/stop has been clicked in GUI (or if exiting)
			if Window.running:
				servo.A = Window.AMP #these all take GUI values and sends them to the pattern calculations in servo
				servo.M = Window.OFF
				servo.freq = Window.BPM
				func = switch(Window.FUNC)
				servo.reset() #resets the robot to the offset
				Window.UpdateCheck = 0 #stops this branch from running multiple times without user input
			else: #resets the robot to zero position when stopped or exiting
				servo.M = 21 #21 duty cycle corresponds with 0 location
				servo.reset()
				Window.UpdateCheck = 0
				
		elif(Window.running==1):
			func() #runs selected function in servofunctions to move the robot
		
		root.update() #checks GUI for input