def __init__(self, debug=False): self.GPIO = GPIO self.i2c = i2c self.debug = debug self.linear_actuator_l = linear_actuator.Linear_Actuator('L', debug) self.linear_actuator_r = linear_actuator.Linear_Actuator('R', debug) self.wheel_l = wheel.Wheel("L", self.linear_actuator_l, debug) self.wheel_r = wheel.Wheel("L", self.linear_actuator_r, debug) # outputs self.i2c.pinMode(config.I2C_OUT_OR_SEAT, 1) self.i2c.pinMode(config.I2C_OUT_OR_BRAKE, 1) self.i2c.pinMode(config.I2C_OUT_OR_ARMS, 1) self.i2c.pinMode(config.I2C_OUT_OR_IGNITION, 1) self.i2c.pinMode(config.I2C_OUT_OR_BLADES, 1) self.i2c.digitalWrite(config.I2C_OUT_OR_SEAT, False) self.i2c.digitalWrite(config.I2C_OUT_OR_BRAKE, False) self.i2c.digitalWrite(config.I2C_OUT_OR_ARMS, False) self.i2c.digitalWrite(config.I2C_OUT_OR_IGNITION, False) self.i2c.digitalWrite(config.I2C_OUT_OR_BLADES, False) self.engine_state = False #inputs self.i2c.pinMode(config.I2C_IN_OR_SEAT, 0) self.i2c.pinMode(config.I2C_IN_OR_BRAKE, 0) #self.i2c.pinMode(config.I2C_IN_OR_ARMS, 0) #self.i2c.pinMode(config.I2C_IN_OR_IGNITION, 0) self.i2c.pinMode(config.I2C_IN_OR_BLADES, 0)
def __init__(self, left_wheel_ports, right_wheel_ports, debug=False): if debug: import wheel_base self._left_wheel = wheel_base.WheelBase('Left wheel', left_wheel_ports) self._right_wheel = wheel_base.WheelBase('Right wheel', right_wheel_ports) else: import wheel self._left_wheel = wheel.Wheel('Left wheel', left_wheel_ports) self._right_wheel = wheel.Wheel('Right wheel', right_wheel_ports) self._left_direction = 0 self._right_direction = 0 self._run = True threading.Thread.__init__(self)
def setUpWheel(wsp): name = wsp["name"] e = wsp["e"] f = wsp["f"] r = wsp["r"] print("Wheel {} e:{} f:{} r:{}".format(name, e, f, r)) return W.Wheel(e,f,r)
def createWindow(self, controller): #username label and text entry box username_label = tk.Label(self, text="User Name: ") # username_label.grid(row=0, column=0) username_label.pack() username = tk.StringVar() username_entry = tk.Entry(self, textvariable=username) # user has to press enter/return key after typing in their username username_entry.bind("<Return>", lambda event: self.checkUsername(username.get())) username_entry.pack() #password label and password entry box password_label = tk.Label(self, text="Password: "******"both", expand=True) # create wheel wheel = w.Wheel() wheel.create(canvas) # bind keyboard input to this frame self.focus_set() self.bind( "<Key>", lambda event: self.keyPress(event, wheel, canvas, password_canvas)) #login button # need to bind this with a function that validates credentials validate = partial(self.validateLogin, password_canvas) submit_button = tk.Button(self, text="Login", command=validate) submit_button.pack() # buttons for navigating between windows button1 = tk.Button(self, text="Back to Home", command=lambda: controller.show_frame(StartPage)) button1.pack(side=LEFT, pady=20) button2 = tk.Button(self, text="Register", command=lambda: controller.show_frame(Register)) button2.pack(side=LEFT, pady=20)
def wheels(self): # create image dictionary self.images = { 1: PhotoImage(file="bell.png"), 2: PhotoImage(file="grape.png"), 3: PhotoImage(file="cherry.png") } # create random number object to determine image to be displayed wheel_image = wheel.Wheel() # First Wheel self.wheel1 = wheel_image.spin() if self.wheel1 == 1: first_image = self.images[1] elif self.wheel1 == 2: first_image = self.images[2] else: first_image = self.images[3] first_wheel = Label(self.main_window, image=first_image) first_wheel.grid(row=1, sticky="W") # Second Wheel self.wheel2 = wheel_image.spin() if self.wheel2 == 1: second_image = self.images[1] elif self.wheel2 == 2: second_image = self.images[2] else: second_image = self.images[3] second_wheel = Label(self.main_window, image=second_image) second_wheel.grid(row=1) # Third Wheel self.wheel3 = wheel_image.spin() if self.wheel3 == 1: third_image = self.images[1] elif self.wheel3 == 2: third_image = self.images[2] else: third_image = self.images[3] third_wheel = Label(self.main_window, image=third_image) third_wheel.grid(row=1, sticky="E")
class Vehicle(ABC): __speed = 0 __name = '' __color = '' __wheel = wheel.Wheel() def __init__(self): data = '' __speed = 0 __name = '' __color = '' @abstractmethod def setName(self, n): #self.__name = n pass def getName(self): #return self.__name pass def setColor(self, c): #self.__color = c pass def getColor(self): pass #return self.__color def setSpeed(self, s): #self.__speed = s pass def getSpeed(self): #return self.__speed pass def brake(self): #self.__speed = 0 pass
def setUp(self): self.wheel = wheel.Wheel() self.table = table.Table(minimum=10, maximum=1000) self.game = roulette_game.RouletteGame(self.wheel, self.table) self.player = roulette_cancellation.RouletteCancellation( table=self.table, wheel=self.wheel)
def add_wheel(self, mass, position, radius=0, torque=0): w = wheel.Wheel(mass, position, radius, torque) self.wheel_list.append(w)
def __init__(self, app): self.app = app self.board = board.Board(app) self.wheel = wheel.Wheel(app) self.scoreboard = scoreboard.Scoreboard(app) self.backgroundImage = pygame.image.load("resources/background.jpg")
print("lights on" if pressed else "lights off") def on_high_beam(pressed): print("highbeam on" if pressed else "highbeam off") def on_windshied_wiper(pressed): print("wipers on" if pressed else "wipers off") def on_gear_shift(gear): print gear, "gear" g27 = wheel.Wheel() g27.register_steering_wheel(on_angle) g27.register_pedal(g27.config.ACCELERATOR, handle_accelerator) g27.register_pedal(g27.config.BRAKE, handle_brake) g27.register_pedal(g27.config.CLUTCH, handle_clutch) g27.register_button(g27.config.IGNITION, on_ignition) g27.register_button(g27.config.PARKING_BRAKE, on_parking_brake) g27.register_button(g27.config.HEADLAMP, on_headlamp) g27.register_button(g27.config.HIGH_BEAM, on_high_beam) g27.register_button(g27.config.WINDSHIELD_WIPER, on_windshied_wiper) g27.register_gear_shift(on_gear_shift) print(g27.steering_wheel.angle) g27.steering_wheel.angle = 0 print(g27.steering_wheel.angle)
def setUp(self): self.wheel = wheel.Wheel() self.table = table.Table(minimum=10, maximum=1000) self.game = roulette_game.RouletteGame(self.wheel, self.table) self.player = roulette_fibonacci.RouletteFibonacci(table=self.table, wheel=self.wheel)