Skip to content
Rick Waldron edited this page May 19, 2015 · 19 revisions

The Joystick class constructs objects that represent a single Joystick sensor attached to the physical board.

This list will continue to be updated as more Joystick devices are confirmed.

Parameters

  • General Options

    Property Type Value/Description Default Required
    pins Array of Pins ["A*", ...]. Analog pins connected to X and Y yes
    invert Boolean `true false`. Invert both axes false
    invertX Boolean `true false`. Invert the X axis false
    invertY Boolean `true false`. Invert the Y axis false

Shape

{ 
  id: A user definable id value. Defaults to a generated uid
  pins: The pins defined for X and Y.
  x: -1, 1. READONLY
  y: -1, 1. READONLY
}

Component Initialization

Analog

new five.Joystick({
  // [ x, y ]
  pins: ["A0", "A1"]
});

Joystick

Adafruit Joystick

SparkFun Joystick

Axis Inversion

var joy = new Joystick({ pins: ["A0", "A1"], invertY: true });

Produces the following default axes:

    -1
-1   *   1
     1      
var joy = new Joystick({ pins: ["A0", "A1"], invertY: true });

Produces an inverted Y axis, with a default X axis:

     1
-1   *   1
    -1      
var joy = new Joystick({ pins: ["A0", "A1"], invertX: true });

Produces an inverted X axis, with a default Y axis:

   -1
1   *   -1
    1      
var joy = new Joystick({ pins: ["A0", "A1"], invert: true });

Produces an both inverted X and Y axes:

    1
1   *   -1
   -1      

API

There are no special API functions for this class.

Events

  • axismove Is an alias for "change".

  • change The "change" event is emitted whenever the value of the gyro changes more then the threshold value allows.

  • data The "data" event is fired as frequently as the user defined freq will allow in milliseconds. ("data" replaced the "read" event)

Clone this wiki locally