from overdrive import Overdrive from tkinter import* from tkinter import messagebox top = Tk() def locationChangeCallback(addr, location, piece, speed, clockwise): # Print out addr, piece ID, location ID of the vehicle, this print everytime when location changed print("Location from " + addr + " : " + "Piece=" + str(piece) + " Location=" + str(location) + " Clockwise=" + str(clockwise)) car = Overdrive("F6:ED:77:8C:70:CA") car.setLocationChangeCallback(locationChangeCallback) # Set location change callback to function above car.changeSpeed(750, 1000) # Set car speed with speed = 500, acceleration = 1000 car.changeLaneRight(1000, 1000) # Switch to next right lane with speed = 1000, acceleration = 1000 def StopCar(): car.changeSpeed(0, 100) msg = messagebox.showinfo("Car Stopped", "Car Stop Command Sent") top.geometry("500x500") B = Button(top, text="Stop Car", command=StopCar) B.place(x = 50, y = 50) top.mainloop()
from overdrive import Overdrive def locationChangeCallback(addr, params): # Print out addr, piece ID, location ID of the vehicle, this print everytime when location changed print( "Location from {addr} : Piece={piece} Location={location} Clockwise={clockwise}" .format(addr=addr, **params)) car = Overdrive("xx:xx:xx:xx:xx:xx") car.setLocationChangeCallback( locationChangeCallback) # Set location change callback to function above car.changeSpeed(500, 500) # Set car speed with speed = 500, acceleration = 500 car.changeLaneRight( 500, 500) # Switch to next right lane with speed = 500, acceleration = 500 input() # Hold the program so it won't end abruptly
'Location from {addr} : Piece={piece} Location={location} Speed={speed} Clockwise={clockwise}' .format(**params)) car.setLocationChangeCallback(locationChangeCallback) def transitionChangeCallback(addr, params): params['addr'] = addr print('Transition from {addr} From={piecePrev} To={piece} Offset={offset}'. format(**params)) car.setTransitionCallback(transitionChangeCallback) car.changeSpeed(500, 800) while True: inpt = input( '[ to change lane to left, ] to change lane to right, enter to stop.\n' ) if inpt == '[': car.changeLaneLeft(500, 800) elif inpt == ']': car.changeLaneRight(500, 800) else: break car.changeSpeed(0, 800) car.disconnect()