joystick
#include <Joystick.h>
Public Member Functions | |
| Joystick (PinName b, PinName h, PinName v) | |
| Constructor: Joystick. | |
| joyhv | read () |
| Function: read Read the joystick position, represented as a joyhv value - h and v are doubles in the range [0.0, 1.0]. | |
| double | getV () |
| Function: getV Read the joystick's vertical position, represented as a double value in the range [0.0, 1.0]. | |
| double | getH () |
| Function: getH Read the joystick's horizontal position, represented as a double value in the range [0.0, 1.0]. | |
| void | rise (void(*fptr)(void)) |
| Function: rise Attach a function to call when a rising edge occurs on the button input. | |
| void | fall (void(*fptr)(void)) |
| Function: fall Attach a function to call when a falling edge occurs on the button input. | |
| operator joyhv () | |
| Function: operator joyhv An operator shorthand for <read()>. | |
Class: Joystick.
Used for reading from an analog joystick
Example:
> include "mbed.h"
> Joystick joy(p20, p19, p18);
Definition at line 28 of file Joystick.h.
| Joystick | ( | PinName | b, | |
| PinName | h, | |||
| PinName | v | |||
| ) |
Constructor: Joystick.
Variables: b - DigitalIn pin for button h - AnalogIn pin for horizontal v - AnalogIn pin for vertical
Definition at line 49 of file Joystick.cpp.
| void fall | ( | void(*)(void) | fptr | ) |
Function: fall Attach a function to call when a falling edge occurs on the button input.
Variables: fptr - A pointer to a void function, or 0 to set as none
Definition at line 71 of file Joystick.cpp.
| double getH | ( | ) |
Function: getH Read the joystick's horizontal position, represented as a double value in the range [0.0, 1.0].
Variables: returns - A double values representing the horizontal position of the joystick, measured as a percentage
Definition at line 63 of file Joystick.cpp.
| double getV | ( | ) |
Function: getV Read the joystick's vertical position, represented as a double value in the range [0.0, 1.0].
Variables: returns - A double values representing the vertical position of the joystick, measured as a percentage
Definition at line 59 of file Joystick.cpp.
| operator joyhv | ( | ) |
Function: operator joyhv An operator shorthand for <read()>.
The joyhv() operator can be used as a shorthand for <read()> to simplify common code sequences
Definition at line 52 of file Joystick.cpp.
| joyhv read | ( | ) |
Function: read Read the joystick position, represented as a joyhv value - h and v are doubles in the range [0.0, 1.0].
Variables: returns - A structure of two double values representing the position of the joystick, measured as a percentage vertically (joyhv.v) or horizontally (joyhv.h)
| void rise | ( | void(*)(void) | fptr | ) |
Function: rise Attach a function to call when a rising edge occurs on the button input.
Variables: fptr - A pointer to a void function, or 0 to set as none
Definition at line 67 of file Joystick.cpp.