Exemple #1
0
def init():
    global joystick
    joystick = Joystick(0)

    crossbow = JoystickButton(joystick, 5)
    crossbow_in_hold = JoystickButton(joystick, 6)

    solenoid_intake = JoystickButton(joystick, 1)

    crossbow.whenPressed(Crossbow(0.8, 1))
    crossbow_in_hold.whenPressed(Crossbow(-0.6, 1.75))

    solenoid_intake.whenPressed(PullIntake())

    intake = JoystickButton(joystick, 4)
    intake.toggleWhenPressed(Intake())
class OI():
    
    backwardsButton = False
    backwardsToggle = False
    
    
    def __init__(self):
        self.joystick = wpilib.Joystick(robotMap.JOYSTICK)
        self.gamepad = wpilib.Joystick(robotMap.GAMEPAD)
        self.winchToggle = JoystickButton(self.joystick, robotMap.WINCHTOGGLE)
        from commands import teleClimb
        self.winchToggle.toggleWhenPressed(teleClimb.TeleClimb())
        
    def getLeftSpeed(self):
        return self.gamepad.getRawAxis(robotMap.LEFTDRIVECONTROL)
        
    def getRightSpeed(self):
        return self.gamepad.getRawAxis(robotMap.RIGHTDRIVECONTROL)

    def backwardsCheck(self):
        if (self.backwardsButton and not self.gamepad.getRawButton(robotMap.REVERSE)):
            self.backwardsButton = False
        elif (not self.backwardsButton and self.gamepad.getRawButton(robotMap.REVERSE)) :
            self.backwardsButton = True
            self.backwardsToggle = not self.backwardsToggle

    def getBackwards(self): 
        return self.backwardsToggle
    

    def getSlowDown(self):
        return self.gamepad.getRawButton(robotMap.SLOWDOWN)
    
    def getWinchSpeed(self):
        return self.joystick.getRawAxis(robotMap.WINCH)
    
    def getPOV(self):
        return self.gamepad.getPOV()