Skip to content

Commit

Permalink
Fixed Joystick issue
Browse files Browse the repository at this point in the history
Happy Independence day!
  • Loading branch information
ProgramDragon64 committed Jul 4, 2022
1 parent ac7ba63 commit c463dc7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Larry/conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ def sign(num) -> int:
return 0

def convertJoystickInputToDegrees(x: float, y: float): # this allows us to use the x and y values on the joystick and convert it into degrees
return float(math.degrees(math.atan2(y, x)))
if sign(x) == -1:
return float(math.degrees(math.atan2(x, -y)) + 360.0) # this will make sure that it gives us a number between 0 and 360
else:
if float(math.degrees(math.atan2(x, -y))) == 360.0: #This makes sure that if we get 360.0 degrees, it will be zero
return 0.0
else:
return float(math.degrees(math.atan2(x, -y))) # the degrees, the joystick up is zero and the values increase clock-wise

def deadband(value: float, band: float):
# this makes sure that joystick drifting is not an issue.
Expand Down

0 comments on commit c463dc7

Please # to comment.