def stop(self): """Stops the elevator, and flips direction for smoother stopping.""" if self.direction is OUTPUT.MOTOR_UP: io.setBit(OUTPUT.MOTORDIR,OUTPUT.MOTOR_DOWN) elif self.direction is OUTPUT.MOTOR_DOWN: io.setBit(OUTPUT.MOTORDIR,OUTPUT.MOTOR_UP) io.write(OUTPUT.MOTOR,2048)
def stop(self): """Stops the elevator, and flips direction for smoother stopping.""" if self.direction is OUTPUT.MOTOR_UP: io.setBit(OUTPUT.MOTORDIR, OUTPUT.MOTOR_DOWN) elif self.direction is OUTPUT.MOTOR_DOWN: io.setBit(OUTPUT.MOTORDIR, OUTPUT.MOTOR_UP) io.write(OUTPUT.MOTOR, 2048)
def move(self,direction,speed=1000): """Asks the motor to move in a given direction and with a given speed. direction -- OUTPUT.MOTOR_UP or OUTPUT.MOTOR_DOWN, tells the direction to move in. speed -- Defaults to 1000. Used for debugging purposes only. """ self.direction = direction if (speed > 0): io.setBit(OUTPUT.MOTORDIR,direction) elif (speed < 0): io.setBit(OUTPUT.MOTORDIR,direction) io.write(OUTPUT.MOTOR,2048 + 2*abs(speed))
def move(self, direction, speed=1000): """Asks the motor to move in a given direction and with a given speed. direction -- OUTPUT.MOTOR_UP or OUTPUT.MOTOR_DOWN, tells the direction to move in. speed -- Defaults to 1000. Used for debugging purposes only. """ self.direction = direction if (speed > 0): io.setBit(OUTPUT.MOTORDIR, direction) elif (speed < 0): io.setBit(OUTPUT.MOTORDIR, direction) io.write(OUTPUT.MOTOR, 2048 + 2 * abs(speed))
def stop(self): """Stops the elevator, and flips direction for smoother stopping.""" if not self.moving: return self.moving = False sleep(0.16) if self.direction is OUTPUT.MOTOR_UP: io.setBit(OUTPUT.MOTORDIR,OUTPUT.MOTOR_DOWN) elif self.direction is OUTPUT.MOTOR_DOWN: io.setBit(OUTPUT.MOTORDIR,OUTPUT.MOTOR_UP) io.write(OUTPUT.MOTOR,2048 + 1000) sleep(0.01) io.write(OUTPUT.MOTOR,2048) self.moving = False