Skip to content

Commit 02ed307

Browse files
author
Benjamin Hinchley
committed
Added docs for all the functions and sys vars
This still needs to be fleshed out a bit, and haven't tested any of the examples properly, but least gives it more of a base point now
1 parent 07cb784 commit 02ed307

File tree

1 file changed

+65
-1
lines changed

1 file changed

+65
-1
lines changed

src/input/acceleration.js

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ define(function (require){
1212

1313
/**
1414
* The system variable deviceOrientation always contains the orientation of
15-
* the device. The vaule of this varible will either be landscape or portrait.
15+
* the device. The value of this variable will either be set 'landscape'
16+
* or 'portrait'. If no data is avaliable it will be set to 'undefined'.
1617
*
1718
* @property deviceOrientation
1819
*/
@@ -69,6 +70,11 @@ define(function (require){
6970
*/
7071
p5.prototype.pAccelerationZ = 0;
7172

73+
/**
74+
* _updatePAccelerations updates the pAcceleration values
75+
*
76+
* @private
77+
*/
7278
p5.prototype._updatePAccelerations = function(){
7379
this._setProperty('pAccelerationX', this.accelerationX);
7480
this._setProperty('pAccelerationY', this.accelerationY);
@@ -77,6 +83,13 @@ define(function (require){
7783

7884
var move_threshold = 0.5;
7985

86+
/**
87+
* The setMoveThreshold() function is used to set the movement threshold for
88+
* the onDeviceMove() function.
89+
*
90+
* @method setMoveThreshold
91+
* @param {number} value The threshold value
92+
*/
8093
p5.prototype.setMoveThreshold = function(val){
8194
if(typeof val === 'number'){
8295
move_threshold = val;
@@ -86,6 +99,57 @@ define(function (require){
8699
var old_max_axis = '';
87100
var new_max_axis = '';
88101

102+
/**
103+
* The onDeviceMove() function is called when the devices orientation changes
104+
* by more than the threshold value.
105+
* @method onDeviceMove
106+
* @example
107+
* <div>
108+
* <code>
109+
* // Run this example on a mobile device
110+
* // Move the device around
111+
* // to change the value.
112+
*
113+
* var value = 0;
114+
* function draw() {
115+
* fill(value);
116+
* rect(25, 25, 50, 50);
117+
* }
118+
* function onDeviceMove() {
119+
* value = value + 5;
120+
* if (value > 255) {
121+
* value = 0;
122+
* }
123+
* }
124+
* </code>
125+
* </div>
126+
*/
127+
128+
/**
129+
* The onDeviceTurn() function is called when the device rotates by
130+
* more than 90 degrees.
131+
* @method onDeviceTurn
132+
* @example
133+
* <div>
134+
* <code>
135+
* // Run this example on a mobile device
136+
* // Rotate the device by 90 degrees
137+
* // to change the value.
138+
*
139+
* var value = 0;
140+
* function draw() {
141+
* fill(value);
142+
* rect(25, 25, 50, 50);
143+
* }
144+
* function onDeviceTurn() {
145+
* value = value + 5;
146+
* if (value > 255) {
147+
* value = 0;
148+
* }
149+
* }
150+
* </code>
151+
* </div>
152+
*/
89153
p5.prototype.ondevicemotion = function (e) {
90154
this._setProperty('accelerationX', e.accelerationIncludingGravity.x);
91155
this._setProperty('accelerationY', e.accelerationIncludingGravity.y);

0 commit comments

Comments
 (0)