Orientation - dtex/NodebotUI GitHub Wiki

back

The Orientation class constructs an object that maps to one, two or three inputs. All devices with deviceOrientation will output data on the beta and gamma axes. Only devices with a compass will send data for the alpha axis.

Orientation is represented in the HTML by a <fieldset> element that has a unique ID attribute and a data-device-type attribute of one of Orientation. This example:

<form id="sampleBoard" data-device-type="board">
  <fieldset id="myOrientator" data-device-type="orientation">
    <input data-device-type="servo" id="myBeta" data-axis="beta" />
    <input data-device-type="servo" id="myGamma" data-axis="gamma" />
  </fieldset>
</form>

will initialize a board in the NodebotUI server, create an Orientation BrowserControl and bind servos to the beta and gamma axes. When you tilt your device, the servos will move.

Parameters

Attribute Name Type Value(s) Description Required
id String Any string that starts with an alpha or _ A unique identifier. This value must not be used on any other element yes
data-device-type String Orientation Type of BrowserControl yes

An Orientation <fieldset> can have one, two or three subordinate <input type="range"> elements. These may be bound to any device that can be associated with a range, and each must have a 'data-axis' attribute specifying wether it is bound to rotation around the alpha(Y), beta(X) or gamma(Z) axis.

API

Lineage

Child of of Window.nodebotui

Properties

Orientation.inputMin - Int, -180 through 180, default -90 The minimum input value for all three axes.

Orientation.inputMax - Int, -180 through 180, default 90 The maximum output value for all three axes.

Methods

Orientation._listen() - Bind an event listener on the deviceOrientation that updates the subordinate input fields. This is called automatically on page load and should not need to be called by the user.

Orientation._update() -

Orientation._initialize() - Traverse the DOM and find all subordinate input elements, and associate their Input objects with the appropriate axes. This is called automatically on page load and should not need to be called by the user.

back

⚠️ **GitHub.com Fallback** ⚠️