Sunday, August 3, 2014

Joystick Axis control with Pygame

Raspberry Pi joystick Pygames

As blogged before the screen image position controlling with joystick button are done. The good thing about electronic devices are that there will be many more things to explore further .Joy stick works as coordinates of the axis when we move it. Looks like its values moves from 1.0 to -1.0 . I am interested to control the screen image with this axis rather than buttons in the joystick.

Looking further on the documentation in Pygame - http://www.pygame.org/docs/ref/joystick.html


get_axis()
get the current position of an axis
get_axis(axis_number) -> float
Returns the current position of a joystick axis. The value will range from -1 to 1 with a value of 0 being centered. You may want to take into account some tolerance to handle jitter, and joystick drift may keep the joystick from centering at 0 or using the full range of position values.

The axis number must be an integer from zero to get_numaxes()-1.



No comments: