Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: N5110 PinDetect PowerControl mbed
Joystick Class Reference
#include <Joystick.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 17 of file Joystick.h.
Constructor & Destructor Documentation
Joystick | ( | PinName | x, |
PinName | y, | ||
PinName | button | ||
) |
Creates a new Joystick object.
- Parameters:
-
x Pin connected to the horizontal potentiometer of the joystick y Pin connected to the vertical potentiometer of the joystick button Pin connected to the button of the thumb joystick
Definition at line 7 of file Joystick.cpp.
~Joystick | ( | ) |
Member Function Documentation
void calibrate | ( | ) |
Calibrates the joystick.
The joystick must be centered while this function is called
Definition at line 23 of file Joystick.cpp.
int getDirection | ( | ) |
Returns the current JoystickDirection based on last update.
- Returns:
- The current JoystickDirection.
Definition at line 40 of file Joystick.h.
int readButton | ( | ) |
Reads the value of the button.
- Returns:
- 1 if pressed, 0 otherwise
Definition at line 45 of file Joystick.h.
void update | ( | ) |
Updates the current direction and button status of the joystick.
Definition at line 31 of file Joystick.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 48 of file Joystick.h.
Generated on Tue Jul 12 2022 21:59:48 by
