-
Notifications
You must be signed in to change notification settings - Fork 5
Orientation
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 Orientation. Each Orientation fieldset will have subordinate input elements mapping to the three axes. This example:
<form id="sampleBoard" data-device-type="board">
<fieldset id="myOrientator" data-device-type="orientation">
<input type="range" data-device-type="servo" id="myBeta" data-axis="beta" />
<input type="range" 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.
| 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.
| 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 | Servo | Type of BrowserControl | yes |
| data-axis | String | alpha | beta | gamma | The axis this device should be bound to | yes |
| data-thresholds | Comma separated integers | min,max | The minimum and maximum allowed input values | yes |
| Plus all valid Range attributes... | ||||
Child of of Window.nodebotui
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.
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.