Hugo Hu / Mbed 2 deprecated BRAVEHEART

Dependencies:   mbed N5110 ShiftReg PinDetect

Embed: (wiki syntax)

« Back to documentation index

Joystick Class Reference

Joystick class. More...

#include <InputManager.h>

Public Member Functions

 Joystick (PinName x, PinName y, PinName button)
 Creates a new Joystick object.
 ~Joystick ()
 Deconstructor.
void update ()
 Updates the current direction and button status of the joystick.
void calibrate ()
 Calibrates the joystick.
int getDirection ()
 Returns the current JoystickDirection based on last update.
int readButton ()
 Reads the value of the button.

Static Public Attributes

static const float DEAD_ZONE = 0.1
 Square set around the center of the joystick where the input is ignored.

Detailed Description

Joystick class.

Definition at line 15 of file InputManager.h.


Constructor & Destructor Documentation

Joystick ( PinName  x,
PinName  y,
PinName  button 
)

Creates a new Joystick object.

Parameters:
xPin connected to the horizontal potentiometer of the joystick
yPin connected to the vertical potentiometer of the joystick
buttonPin connected to the button of the thumb joystick

Definition at line 72 of file InputManager.cpp.

~Joystick (  )

Deconstructor.

Frees allocated memory

Definition at line 79 of file InputManager.cpp.


Member Function Documentation

void calibrate (  )

Calibrates the joystick.

The joystick must be centered while this function is called

Definition at line 88 of file InputManager.cpp.

int getDirection (  )

Returns the current JoystickDirection based on last update.

Returns:
The current JoystickDirection.

Definition at line 38 of file InputManager.h.

int readButton (  )

Reads the value of the button.

Returns:
1 if pressed, 0 otherwise

Definition at line 43 of file InputManager.h.

void update (  )

Updates the current direction and button status of the joystick.

Definition at line 96 of file InputManager.cpp.


Field Documentation

const float DEAD_ZONE = 0.1 [static]

Square set around the center of the joystick where the input is ignored.

The axes are treated seperately. Can be varied from 0 (no dead-zone) to 0.5 (max value for dx and dy).

Definition at line 46 of file InputManager.h.