upm  0.4.1
Sensor/Actuator repository for libmraa (v0.8.0)
Public Member Functions | List of all members

API for the ElecFreaks* Joystick v 1.2-1.4 Breakout. More...

Detailed Description

This module defines the Joystick API, and implementation for the X and Y buttons could be treated as normal GPIO - this enables easier interrupt support. This driver should be compatible with any 2-axis analog joystick.

joystick12.jpg
// Instantiate a joystick on analog pins A0 and A1
// Print the X and Y input values every second
while(true){
float x = joystick.getXInput();
float y = joystick.getYInput();
System.out.println("Driving X: " + x + " , and Y: " + y );
Thread.sleep(1000);
}

Public Member Functions

synchronized void delete ()
 
 Joystick12 (int pinX, int pinY)
 
float getXInput ()
 
float getYInput ()
 

Constructor & Destructor Documentation

Joystick12 ( int  pinX,
int  pinY 
)

Instantiates a Joystick object

Parameters
pinXAnalog pin where the X input is connected
pinYAnalog pin where the Y input is connected

Member Function Documentation

float getXInput ( )

Gets the X input

Returns
float X value, ranging from -1 to 1; 0 is mid
float getYInput ( )

Gets the Y input

Returns
float Y value, ranging from -1 to 1; 0 is mid

The documentation for this class was generated from the following file: