I am trying to program a controller menu that shows values of different sensors by moving the controller joystick up, down, left, or right. I am coding this in python. The program compiles and downloads fine but freezes and crashes when moving the joystick at all. Some help would be appreciated.
Code:
if con.axis2.position(PercentUnits.PCT) > 10 and abs(on.axis2.position(PercentUnits.PCT)) > abs(con.axis1.position(PercentUnits.PCT)): #UP
con.screen.set_cursor(1,0)
con.screen.print_('Tray: {} ' .format(TrayPot.value(RotationUnits.DEG)))
con.screen.set_cursor(2,0)
con.screen.print_('Arm: {} ' .format(ArmPot.value(RotationUnits.DEG)))
con.screen.set_cursor(3,0)
con.screen.print_('Gyro: {} ' .format(Inertial.rotation(RotationUnits.DEG)))
elif con.axis2.position(PercentUnits.PCT) < -10 and abs(con.axis2.position(PercentUnits.PCT)) > abs(con.axis1.position(PercentUnits.PCT)): #DOWN
con.screen.set_cursor(1,0)
con.screen.print_('Auton: {} ' .format(Auton))
con.screen.set_cursor(2,0)
con.screen.print_(' ')
con.screen.set_cursor(3,0)
con.screen.print_('Arm Temp: {}C ' .format(ArmMotor.temperature(TemperatureUnits.CELSIUS)))
elif con.axis1.position(PercentUnits.PCT) > 10 and abs(con.axis1.position(PercentUnits.PCT)) > abs(con.axis2.position(PercentUnits.PCT)): #RIGHT
con.screen.set_cursor(1,0)
con.screen.print_(' ')
con.screen.set_cursor(2,0)
con.screen.print_(' Empty Menu ')
con.screen.set_cursor(3,0)
con.screen.print_(' ')
elif con.axis1.position(PercentUnits.PCT) < -10 and abs(con.axis1.position(PercentUnits.PCT)) > abs(con.axis2.position(PercentUnits.PCT)): #LEFT
con.screen.set_cursor(1,0)
con.screen.print_(' ')
con.screen.set_cursor(2,0)
con.screen.print_(' Empty Menu ')
con.screen.set_cursor(3,0)
con.screen.print_(' ')
else:
con.screen.set_cursor(1,0)
con.screen.print_(' Welcome To ')
con.screen.set_cursor(2,0)
con.screen.print_(" 1429B's Program ")
con.screen.set_cursor(3,0)
con.screen.print_(' Enjoy ')