4 |
5 |
6 |
7 | Juego
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/COPYRIGHT:
--------------------------------------------------------------------------------
1 | The following copyright message should appear at the top of all
2 | source files. This file can be removed from your repository.
3 |
4 | Copyright (c) 2015 Adobe Systems Incorporated. All rights reserved.
5 |
6 | Licensed under the Apache License, Version 2.0 (the "License");
7 | you may not use this file except in compliance with the License.
8 | You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing, software
13 | distributed under the License is distributed on an "AS IS" BASIS,
14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | See the License for the specific language governing permissions and
16 | limitations under the License.
17 |
--------------------------------------------------------------------------------
/plugins/cordova-plugin-device-motion/www/Acceleration.js:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | *
20 | */
21 |
22 | var Acceleration = function(x, y, z, timestamp) {
23 | this.x = x;
24 | this.y = y;
25 | this.z = z;
26 | this.timestamp = timestamp || (new Date()).getTime();
27 | };
28 |
29 | module.exports = Acceleration;
30 |
--------------------------------------------------------------------------------
/hooks/README.md:
--------------------------------------------------------------------------------
1 |
21 | # Cordova Hooks
22 |
23 | Cordova Hooks represent special scripts which could be added by application and plugin developers or even by your own build system to customize cordova commands. See Hooks Guide for more details: http://cordova.apache.org/docs/en/edge/guide_appdev_hooks_index.md.html#Hooks%20Guide.
24 |
--------------------------------------------------------------------------------
/plugins/cordova-plugin-device-motion/tests/plugin.xml:
--------------------------------------------------------------------------------
1 |
2 |
20 |
21 |
24 | Cordova Device Motion Plugin Tests
25 | Apache 2.0
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/plugins/cordova-plugin-device-motion/src/ios/CDVAccelerometer.h:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to the Apache Software Foundation (ASF) under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. The ASF licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 | */
19 |
20 | #import
21 | #import
22 |
23 | @interface CDVAccelerometer : CDVPlugin
24 | {
25 | double x;
26 | double y;
27 | double z;
28 | NSTimeInterval timestamp;
29 | }
30 |
31 | @property (readonly, assign) BOOL isRunning;
32 | @property (nonatomic, strong) NSString* callbackId;
33 |
34 | - (CDVAccelerometer*)init;
35 |
36 | - (void)start:(CDVInvokedUrlCommand*)command;
37 | - (void)stop:(CDVInvokedUrlCommand*)command;
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/plugins/cordova-plugin-device-motion/src/firefoxos/accelerometer.js:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | *
20 | */
21 |
22 | function listener(success, ev) {
23 | var acc = ev.accelerationIncludingGravity;
24 | acc.timestamp = new Date().getTime();
25 | success(acc);
26 | }
27 |
28 | var Accelerometer = {
29 | start: function start(success, error) {
30 | return window.addEventListener('devicemotion', function(ev) {
31 | listener(success, ev);
32 | }, false);
33 | },
34 |
35 | stop: function stop() {
36 | window.removeEventListener('devicemotion', listener, false);
37 | }
38 | };
39 |
40 | module.exports = Accelerometer;
41 | require('cordova/exec/proxy').add('Accelerometer', Accelerometer);
42 |
--------------------------------------------------------------------------------
/plugins/cordova-plugin-device-motion/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 |
21 |
22 | # Contributing to Apache Cordova
23 |
24 | Anyone can contribute to Cordova. And we need your contributions.
25 |
26 | There are multiple ways to contribute: report bugs, improve the docs, and
27 | contribute code.
28 |
29 | For instructions on this, start with the
30 | [contribution overview](http://cordova.apache.org/contribute/).
31 |
32 | The details are explained there, but the important items are:
33 | - Sign and submit an Apache ICLA (Contributor License Agreement).
34 | - Have a Jira issue open that corresponds to your contribution.
35 | - Run the tests so your patch doesn't break existing functionality.
36 |
37 | We look forward to your contributions!
38 |
--------------------------------------------------------------------------------
/plugins/cordova-plugin-device-motion/src/ubuntu/accelerometer.h:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing,
10 | * software distributed under the License is distributed on an
11 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
12 | * KIND, either express or implied. See the License for the
13 | * specific language governing permissions and limitations
14 | * under the License.
15 | *
16 | */
17 |
18 | #ifndef ACCELEROMETER_H
19 | #define ACCELEROMETER_H
20 |
21 | #include
22 | #include
23 | #include
24 |
25 | class DeviceMotion: public CPlugin {
26 | Q_OBJECT
27 | public:
28 | explicit DeviceMotion(Cordova *cordova);
29 |
30 | virtual const QString fullName() override {
31 | return DeviceMotion::fullID();
32 | }
33 |
34 | virtual const QString shortName() override {
35 | return "Accelerometer";
36 | }
37 |
38 | static const QString fullID() {
39 | return "Accelerometer";
40 | }
41 |
42 | public slots:
43 | void start(int scId, int ecId);
44 | void stop(int scId, int ecId);
45 |
46 | protected slots:
47 | void updateSensor();
48 |
49 | private:
50 | int _scId, _ecId;
51 | bool _sensorAvaliable;
52 | QSharedPointer _accelerometerSource;
53 | };
54 |
55 | #endif
56 |
--------------------------------------------------------------------------------
/plugins/cordova-plugin-device-motion/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "cordova-plugin-device-motion",
3 | "version": "1.2.2",
4 | "description": "Cordova Device Motion Plugin",
5 | "cordova": {
6 | "id": "cordova-plugin-device-motion",
7 | "platforms": [
8 | "firefoxos",
9 | "android",
10 | "amazon-fireos",
11 | "ubuntu",
12 | "ios",
13 | "blackberry10",
14 | "wp7",
15 | "wp8",
16 | "windows8",
17 | "windows",
18 | "tizen",
19 | "browser"
20 | ]
21 | },
22 | "repository": {
23 | "type": "git",
24 | "url": "https://github.com/apache/cordova-plugin-device-motion"
25 | },
26 | "keywords": [
27 | "cordova",
28 | "device",
29 | "motion",
30 | "ecosystem:cordova",
31 | "cordova-firefoxos",
32 | "cordova-android",
33 | "cordova-amazon-fireos",
34 | "cordova-ubuntu",
35 | "cordova-ios",
36 | "cordova-blackberry10",
37 | "cordova-wp7",
38 | "cordova-wp8",
39 | "cordova-windows8",
40 | "cordova-windows",
41 | "cordova-tizen",
42 | "cordova-browser"
43 | ],
44 | "scripts": {
45 | "test": "npm run jshint",
46 | "jshint": "node node_modules/jshint/bin/jshint www && node node_modules/jshint/bin/jshint src && node node_modules/jshint/bin/jshint tests"
47 | },
48 | "author": "Apache Software Foundation",
49 | "license": "Apache-2.0",
50 | "engines": {
51 | "cordovaDependencies": {
52 | "2.0.0": {
53 | "cordova": ">100"
54 | }
55 | }
56 | },
57 | "devDependencies": {
58 | "jshint": "^2.6.0"
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/plugins/cordova-plugin-device-motion/src/browser/AccelerometerProxy.js:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | *
20 | */
21 |
22 |
23 | function listener(success) {
24 | var accel = {};
25 |
26 | accel.x = (Math.round(((Math.random() * 2) - 1) * 100) / 100);
27 | accel.y = (Math.round(((Math.random() * 2) - 1) * 100) / 100);
28 | accel.z = (Math.round(((Math.random() * 2) - 1) * 100) / 100);
29 | accel.timestamp = new Date().getTime();
30 |
31 | success(accel);
32 |
33 | window.removeEventListener('devicemotion', listener, false);
34 | }
35 |
36 | var Accelerometer = {
37 | start: function start(success, error) {
38 | return window.addEventListener('devicemotion', function(){
39 | listener(success);
40 | }, false);
41 | }
42 | };
43 |
44 | module.exports = Accelerometer;
45 | require('cordova/exec/proxy').add('Accelerometer', Accelerometer);
46 |
--------------------------------------------------------------------------------
/plugins/cordova-plugin-device-motion/src/blackberry10/index.js:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | *
20 | */
21 |
22 | /* global PluginResult */
23 |
24 | var callback;
25 |
26 | module.exports = {
27 | start: function (success, fail, args, env) {
28 | var result = new PluginResult(args, env);
29 | window.removeEventListener("devicemotion", callback);
30 | callback = function (motion) {
31 | var info = {
32 | x: motion.accelerationIncludingGravity.x,
33 | y: motion.accelerationIncludingGravity.y,
34 | z: motion.accelerationIncludingGravity.z,
35 | timestamp: motion.timestamp
36 | };
37 | result.callbackOk(info, true);
38 | };
39 | window.addEventListener("devicemotion", callback);
40 | result.noResult(true);
41 | },
42 | stop: function (success, fail, args, env) {
43 | var result = new PluginResult(args, env);
44 | window.removeEventListener("devicemotion", callback);
45 | result.ok("removed");
46 | }
47 | };
48 |
--------------------------------------------------------------------------------
/plugins/cordova-plugin-device-motion/src/ubuntu/accelerometer.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing,
10 | * software distributed under the License is distributed on an
11 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
12 | * KIND, either express or implied. See the License for the
13 | * specific language governing permissions and limitations
14 | * under the License.
15 | *
16 | */
17 |
18 | #include
19 | #include "accelerometer.h"
20 |
21 | DeviceMotion::DeviceMotion(Cordova *cordova): CPlugin(cordova), _scId(0), _ecId(0) {
22 | _accelerometerSource = QSharedPointer(new QAccelerometer());
23 | _sensorAvaliable = _accelerometerSource->start();
24 | connect(_accelerometerSource.data(), SIGNAL(readingChanged()), SLOT(updateSensor()));
25 | }
26 |
27 | void DeviceMotion::start(int scId, int ecId) {
28 | assert(_ecId == 0);
29 | assert(_scId == 0);
30 |
31 | _ecId = ecId;
32 | _scId = scId;
33 |
34 | if (!_sensorAvaliable) {
35 | this->cb(ecId);
36 | return;
37 | }
38 | }
39 |
40 | void DeviceMotion::stop(int, int) {
41 | _scId = 0;
42 | _ecId = 0;
43 | }
44 |
45 | void DeviceMotion::updateSensor() {
46 | QAccelerometerReading *accelerometer = _accelerometerSource->reading();
47 |
48 | QVariantMap obj;
49 | obj.insert("x", accelerometer->x());
50 | obj.insert("y", accelerometer->y());
51 | obj.insert("z", accelerometer->z());
52 | // accelerometer->timestamp() is not sutiable.
53 | // Timestamps values are microseconds since _a_ fixed point(depend on backend).
54 | obj.insert("timestamp", QDateTime::currentDateTime().toMSecsSinceEpoch());
55 |
56 | if (_scId)
57 | this->callbackWithoutRemove(_scId, CordovaInternal::format(obj));
58 | }
59 |
--------------------------------------------------------------------------------
/plugins/cordova-plugin-device-motion/src/tizen/AccelerometerProxy.js:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | *
20 | */
21 |
22 | (function(win) {
23 | var accelerometerCallback = null;
24 |
25 | module.exports = {
26 | start: function (successCallback, errorCallback) {
27 | if (accelerometerCallback) {
28 | win.removeEventListener("devicemotion", accelerometerCallback, true);
29 | }
30 |
31 | accelerometerCallback = function (motion) {
32 | successCallback({
33 | x: motion.accelerationIncludingGravity.x,
34 | y: motion.accelerationIncludingGravity.y,
35 | z: motion.accelerationIncludingGravity.z,
36 | timestamp: new Date().getTime()
37 | });
38 | };
39 | win.addEventListener("devicemotion", accelerometerCallback, true);
40 | },
41 |
42 | stop: function (successCallback, errorCallback) {
43 | win.removeEventListener("devicemotion", accelerometerCallback, true);
44 | accelerometerCallback = null;
45 | }
46 | };
47 |
48 | require("cordova/tizen/commandProxy").add("Accelerometer", module.exports);
49 | }(window));
50 |
--------------------------------------------------------------------------------
/plugins/cordova-plugin-device-motion/src/windows/AccelerometerProxy.js:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | *
20 | */
21 |
22 | /*global Windows:true */
23 |
24 | var Acceleration = require('cordova-plugin-device-motion.Acceleration');
25 |
26 | /* This is the actual implementation part that returns the result on Windows 8
27 | */
28 | var gConstant = -9.81;
29 |
30 | module.exports = {
31 | onDataChanged:null,
32 | start:function(win,lose){
33 |
34 | var accel = Windows.Devices.Sensors.Accelerometer.getDefault();
35 | if(!accel) {
36 | if (lose) {
37 | lose("No accelerometer found");
38 | }
39 | }
40 | else {
41 | accel.reportInterval = Math.max(16,accel.minimumReportInterval);
42 |
43 | // store our bound function
44 | this.onDataChanged = function(e) {
45 | var a = e.reading;
46 | win(new Acceleration(a.accelerationX * gConstant, a.accelerationY * gConstant, a.accelerationZ * gConstant), {keepCallback: true});
47 | };
48 | accel.addEventListener("readingchanged",this.onDataChanged);
49 |
50 | setTimeout(function(){
51 | var a = accel.getCurrentReading();
52 | win(new Acceleration(a.accelerationX * gConstant, a.accelerationY * gConstant, a.accelerationZ * gConstant), {keepCallback: true});
53 | },0); // async do later
54 | }
55 | },
56 | stop:function(win,lose){
57 | win = win || function(){};
58 | var accel = Windows.Devices.Sensors.Accelerometer.getDefault();
59 | if(!accel) {
60 | if (lose) {
61 | lose("No accelerometer found");
62 | }
63 | }
64 | else {
65 | accel.removeEventListener("readingchanged",this.onDataChanged);
66 | this.onDataChanged = null;
67 | accel.reportInterval = 0; // back to the default
68 | win();
69 | }
70 | }
71 | };
72 |
73 | require("cordova/exec/proxy").add("Accelerometer",module.exports);
74 |
--------------------------------------------------------------------------------
/www/js/juego.js:
--------------------------------------------------------------------------------
1 | var app={
2 | inicio: function(){
3 | DIAMETRO_BOLA = 50;
4 | dificultad = 0;
5 | velocidadX = 0;
6 | velocidadY = 0;
7 | puntuacion = 0;
8 |
9 | alto = document.documentElement.clientHeight;
10 | ancho = document.documentElement.clientWidth;
11 |
12 | app.vigilaSensores();
13 | app.iniciaJuego();
14 | },
15 |
16 | iniciaJuego: function(){
17 |
18 | function preload() {
19 | game.physics.startSystem(Phaser.Physics.ARCADE);
20 |
21 | game.stage.backgroundColor = '#f27d0c';
22 | game.load.image('bola', 'assets/bola.png');
23 | game.load.image('objetivo', 'assets/objetivo.png');
24 | }
25 |
26 | function create() {
27 | scoreText = game.add.text(16, 16, puntuacion, { fontSize: '100px', fill: '#757676' });
28 |
29 | objetivo = game.add.sprite(app.inicioX(), app.inicioY(), 'objetivo');
30 | bola = game.add.sprite(app.inicioX(), app.inicioY(), 'bola');
31 |
32 | game.physics.arcade.enable(bola);
33 | game.physics.arcade.enable(objetivo);
34 |
35 | bola.body.collideWorldBounds = true;
36 | bola.body.onWorldBounds = new Phaser.Signal();
37 | bola.body.onWorldBounds.add(app.decrementaPuntuacion, this);
38 | }
39 |
40 | function update(){
41 | var factorDificultad = (300 + (dificultad * 100));
42 | bola.body.velocity.y = (velocidadY * factorDificultad);
43 | bola.body.velocity.x = (velocidadX * (-1 * factorDificultad));
44 |
45 | game.physics.arcade.overlap(bola, objetivo, app.incrementaPuntuacion, null, this);
46 | }
47 |
48 | var estados = { preload: preload, create: create, update: update };
49 | var game = new Phaser.Game(ancho, alto, Phaser.CANVAS, 'phaser',estados);
50 | },
51 |
52 | decrementaPuntuacion: function(){
53 | puntuacion = puntuacion-1;
54 | scoreText.text = puntuacion;
55 | },
56 |
57 | incrementaPuntuacion: function(){
58 | puntuacion = puntuacion+1;
59 | scoreText.text = puntuacion;
60 |
61 | objetivo.body.x = app.inicioX();
62 | objetivo.body.y = app.inicioY();
63 |
64 | if (puntuacion > 0){
65 | dificultad = dificultad + 1;
66 | }
67 | },
68 |
69 | inicioX: function(){
70 | return app.numeroAleatorioHasta(ancho - DIAMETRO_BOLA );
71 | },
72 |
73 | inicioY: function(){
74 | return app.numeroAleatorioHasta(alto - DIAMETRO_BOLA );
75 | },
76 |
77 | numeroAleatorioHasta: function(limite){
78 | return Math.floor(Math.random() * limite);
79 | },
80 |
81 | vigilaSensores: function(){
82 |
83 | function onError() {
84 | console.log('onError!');
85 | }
86 |
87 | function onSuccess(datosAceleracion){
88 | app.detectaAgitacion(datosAceleracion);
89 | app.registraDireccion(datosAceleracion);
90 | }
91 |
92 | navigator.accelerometer.watchAcceleration(onSuccess, onError,{ frequency: 10 });
93 | },
94 |
95 | detectaAgitacion: function(datosAceleracion){
96 | var agitacionX = datosAceleracion.x > 10;
97 | var agitacionY = datosAceleracion.y > 10;
98 |
99 | if (agitacionX || agitacionY){
100 | setTimeout(app.recomienza, 1000);
101 | }
102 | },
103 |
104 | recomienza: function(){
105 | document.location.reload(true);
106 | },
107 |
108 | registraDireccion: function(datosAceleracion){
109 | velocidadX = datosAceleracion.x ;
110 | velocidadY = datosAceleracion.y ;
111 | }
112 |
113 | };
114 |
115 | if ('addEventListener' in document) {
116 | document.addEventListener('deviceready', function() {
117 | app.inicio();
118 | }, false);
119 | }
--------------------------------------------------------------------------------
/plugins/cordova-plugin-device-motion/doc/zh/index.md:
--------------------------------------------------------------------------------
1 |
19 |
20 | # cordova-plugin-device-motion
21 |
22 | 這個外掛程式提供了對設備的加速度計的訪問。 加速度計是動作感應器檢測到的更改 (*三角洲*) 在相對於當前的設備方向,在三個維度沿*x*、 *y*和*z*軸運動。
23 |
24 | 訪問是通過一個全球 `navigator.accelerometer` 物件。
25 |
26 | 雖然該物件附加到全球範圍內 `導航器`,它不可用直到 `deviceready` 事件之後。
27 |
28 | document.addEventListener("deviceready", onDeviceReady, false);
29 | function onDeviceReady() {
30 | console.log(navigator.accelerometer);
31 | }
32 |
33 |
34 | ## 安裝
35 |
36 | cordova plugin add cordova-plugin-device-motion
37 |
38 |
39 | ## 支援的平臺
40 |
41 | * 亞馬遜火 OS
42 | * Android 系統
43 | * 黑莓 10
44 | * 瀏覽器
45 | * 火狐瀏覽器的作業系統
46 | * iOS
47 | * 泰
48 | * Windows Phone 8
49 | * Windows
50 |
51 | ## 方法
52 |
53 | * navigator.accelerometer.getCurrentAcceleration
54 | * navigator.accelerometer.watchAcceleration
55 | * navigator.accelerometer.clearWatch
56 |
57 | ## 物件
58 |
59 | * 加速度
60 |
61 | ## navigator.accelerometer.getCurrentAcceleration
62 |
63 | 得到當前加速度沿 *x*、 *y* 和 *z* 軸。
64 |
65 | 這些加速度值將返回到 `accelerometerSuccess` 回呼函數。
66 |
67 | navigator.accelerometer.getCurrentAcceleration(accelerometerSuccess, accelerometerError);
68 |
69 |
70 | ### 示例
71 |
72 | function onSuccess(acceleration) {
73 | alert('Acceleration X: ' + acceleration.x + '\n' +
74 | 'Acceleration Y: ' + acceleration.y + '\n' +
75 | 'Acceleration Z: ' + acceleration.z + '\n' +
76 | 'Timestamp: ' + acceleration.timestamp + '\n');
77 | };
78 |
79 | function onError() {
80 | alert('onError!');
81 | };
82 |
83 | navigator.accelerometer.getCurrentAcceleration(onSuccess, onError);
84 |
85 |
86 | ### 瀏覽器的怪癖
87 |
88 | 值 X、 Y、 Z 議案是所有中隨機生成的訂單來類比加速度感應器。
89 |
90 | ### iOS 的怪癖
91 |
92 | * iOS 不會認識到在任何給定的點獲取當前加速度的概念。
93 |
94 | * 你必須看加速和捕獲的資料在特定的時間間隔。
95 |
96 | * 因此, `getCurrentAcceleration` 收益率從報告的最後一個值的函數 `watchAccelerometer` 調用。
97 |
98 | ## navigator.accelerometer.watchAcceleration
99 |
100 | 在週期性時間間隔,執行 `accelerometerSuccess` 回呼函數每次檢索設備的當前 `Accelerometer`。 指定的間隔,以毫秒為單位通過 `acceleratorOptions` 物件的 `frequency` 參數。
101 |
102 | 返回的表 ID 引用加速度計的手錶時間間隔,並且可以與 `navigator.accelerometer.clearWatch` 用來停止觀看了加速度計。
103 |
104 | var watchID = navigator.accelerometer.watchAcceleration(accelerometerSuccess,
105 | accelerometerError,
106 | accelerometerOptions);
107 |
108 |
109 | * **accelerometerOptions**: 具有以下可選的鍵的物件:
110 | * **期間**: 請求的期間的調用的 accelerometerSuccess 與加速度資料以毫秒為單位。*(人數)*(預設值: 10000)
111 |
112 | ### 示例
113 |
114 | function onSuccess(acceleration) {
115 | alert('Acceleration X: ' + acceleration.x + '\n' +
116 | 'Acceleration Y: ' + acceleration.y + '\n' +
117 | 'Acceleration Z: ' + acceleration.z + '\n' +
118 | 'Timestamp: ' + acceleration.timestamp + '\n');
119 | };
120 |
121 | function onError() {
122 | alert('onError!');
123 | };
124 |
125 | var options = { frequency: 3000 }; // Update every 3 seconds
126 |
127 | var watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);
128 |
129 |
130 | ### iOS 的怪癖
131 |
132 | API 呼叫成功的回呼函數在時間間隔的要求,但將請求的範圍限制為 40ms年之間裝置和 1000ms。 例如,如果您請求的時間間隔為 3 秒,(3000ms),API 請求資料從設備每隔 1 秒,但只是執行成功回檔每 3 秒。
133 |
134 | ## navigator.accelerometer.clearWatch
135 |
136 | 別看 `watchID` 參數所引用的 `Accelerometer`。
137 |
138 | navigator.accelerometer.clearWatch(watchID);
139 |
140 |
141 | * **watchID**: 由返回的 ID`navigator.accelerometer.watchAcceleration`.
142 |
143 | ### 示例
144 |
145 | var watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);
146 |
147 | // ... later on ...
148 |
149 | navigator.accelerometer.clearWatch(watchID);
150 |
151 |
152 | ## 加速度
153 |
154 | 包含在時間中捕獲的特定點的 `Accekerometer` 資料。 加速度值包括重力的作用 (9.81 m/s ^2),這樣當設備在於扁和朝上,*x*,*y*,*z* 返回的值應該是 ``、 `` 度和 `9.81`.
155 |
156 | ### 屬性
157 |
158 | * **x**: 在 X 軸上的加速度量。(在 m/s ^2)*(人數)*
159 | * **y**: 在 y 軸上的加速度量。(在 m/s ^2)*(人數)*
160 | * **z**: 在 Z 軸上的加速度量。(在 m/s ^2)*(人數)*
161 | * **timestamp**: 創建時間戳記以毫秒為單位。*() DOMTimeStamp*
162 |
--------------------------------------------------------------------------------
/plugins/cordova-plugin-device-motion/doc/ko/index.md:
--------------------------------------------------------------------------------
1 |
19 |
20 | # cordova-plugin-device-motion
21 |
22 | 이 플러그인 장치의 속도계에 대 한 액세스를 제공합니다. 가 속도계 3 차원 *x*, *y*및 *z* 축 따라 현재 장치 방향 기준으로 이동 (*델타*) 변경 내용을 감지 하는 모션 센서입니다.
23 |
24 | 글로벌 `navigator.accelerometer` 개체를 통해 액세스가입니다.
25 |
26 | 개체 `navigator` 글로벌 범위 첨부 아니에요 때까지 사용할 수 있는 `deviceready` 이벤트 후.
27 |
28 | document.addEventListener("deviceready", onDeviceReady, false);
29 | function onDeviceReady() {
30 | console.log(navigator.accelerometer);
31 | }
32 |
33 |
34 | ## 설치
35 |
36 | cordova plugin add cordova-plugin-device-motion
37 |
38 |
39 | ## 지원 되는 플랫폼
40 |
41 | * 아마존 화재 운영 체제
42 | * 안 드 로이드
43 | * 블랙베리 10
44 | * 브라우저
45 | * Firefox 운영 체제
46 | * iOS
47 | * Tizen
48 | * Windows Phone 8
49 | * 윈도우
50 |
51 | ## 메서드
52 |
53 | * navigator.accelerometer.getCurrentAcceleration
54 | * navigator.accelerometer.watchAcceleration
55 | * navigator.accelerometer.clearWatch
56 |
57 | ## 개체
58 |
59 | * 가속
60 |
61 | ## navigator.accelerometer.getCurrentAcceleration
62 |
63 | *X*, *y* 및 *z* 축 따라 현재 가속도 얻을.
64 |
65 | 이 가속도 값이 `accelerometerSuccess` 콜백 함수에 반환 됩니다.
66 |
67 | navigator.accelerometer.getCurrentAcceleration(accelerometerSuccess, accelerometerError);
68 |
69 |
70 | ### 예를 들어
71 |
72 | function onSuccess(acceleration) {
73 | alert('Acceleration X: ' + acceleration.x + '\n' +
74 | 'Acceleration Y: ' + acceleration.y + '\n' +
75 | 'Acceleration Z: ' + acceleration.z + '\n' +
76 | 'Timestamp: ' + acceleration.timestamp + '\n');
77 | };
78 |
79 | function onError() {
80 | alert('onError!');
81 | };
82 |
83 | navigator.accelerometer.getCurrentAcceleration(onSuccess, onError);
84 |
85 |
86 | ### 브라우저 만지면
87 |
88 | X, Y 값 Z 모션은가 속도계 시뮬레이션 모든에 임의로 생성 된 순서입니다.
89 |
90 | ### iOS 단점
91 |
92 | * iOS는 어떤 주어진된 시점에서 현재 가속도의 개념을 인식 하지 못합니다.
93 |
94 | * 가속을 감시 하며 데이터 캡처에 주어진 시간 간격.
95 |
96 | * 따라서,는 `getCurrentAcceleration` 에서 보고 된 마지막 값을 생성 하는 함수는 `watchAccelerometer` 전화.
97 |
98 | ## navigator.accelerometer.watchAcceleration
99 |
100 | 때마다 `accelerometerSuccess` 콜백 함수를 실행 정기적 소자의 현재 `Acceleration`을 검색 합니다. `acceleratorOptions` 개체의 `frequency` 매개 변수를 통해 밀리초 단위로 간격을 지정 합니다.
101 |
102 | 반환 된 시계 ID가 속도계의 시계 간격을 참조 하 고가 속도계를 보는 중지 하 `navigator.accelerometer.clearWatch`와 함께 사용할 수 있습니다.
103 |
104 | var watchID = navigator.accelerometer.watchAcceleration(accelerometerSuccess,
105 | accelerometerError,
106 | accelerometerOptions);
107 |
108 |
109 | * **accelerometerOptions**: 다음 선택적 키 개체:
110 | * **기간**: 밀리초에서 가속 데이터와 accelerometerSuccess에 대 한 호출의 요청된 기간. *(수)* (기본: 10000)
111 |
112 | ### 예를 들어
113 |
114 | function onSuccess(acceleration) {
115 | alert('Acceleration X: ' + acceleration.x + '\n' +
116 | 'Acceleration Y: ' + acceleration.y + '\n' +
117 | 'Acceleration Z: ' + acceleration.z + '\n' +
118 | 'Timestamp: ' + acceleration.timestamp + '\n');
119 | };
120 |
121 | function onError() {
122 | alert('onError!');
123 | };
124 |
125 | var options = { frequency: 3000 }; // Update every 3 seconds
126 |
127 | var watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);
128 |
129 |
130 | ### iOS 단점
131 |
132 | API 요청 간격 성공 콜백 함수를 호출 하지만 40ms 사이 장치에 요청의 범위를 제한 하 고 1000ms. 예를 들어 (3000ms) 3 초의 간격을 요청 하는 경우 API 마다 1 초 장치에서 데이터를 요청 하지만 성공 콜백을 3 초 마다 실행 됩니다.
133 |
134 | ## navigator.accelerometer.clearWatch
135 |
136 | `watchID` 매개 변수에서 참조 `가속도` 보고 중지 합니다.
137 |
138 | navigator.accelerometer.clearWatch(watchID);
139 |
140 |
141 | * **watchID**: ID 반환`navigator.accelerometer.watchAcceleration`.
142 |
143 | ### 예를 들어
144 |
145 | var watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);
146 |
147 | // ... later on ...
148 |
149 | navigator.accelerometer.clearWatch(watchID);
150 |
151 |
152 | ## 가속
153 |
154 | 특정 시점에 캡처된 `Accelerometer` 데이터를 포함 합니다. 가속도 값 포함 중력의 효과 (9.81 m/s ^2) 때 장치 거짓말 평평 하 고 *x*, *y*, 최대 직면 하 고 반환 하는 *z* 값 ``, `` 및 `9.81` 이어야 한다,.
155 |
156 | ### 속성
157 |
158 | * **x**: x 축에 가속의 금액. (m/s에서 ^2) *(수)*
159 | * **y**: y 축에 가속의 금액. (m/s에서 ^2) *(수)*
160 | * **z**: z 축의 가속도의 금액. (m/s에서 ^2) *(수)*
161 | * **타임 스탬프**: 생성 타임 스탬프 (밀리초)입니다. *(DOMTimeStamp)*
162 |
--------------------------------------------------------------------------------
/plugins/cordova-plugin-device-motion/doc/zh/README.md:
--------------------------------------------------------------------------------
1 |
19 |
20 | # cordova-plugin-device-motion
21 |
22 | [](https://travis-ci.org/apache/cordova-plugin-device-motion)
23 |
24 | 這個外掛程式提供了對設備的加速度計的訪問。 加速度計是動作感應器檢測到的更改 (*三角洲*) 在相對於當前的設備方向,在三個維度沿*x*、 *y*和*z*軸運動。
25 |
26 | 訪問是通過一個全球 `navigator.accelerometer` 物件。
27 |
28 | 雖然該物件附加到全球範圍內 `導航器`,它不可用直到 `deviceready` 事件之後。
29 |
30 | document.addEventListener("deviceready", onDeviceReady, false);
31 | function onDeviceReady() {
32 | console.log(navigator.accelerometer);
33 | }
34 |
35 |
36 | ## 安裝
37 |
38 | cordova plugin add cordova-plugin-device-motion
39 |
40 |
41 | ## 支援的平臺
42 |
43 | * 亞馬遜火 OS
44 | * Android 系統
45 | * 黑莓 10
46 | * 瀏覽器
47 | * 火狐瀏覽器作業系統
48 | * iOS
49 | * Tizen
50 | * Windows Phone 8
51 | * Windows
52 |
53 | ## 方法
54 |
55 | * navigator.accelerometer.getCurrentAcceleration
56 | * navigator.accelerometer.watchAcceleration
57 | * navigator.accelerometer.clearWatch
58 |
59 | ## 物件
60 |
61 | * 加速度
62 |
63 | ## navigator.accelerometer.getCurrentAcceleration
64 |
65 | 得到當前加速度沿 *x*、 *y* 和 *z* 軸。
66 |
67 | 這些加速度值將返回到 `accelerometerSuccess` 回呼函數。
68 |
69 | navigator.accelerometer.getCurrentAcceleration(accelerometerSuccess, accelerometerError);
70 |
71 |
72 | ### 示例
73 |
74 | function onSuccess(acceleration) {
75 | alert('Acceleration X: ' + acceleration.x + '\n' +
76 | 'Acceleration Y: ' + acceleration.y + '\n' +
77 | 'Acceleration Z: ' + acceleration.z + '\n' +
78 | 'Timestamp: ' + acceleration.timestamp + '\n');
79 | };
80 |
81 | function onError() {
82 | alert('onError!');
83 | };
84 |
85 | navigator.accelerometer.getCurrentAcceleration(onSuccess, onError);
86 |
87 |
88 | ### 瀏覽器的怪癖
89 |
90 | 值 X、 Y、 Z 議案是所有中隨機生成的訂單來類比加速度感應器。
91 |
92 | ### iOS 的怪癖
93 |
94 | * iOS 不會認識到在任何給定的點獲取當前加速度的概念。
95 |
96 | * 你必須看加速和捕獲的資料在特定的時間間隔。
97 |
98 | * 因此, `getCurrentAcceleration` 收益率從報告的最後一個值的函數 `watchAccelerometer` 調用。
99 |
100 | ## navigator.accelerometer.watchAcceleration
101 |
102 | 在週期性時間間隔,執行 `accelerometerSuccess` 回呼函數每次檢索設備的當前 `Accelerometer`。 指定的間隔,以毫秒為單位通過 `acceleratorOptions` 物件的 `frequency` 參數。
103 |
104 | 返回的表 ID 引用加速度計的手錶時間間隔,並且可以與 `navigator.accelerometer.clearWatch` 用來停止觀看了加速度計。
105 |
106 | var watchID = navigator.accelerometer.watchAcceleration(accelerometerSuccess,
107 | accelerometerError,
108 | accelerometerOptions);
109 |
110 |
111 | * **accelerometerOptions**: 具有以下可選的鍵的物件:
112 | * **期間**: 請求的期間的調用的 accelerometerSuccess 與加速度資料以毫秒為單位。*(人數)*(預設值: 10000)
113 |
114 | ### 示例
115 |
116 | function onSuccess(acceleration) {
117 | alert('Acceleration X: ' + acceleration.x + '\n' +
118 | 'Acceleration Y: ' + acceleration.y + '\n' +
119 | 'Acceleration Z: ' + acceleration.z + '\n' +
120 | 'Timestamp: ' + acceleration.timestamp + '\n');
121 | };
122 |
123 | function onError() {
124 | alert('onError!');
125 | };
126 |
127 | var options = { frequency: 3000 }; // Update every 3 seconds
128 |
129 | var watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);
130 |
131 |
132 | ### iOS 的怪癖
133 |
134 | API 呼叫成功的回呼函數在時間間隔的要求,但將請求的範圍限制為 40ms年之間裝置和 1000ms。 例如,如果您請求的時間間隔為 3 秒,(3000ms),API 請求資料從設備每隔 1 秒,但只是執行成功回檔每 3 秒。
135 |
136 | ## navigator.accelerometer.clearWatch
137 |
138 | 別看 `watchID` 參數所引用的 `Accelerometer`。
139 |
140 | navigator.accelerometer.clearWatch(watchID);
141 |
142 |
143 | * **watchID**: 由返回的 ID`navigator.accelerometer.watchAcceleration`.
144 |
145 | ### 示例
146 |
147 | var watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);
148 |
149 | // ... later on ...
150 |
151 | navigator.accelerometer.clearWatch(watchID);
152 |
153 |
154 | ## 加速度
155 |
156 | 包含在時間中捕獲的特定點的 `Accekerometer` 資料。 加速度值包括重力的作用 (9.81 m/s ^2),這樣當設備在於扁和朝上,*x*,*y*,*z* 返回的值應該是 ``、 `` 度和 `9.81`.
157 |
158 | ### 屬性
159 |
160 | * **x**: 在 X 軸上的加速度量。(在 m/s ^2)*(人數)*
161 | * **y**: 在 y 軸上的加速度量。(在 m/s ^2)*(人數)*
162 | * **z**: 在 Z 軸上的加速度量。(在 m/s ^2)*(人數)*
163 | * **timestamp**: 創建時間戳記以毫秒為單位。*() DOMTimeStamp*
--------------------------------------------------------------------------------
/plugins/cordova-plugin-device-motion/doc/ja/index.md:
--------------------------------------------------------------------------------
1 |
19 |
20 | # cordova-plugin-device-motion
21 |
22 | このプラグインは、デバイスの加速度計へのアクセスを提供します。 加速度計の現在のデバイスの向き、 *x* *y*、および*z*軸に沿って 3 つの次元の相対運動の変更 (*デルタ*) を検出するモーション センサーです。
23 |
24 | アクセスは、グローバル `navigator.accelerometer` オブジェクトを介して。
25 |
26 | オブジェクトは、グローバル スコープの `ナビゲーター` に添付、それがないまで `deviceready` イベントの後。
27 |
28 | document.addEventListener("deviceready", onDeviceReady, false);
29 | function onDeviceReady() {
30 | console.log(navigator.accelerometer);
31 | }
32 |
33 |
34 | ## インストール
35 |
36 | cordova plugin add cordova-plugin-device-motion
37 |
38 |
39 | ## サポートされているプラットフォーム
40 |
41 | * アマゾン火 OS
42 | * アンドロイド
43 | * ブラックベリー 10
44 | * ブラウザー
45 | * Firefox の OS
46 | * iOS
47 | * Tizen
48 | * Windows Phone 8
49 | * Windows
50 |
51 | ## メソッド
52 |
53 | * navigator.accelerometer.getCurrentAcceleration
54 | * navigator.accelerometer.watchAcceleration
55 | * navigator.accelerometer.clearWatch
56 |
57 | ## オブジェクト
58 |
59 | * 加速
60 |
61 | ## navigator.accelerometer.getCurrentAcceleration
62 |
63 | *X* *y*、および *z* 軸に沿って現在の加速を取得します。
64 |
65 | これらの加速度値が `accelerometerSuccess` コールバック関数に返されます。
66 |
67 | navigator.accelerometer.getCurrentAcceleration(accelerometerSuccess, accelerometerError);
68 |
69 |
70 | ### 例
71 |
72 | function onSuccess(acceleration) {
73 | alert('Acceleration X: ' + acceleration.x + '\n' +
74 | 'Acceleration Y: ' + acceleration.y + '\n' +
75 | 'Acceleration Z: ' + acceleration.z + '\n' +
76 | 'Timestamp: ' + acceleration.timestamp + '\n');
77 | };
78 |
79 | function onError() {
80 | alert('onError!');
81 | };
82 |
83 | navigator.accelerometer.getCurrentAcceleration(onSuccess, onError);
84 |
85 |
86 | ### ブラウザーの癖
87 |
88 | 値 X、Y、Z モーションは、加速度計をシミュレートするためにすべてのランダムに生成される順序です。
89 |
90 | ### iOS の癖
91 |
92 | * iOS は、任意の時点で現在の加速度を得ることの概念を認識しません。
93 |
94 | * 加速度を見るし、データをキャプチャする必要があります指定した時間間隔で。
95 |
96 | * したがって、 `getCurrentAcceleration` 関数から報告された最後の値が生成されます、 `watchAccelerometer` を呼び出します。
97 |
98 | ## navigator.accelerometer.watchAcceleration
99 |
100 | たびに `accelerometerSuccess` コールバック関数を実行する定期的な間隔で、デバイスの現在の `Acceleration` を取得します。 `acceleratorOptions` オブジェクトの `frquency` パラメーターを介してミリ秒単位で間隔を指定します。
101 |
102 | 返される時計 ID、加速度計腕時計間隔を参照し、加速度計を見て停止する `navigator.accelerometer.clearWatch` を使用することができます。
103 |
104 | var watchID = navigator.accelerometer.watchAcceleration(accelerometerSuccess,
105 | accelerometerError,
106 | accelerometerOptions);
107 |
108 |
109 | * **accelerometerOptions**: 次のオプションのキーを持つオブジェクト:
110 | * **期間**: ミリ秒単位での加速度データと accelerometerSuccess への呼び出しの要求された期間。*(数)*(デフォルト: 10000)
111 |
112 | ### 例
113 |
114 | function onSuccess(acceleration) {
115 | alert('Acceleration X: ' + acceleration.x + '\n' +
116 | 'Acceleration Y: ' + acceleration.y + '\n' +
117 | 'Acceleration Z: ' + acceleration.z + '\n' +
118 | 'Timestamp: ' + acceleration.timestamp + '\n');
119 | };
120 |
121 | function onError() {
122 | alert('onError!');
123 | };
124 |
125 | var options = { frequency: 3000 }; // Update every 3 seconds
126 |
127 | var watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);
128 |
129 |
130 | ### iOS の癖
131 |
132 | API は、要求された間隔で、成功コールバック関数を呼び出しますが 40 ms の間デバイスへの要求の範囲を制限し、1000 ミリ秒になります。 たとえば、(ms) 3 秒の間隔を要求した場合、API 1 秒ごとに、デバイスからデータを要求がのみ成功コールバック 3 秒ごとを実行します。
133 |
134 | ## navigator.accelerometer.clearWatch
135 |
136 | `watchID` パラメーターによって参照される `加速` を見て停止します。
137 |
138 | navigator.accelerometer.clearWatch(watchID);
139 |
140 |
141 | * **watchID**: によって返される ID`navigator.accelerometer.watchAcceleration`.
142 |
143 | ### 例
144 |
145 | var watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);
146 |
147 | // ... later on ...
148 |
149 | navigator.accelerometer.clearWatch(watchID);
150 |
151 |
152 | ## 加速
153 |
154 | 特定の時点でキャプチャした `Accelerometer` データが含まれています。 加速度値のとおり重力の効果 (9.81 m/s ^2) デバイスにあるフラットと *x* *y*、直面していると返された *z* 値は `` ``、および `9.81` をする必要がありますように、.
155 |
156 | ### プロパティ
157 |
158 | * **x**: x 軸の加速度の量です。(m/s ^2)*(数)*
159 | * **y**: y 軸の加速度の量です。(m/s ^2)*(数)*
160 | * **z**: z 軸の加速度の量です。(m/s ^2)*(数)*
161 | * **タイムスタンプ**: 作成時のタイムスタンプ (ミリ秒単位)。*(,)*
162 |
--------------------------------------------------------------------------------
/plugins/cordova-plugin-device-motion/doc/ko/README.md:
--------------------------------------------------------------------------------
1 |
19 |
20 | # cordova-plugin-device-motion
21 |
22 | [](https://travis-ci.org/apache/cordova-plugin-device-motion)
23 |
24 | 이 플러그인 장치의 속도계에 대 한 액세스를 제공합니다. 가 속도계 3 차원 *x*, *y*및 *z* 축 따라 현재 장치 방향 기준으로 이동 (*델타*) 변경 내용을 감지 하는 모션 센서입니다.
25 |
26 | 글로벌 `navigator.accelerometer` 개체를 통해 액세스가입니다.
27 |
28 | 개체 `navigator` 글로벌 범위 첨부 아니에요 때까지 사용할 수 있는 `deviceready` 이벤트 후.
29 |
30 | document.addEventListener("deviceready", onDeviceReady, false);
31 | function onDeviceReady() {
32 | console.log(navigator.accelerometer);
33 | }
34 |
35 |
36 | ## 설치
37 |
38 | cordova plugin add cordova-plugin-device-motion
39 |
40 |
41 | ## 지원 되는 플랫폼
42 |
43 | * 아마존 화재 운영 체제
44 | * 안 드 로이드
45 | * 블랙베리 10
46 | * 브라우저
47 | * Firefox 운영 체제
48 | * iOS
49 | * Tizen
50 | * Windows Phone 8
51 | * 윈도우
52 |
53 | ## 메서드
54 |
55 | * navigator.accelerometer.getCurrentAcceleration
56 | * navigator.accelerometer.watchAcceleration
57 | * navigator.accelerometer.clearWatch
58 |
59 | ## 개체
60 |
61 | * 가속
62 |
63 | ## navigator.accelerometer.getCurrentAcceleration
64 |
65 | *X*, *y* 및 *z* 축 따라 현재 가속도 얻을.
66 |
67 | 이 가속도 값이 `accelerometerSuccess` 콜백 함수에 반환 됩니다.
68 |
69 | navigator.accelerometer.getCurrentAcceleration(accelerometerSuccess, accelerometerError);
70 |
71 |
72 | ### 예를 들어
73 |
74 | function onSuccess(acceleration) {
75 | alert('Acceleration X: ' + acceleration.x + '\n' +
76 | 'Acceleration Y: ' + acceleration.y + '\n' +
77 | 'Acceleration Z: ' + acceleration.z + '\n' +
78 | 'Timestamp: ' + acceleration.timestamp + '\n');
79 | };
80 |
81 | function onError() {
82 | alert('onError!');
83 | };
84 |
85 | navigator.accelerometer.getCurrentAcceleration(onSuccess, onError);
86 |
87 |
88 | ### 브라우저 만지면
89 |
90 | X, Y 값 Z 모션은가 속도계 시뮬레이션 모든에 임의로 생성 된 순서입니다.
91 |
92 | ### iOS 단점
93 |
94 | * iOS는 어떤 주어진된 시점에서 현재 가속도의 개념을 인식 하지 못합니다.
95 |
96 | * 가속을 감시 하며 데이터 캡처에 주어진 시간 간격.
97 |
98 | * 따라서,는 `getCurrentAcceleration` 에서 보고 된 마지막 값을 생성 하는 함수는 `watchAccelerometer` 전화.
99 |
100 | ## navigator.accelerometer.watchAcceleration
101 |
102 | 때마다 `accelerometerSuccess` 콜백 함수를 실행 정기적 소자의 현재 `Acceleration`을 검색 합니다. `acceleratorOptions` 개체의 `frequency` 매개 변수를 통해 밀리초 단위로 간격을 지정 합니다.
103 |
104 | 반환 된 시계 ID가 속도계의 시계 간격을 참조 하 고가 속도계를 보는 중지 하 `navigator.accelerometer.clearWatch`와 함께 사용할 수 있습니다.
105 |
106 | var watchID = navigator.accelerometer.watchAcceleration(accelerometerSuccess,
107 | accelerometerError,
108 | accelerometerOptions);
109 |
110 |
111 | * **accelerometerOptions**: 다음 선택적 키 개체:
112 | * **기간**: 밀리초에서 가속 데이터와 accelerometerSuccess에 대 한 호출의 요청된 기간. *(수)* (기본: 10000)
113 |
114 | ### 예를 들어
115 |
116 | function onSuccess(acceleration) {
117 | alert('Acceleration X: ' + acceleration.x + '\n' +
118 | 'Acceleration Y: ' + acceleration.y + '\n' +
119 | 'Acceleration Z: ' + acceleration.z + '\n' +
120 | 'Timestamp: ' + acceleration.timestamp + '\n');
121 | };
122 |
123 | function onError() {
124 | alert('onError!');
125 | };
126 |
127 | var options = { frequency: 3000 }; // Update every 3 seconds
128 |
129 | var watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);
130 |
131 |
132 | ### iOS 단점
133 |
134 | API 요청 간격 성공 콜백 함수를 호출 하지만 40ms 사이 장치에 요청의 범위를 제한 하 고 1000ms. 예를 들어 (3000ms) 3 초의 간격을 요청 하는 경우 API 마다 1 초 장치에서 데이터를 요청 하지만 성공 콜백을 3 초 마다 실행 됩니다.
135 |
136 | ## navigator.accelerometer.clearWatch
137 |
138 | `watchID` 매개 변수에서 참조 `가속도` 보고 중지 합니다.
139 |
140 | navigator.accelerometer.clearWatch(watchID);
141 |
142 |
143 | * **watchID**: ID 반환`navigator.accelerometer.watchAcceleration`.
144 |
145 | ### 예를 들어
146 |
147 | var watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);
148 |
149 | // ... later on ...
150 |
151 | navigator.accelerometer.clearWatch(watchID);
152 |
153 |
154 | ## 가속
155 |
156 | 특정 시점에 캡처된 `Accelerometer` 데이터를 포함 합니다. 가속도 값 포함 중력의 효과 (9.81 m/s ^2) 때 장치 거짓말 평평 하 고 *x*, *y*, 최대 직면 하 고 반환 하는 *z* 값 ``, `` 및 `9.81` 이어야 한다,.
157 |
158 | ### 속성
159 |
160 | * **x**: x 축에 가속의 금액. (m/s에서 ^2) *(수)*
161 | * **y**: y 축에 가속의 금액. (m/s에서 ^2) *(수)*
162 | * **z**: z 축의 가속도의 금액. (m/s에서 ^2) *(수)*
163 | * **타임 스탬프**: 생성 타임 스탬프 (밀리초)입니다. *(DOMTimeStamp)*
--------------------------------------------------------------------------------
/plugins/cordova-plugin-device-motion/doc/ja/README.md:
--------------------------------------------------------------------------------
1 |
19 |
20 | # cordova-plugin-device-motion
21 |
22 | [](https://travis-ci.org/apache/cordova-plugin-device-motion)
23 |
24 | このプラグインは、デバイスの加速度計へのアクセスを提供します。 加速度計の現在のデバイスの向き、 *x* *y*、および*z*軸に沿って 3 つの次元の相対運動の変更 (*デルタ*) を検出するモーション センサーです。
25 |
26 | アクセスは、グローバル `navigator.accelerometer` オブジェクトを介して。
27 |
28 | オブジェクトは、グローバル スコープの `ナビゲーター` に添付、それがないまで `deviceready` イベントの後。
29 |
30 | document.addEventListener("deviceready", onDeviceReady, false);
31 | function onDeviceReady() {
32 | console.log(navigator.accelerometer);
33 | }
34 |
35 |
36 | ## インストール
37 |
38 | cordova plugin add cordova-plugin-device-motion
39 |
40 |
41 | ## サポートされているプラットフォーム
42 |
43 | * アマゾン火 OS
44 | * アンドロイド
45 | * ブラックベリー 10
46 | * ブラウザー
47 | * Firefox の OS
48 | * iOS
49 | * Tizen
50 | * Windows Phone 8
51 | * Windows
52 |
53 | ## メソッド
54 |
55 | * navigator.accelerometer.getCurrentAcceleration
56 | * navigator.accelerometer.watchAcceleration
57 | * navigator.accelerometer.clearWatch
58 |
59 | ## オブジェクト
60 |
61 | * 加速
62 |
63 | ## navigator.accelerometer.getCurrentAcceleration
64 |
65 | *X* *y*、および *z* 軸に沿って現在の加速を取得します。
66 |
67 | これらの加速度値が `accelerometerSuccess` コールバック関数に返されます。
68 |
69 | navigator.accelerometer.getCurrentAcceleration(accelerometerSuccess, accelerometerError);
70 |
71 |
72 | ### 例
73 |
74 | function onSuccess(acceleration) {
75 | alert('Acceleration X: ' + acceleration.x + '\n' +
76 | 'Acceleration Y: ' + acceleration.y + '\n' +
77 | 'Acceleration Z: ' + acceleration.z + '\n' +
78 | 'Timestamp: ' + acceleration.timestamp + '\n');
79 | };
80 |
81 | function onError() {
82 | alert('onError!');
83 | };
84 |
85 | navigator.accelerometer.getCurrentAcceleration(onSuccess, onError);
86 |
87 |
88 | ### ブラウザーの癖
89 |
90 | 値 X、Y、Z モーションは、加速度計をシミュレートするためにすべてのランダムに生成される順序です。
91 |
92 | ### iOS の癖
93 |
94 | * iOS は、任意の時点で現在の加速度を得ることの概念を認識しません。
95 |
96 | * 加速度を見るし、データをキャプチャする必要があります指定した時間間隔で。
97 |
98 | * したがって、 `getCurrentAcceleration` 関数から報告された最後の値が生成されます、 `watchAccelerometer` を呼び出します。
99 |
100 | ## navigator.accelerometer.watchAcceleration
101 |
102 | たびに `accelerometerSuccess` コールバック関数を実行する定期的な間隔で、デバイスの現在の `Acceleration` を取得します。 `acceleratorOptions` オブジェクトの `frquency` パラメーターを介してミリ秒単位で間隔を指定します。
103 |
104 | 返される時計 ID、加速度計腕時計間隔を参照し、加速度計を見て停止する `navigator.accelerometer.clearWatch` を使用することができます。
105 |
106 | var watchID = navigator.accelerometer.watchAcceleration(accelerometerSuccess,
107 | accelerometerError,
108 | accelerometerOptions);
109 |
110 |
111 | * **accelerometerOptions**: 次のオプションのキーを持つオブジェクト:
112 | * **期間**: ミリ秒単位での加速度データと accelerometerSuccess への呼び出しの要求された期間。*(数)*(デフォルト: 10000)
113 |
114 | ### 例
115 |
116 | function onSuccess(acceleration) {
117 | alert('Acceleration X: ' + acceleration.x + '\n' +
118 | 'Acceleration Y: ' + acceleration.y + '\n' +
119 | 'Acceleration Z: ' + acceleration.z + '\n' +
120 | 'Timestamp: ' + acceleration.timestamp + '\n');
121 | };
122 |
123 | function onError() {
124 | alert('onError!');
125 | };
126 |
127 | var options = { frequency: 3000 }; // Update every 3 seconds
128 |
129 | var watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);
130 |
131 |
132 | ### iOS の癖
133 |
134 | API は、要求された間隔で、成功コールバック関数を呼び出しますが 40 ms の間デバイスへの要求の範囲を制限し、1000 ミリ秒になります。 たとえば、(ms) 3 秒の間隔を要求した場合、API 1 秒ごとに、デバイスからデータを要求がのみ成功コールバック 3 秒ごとを実行します。
135 |
136 | ## navigator.accelerometer.clearWatch
137 |
138 | `watchID` パラメーターによって参照される `加速` を見て停止します。
139 |
140 | navigator.accelerometer.clearWatch(watchID);
141 |
142 |
143 | * **watchID**: によって返される ID`navigator.accelerometer.watchAcceleration`.
144 |
145 | ### 例
146 |
147 | var watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);
148 |
149 | // ... later on ...
150 |
151 | navigator.accelerometer.clearWatch(watchID);
152 |
153 |
154 | ## 加速
155 |
156 | 特定の時点でキャプチャした `Accelerometer` データが含まれています。 加速度値のとおり重力の効果 (9.81 m/s ^2) デバイスにあるフラットと *x* *y*、直面していると返された *z* 値は `` ``、および `9.81` をする必要がありますように、.
157 |
158 | ### プロパティ
159 |
160 | * **x**: x 軸の加速度の量です。(m/s ^2)*(数)*
161 | * **y**: y 軸の加速度の量です。(m/s ^2)*(数)*
162 | * **z**: z 軸の加速度の量です。(m/s ^2)*(数)*
163 | * **タイムスタンプ**: 作成時のタイムスタンプ (ミリ秒単位)。*(,)*
--------------------------------------------------------------------------------
/plugins/cordova-plugin-device-motion/src/ios/CDVAccelerometer.m:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to the Apache Software Foundation (ASF) under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. The ASF licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 | */
19 |
20 | #import
21 | #import "CDVAccelerometer.h"
22 |
23 | @interface CDVAccelerometer () {}
24 | @property (readwrite, assign) BOOL isRunning;
25 | @property (readwrite, assign) BOOL haveReturnedResult;
26 | @property (readwrite, strong) CMMotionManager* motionManager;
27 | @property (readwrite, assign) double x;
28 | @property (readwrite, assign) double y;
29 | @property (readwrite, assign) double z;
30 | @property (readwrite, assign) NSTimeInterval timestamp;
31 | @end
32 |
33 | @implementation CDVAccelerometer
34 |
35 | @synthesize callbackId, isRunning,x,y,z,timestamp;
36 |
37 | // defaults to 10 msec
38 | #define kAccelerometerInterval 10
39 | // g constant: -9.81 m/s^2
40 | #define kGravitationalConstant -9.81
41 |
42 | - (CDVAccelerometer*)init
43 | {
44 | self = [super init];
45 | if (self) {
46 | self.x = 0;
47 | self.y = 0;
48 | self.z = 0;
49 | self.timestamp = 0;
50 | self.callbackId = nil;
51 | self.isRunning = NO;
52 | self.haveReturnedResult = YES;
53 | self.motionManager = nil;
54 | }
55 | return self;
56 | }
57 |
58 | - (void)dealloc
59 | {
60 | [self stop:nil];
61 | }
62 |
63 | - (void)start:(CDVInvokedUrlCommand*)command
64 | {
65 | self.haveReturnedResult = NO;
66 | self.callbackId = command.callbackId;
67 |
68 | if (!self.motionManager)
69 | {
70 | self.motionManager = [[CMMotionManager alloc] init];
71 | }
72 |
73 | if ([self.motionManager isAccelerometerAvailable] == YES) {
74 | // Assign the update interval to the motion manager and start updates
75 | [self.motionManager setAccelerometerUpdateInterval:kAccelerometerInterval/1000]; // expected in seconds
76 | __weak CDVAccelerometer* weakSelf = self;
77 | [self.motionManager startAccelerometerUpdatesToQueue:[NSOperationQueue mainQueue] withHandler:^(CMAccelerometerData *accelerometerData, NSError *error) {
78 | weakSelf.x = accelerometerData.acceleration.x;
79 | weakSelf.y = accelerometerData.acceleration.y;
80 | weakSelf.z = accelerometerData.acceleration.z;
81 | weakSelf.timestamp = ([[NSDate date] timeIntervalSince1970] * 1000);
82 | [weakSelf returnAccelInfo];
83 | }];
84 |
85 | if (!self.isRunning) {
86 | self.isRunning = YES;
87 | }
88 | }
89 | else {
90 |
91 | NSLog(@"Running in Simulator? All gyro tests will fail.");
92 | CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_INVALID_ACTION messageAsString:@"Error. Accelerometer Not Available."];
93 |
94 | [self.commandDelegate sendPluginResult:result callbackId:self.callbackId];
95 | }
96 |
97 | }
98 |
99 | - (void)onReset
100 | {
101 | [self stop:nil];
102 | }
103 |
104 | - (void)stop:(CDVInvokedUrlCommand*)command
105 | {
106 | if ([self.motionManager isAccelerometerAvailable] == YES) {
107 | if (self.haveReturnedResult == NO){
108 | // block has not fired before stop was called, return whatever result we currently have
109 | [self returnAccelInfo];
110 | }
111 | [self.motionManager stopAccelerometerUpdates];
112 | }
113 | self.isRunning = NO;
114 | }
115 |
116 | - (void)returnAccelInfo
117 | {
118 | // Create an acceleration object
119 | NSMutableDictionary* accelProps = [NSMutableDictionary dictionaryWithCapacity:4];
120 |
121 | [accelProps setValue:[NSNumber numberWithDouble:self.x * kGravitationalConstant] forKey:@"x"];
122 | [accelProps setValue:[NSNumber numberWithDouble:self.y * kGravitationalConstant] forKey:@"y"];
123 | [accelProps setValue:[NSNumber numberWithDouble:self.z * kGravitationalConstant] forKey:@"z"];
124 | [accelProps setValue:[NSNumber numberWithDouble:self.timestamp] forKey:@"timestamp"];
125 |
126 | CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:accelProps];
127 | [result setKeepCallback:[NSNumber numberWithBool:YES]];
128 | [self.commandDelegate sendPluginResult:result callbackId:self.callbackId];
129 | self.haveReturnedResult = YES;
130 | }
131 |
132 | // TODO: Consider using filtering to isolate instantaneous data vs. gravity data -jm
133 |
134 | /*
135 | #define kFilteringFactor 0.1
136 |
137 | // Use a basic low-pass filter to keep only the gravity component of each axis.
138 | grav_accelX = (acceleration.x * kFilteringFactor) + ( grav_accelX * (1.0 - kFilteringFactor));
139 | grav_accelY = (acceleration.y * kFilteringFactor) + ( grav_accelY * (1.0 - kFilteringFactor));
140 | grav_accelZ = (acceleration.z * kFilteringFactor) + ( grav_accelZ * (1.0 - kFilteringFactor));
141 |
142 | // Subtract the low-pass value from the current value to get a simplified high-pass filter
143 | instant_accelX = acceleration.x - ( (acceleration.x * kFilteringFactor) + (instant_accelX * (1.0 - kFilteringFactor)) );
144 | instant_accelY = acceleration.y - ( (acceleration.y * kFilteringFactor) + (instant_accelY * (1.0 - kFilteringFactor)) );
145 | instant_accelZ = acceleration.z - ( (acceleration.z * kFilteringFactor) + (instant_accelZ * (1.0 - kFilteringFactor)) );
146 |
147 |
148 | */
149 | @end
150 |
--------------------------------------------------------------------------------
/plugins/cordova-plugin-device-motion/doc/ru/index.md:
--------------------------------------------------------------------------------
1 |
19 |
20 | # cordova-plugin-device-motion
21 |
22 | Этот плагин обеспечивает доступ к акселерометру устройства. Акселерометр является датчиком движения, который обнаруживает изменение (*дельта*) в движении относительно текущей ориентации устройства, в трех измерениях вдоль осей *x*, *y* и *z* .
23 |
24 | ## Установка
25 |
26 | cordova plugin add cordova-plugin-device-motion
27 |
28 |
29 | ## Поддерживаемые платформы
30 |
31 | * Amazon Fire ОС
32 | * Android
33 | * BlackBerry 10
34 | * Обозреватель
35 | * Firefox OS
36 | * iOS
37 | * Tizen
38 | * Windows Phone 7 и 8
39 | * Windows 8
40 |
41 | ## Методы
42 |
43 | * navigator.accelerometer.getCurrentAcceleration
44 | * navigator.accelerometer.watchAcceleration
45 | * navigator.accelerometer.clearWatch
46 |
47 | ## Объекты
48 |
49 | * Acceleration
50 |
51 | ## navigator.accelerometer.getCurrentAcceleration
52 |
53 | Возвращает текущее ускорение вдоль осей *x*, *y* и *z*.
54 |
55 | Значения ускорения передаются функции обратного вызова `accelerometerSuccess`.
56 |
57 | navigator.accelerometer.getCurrentAcceleration(accelerometerSuccess, accelerometerError);
58 |
59 |
60 | ### Пример
61 |
62 | function onSuccess(acceleration) {
63 | alert('Acceleration X: ' + acceleration.x + '\n' +
64 | 'Acceleration Y: ' + acceleration.y + '\n' +
65 | 'Acceleration Z: ' + acceleration.z + '\n' +
66 | 'Timestamp: ' + acceleration.timestamp + '\n');
67 | };
68 |
69 | function onError() {
70 | alert('onError!');
71 | };
72 |
73 | navigator.accelerometer.getCurrentAcceleration(onSuccess, onError);
74 |
75 |
76 | ### Браузер причуды
77 |
78 | Значения X, Y, Z движения являются все случайным в целях моделирования акселерометра.
79 |
80 | ### Особенности iOS
81 |
82 | * iOS не поддерживает автоматическое обновление значений для ускорения.
83 |
84 | * Вы должны самостоятельно отслеживать изменение ускорения и считывать данные через определенные интервалы времени.
85 |
86 | * Таким образом функция `getCurrentAcceleration` возвращает последнее значение, полученное при вызове `watchAccelerometer`.
87 |
88 | ## navigator.accelerometer.watchAcceleration
89 |
90 | Извлекает текущая устройство `Acceleration` с постоянным интервалом, выполнение `accelerometerSuccess` функция обратного вызова каждый раз. Задайте интервал в миллисекундах, через `acceleratorOptions` объекта `frequency` параметр.
91 |
92 | Возвращаемый смотреть ссылки ID акселерометр часы интервал и может быть использован с `navigator.accelerometer.clearWatch` чтобы остановить просмотр акселерометр.
93 |
94 | var watchID = navigator.accelerometer.watchAcceleration(accelerometerSuccess,
95 | accelerometerError,
96 | accelerometerOptions);
97 |
98 |
99 | * **accelerometerOptions**: Объект с следующие необязательные свойствами:
100 | * **период**: запрошенный период звонков на accelerometerSuccess с ускорение данных в миллисекундах. *(Число)* (По умолчанию: 10000)
101 |
102 | ### Пример
103 |
104 | function onSuccess(acceleration) {
105 | alert('Acceleration X: ' + acceleration.x + '\n' +
106 | 'Acceleration Y: ' + acceleration.y + '\n' +
107 | 'Acceleration Z: ' + acceleration.z + '\n' +
108 | 'Timestamp: ' + acceleration.timestamp + '\n');
109 | };
110 |
111 | function onError() {
112 | alert('onError!');
113 | };
114 |
115 | var options = { frequency: 3000 }; // Update every 3 seconds
116 |
117 | var watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);
118 |
119 |
120 | ### Особенности iOS
121 |
122 | API вызывает функцию обратного вызова с указанным интервалом, но имеет ограничение по частоте запросов к устройству от 40 мс и до 1000 мс. Например если вы запрашиваете интервал 3 секунды, (3000 мс), API запрашивает данные от устройства каждую секунду, но функция обратного вызова будет срабатывать только каждые 3 секунды.
123 |
124 | ## navigator.accelerometer.clearWatch
125 |
126 | Останавливает отслеживание изменений объекта `Acceleration`, на который ссылается параметр `watchID`.
127 |
128 | navigator.accelerometer.clearWatch(watchID);
129 |
130 |
131 | * **watchID**: идентификатор, возвращенный`navigator.accelerometer.watchAcceleration`.
132 |
133 | ### Пример
134 |
135 | var watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);
136 |
137 | // ... later on ...
138 |
139 | navigator.accelerometer.clearWatch(watchID);
140 |
141 |
142 | ## Acceleration
143 |
144 | Содержит данные полученные от акселерометра на определенный момент времени. Ускорение значения включают эффект гравитации (9,81 м/с ^ 2), так что когда устройство лежит плоская и вверх, *x*, *y*, и *z* значения, возвращаемые должны быть `` , `` , и`9.81`.
145 |
146 | ### Параметры
147 |
148 | * **x**: величина ускорение по оси x. (в м/с ^ 2) *(Число)*
149 | * **y**: величина ускорение по оси y. (в м/с ^ 2) *(Число)*
150 | * **z**: величина ускорение по оси z. (в м/с ^ 2) *(Число)*
151 | * **timestamp**: временая метка в миллисекундах. *(DOMTimeStamp)*
152 |
--------------------------------------------------------------------------------
/plugins/cordova-plugin-device-motion/doc/es/index.md:
--------------------------------------------------------------------------------
1 |
19 |
20 | # cordova-plugin-device-motion
21 |
22 | Este plugin proporciona acceso a acelerómetro del dispositivo. El acelerómetro es un sensor de movimiento que detecta el cambio (*delta*) en movimiento con respecto a la orientación actual del dispositivo, en tres dimensiones sobre el eje *x*, *y*y *z* .
23 |
24 | El acceso es por un global `navigator.accelerometer` objeto.
25 |
26 | Aunque el objeto está unido al ámbito global `navigator` , no estará disponible hasta después de la `deviceready` evento.
27 |
28 | document.addEventListener ("deviceready", onDeviceReady, false);
29 | function onDeviceReady() {console.log(navigator.accelerometer)};
30 |
31 |
32 | ## Instalación
33 |
34 | Cordova plugin añade cordova-plugin-device-movimiento
35 |
36 |
37 | ## Plataformas soportadas
38 |
39 | * Amazon fire OS
40 | * Android
41 | * BlackBerry 10
42 | * Explorador
43 | * Firefox OS
44 | * iOS
45 | * Tizen
46 | * Windows Phone 8
47 | * Windows
48 |
49 | ## Métodos
50 |
51 | * navigator.accelerometer.getCurrentAcceleration
52 | * navigator.accelerometer.watchAcceleration
53 | * navigator.accelerometer.clearWatch
54 |
55 | ## Objetos
56 |
57 | * Acceleration
58 |
59 | ## navigator.accelerometer.getCurrentAcceleration
60 |
61 | Tienes la aceleración actual a lo largo de los ejes *x*, *y*y *z* .
62 |
63 | Estos valores de aceleración son devueltos a la `accelerometerSuccess` función de callback.
64 |
65 | navigator.accelerometer.getCurrentAcceleration (accelerometerSuccess, accelerometerError);
66 |
67 |
68 | ### Ejemplo
69 |
70 | function onSuccess(acceleration) {alert ('Aceleración X:' + acceleration.x + '\n' + 'Aceleración Y:' + acceleration.y + '\n' + 'Aceleración Z:' + acceleration.z + '\n' + ' Timestamp: ' + acceleration.timestamp + '\n');};
71 |
72 | función onError() {alert('onError!');};
73 |
74 | navigator.accelerometer.getCurrentAcceleration (onSuccess, onError);
75 |
76 |
77 | ### Navegador rarezas
78 |
79 | Los valores para X, Y, movimiento Z son todo generada aleatoriamente en orden para simular el acelerómetro.
80 |
81 | ### iOS rarezas
82 |
83 | * iOS no reconoce el concepto de conseguir la aceleración actual en cualquier momento dado.
84 |
85 | * Debes ver la aceleración y capturar los datos en determinados intervalos de tiempo.
86 |
87 | * Así, la función de `getCurrentAcceleration` rinde el último valor informado de una llamada de `watchAccelerometer`.
88 |
89 | ## navigator.accelerometer.watchAcceleration
90 |
91 | Recupera el dispositivo actual de `Acceleration` a intervalos regulares, ejecutar el `accelerometerSuccess` función callback cada vez. Especificar el intervalo en milisegundos mediante la `acceleratorOptions` del objeto `frequency` parámetro.
92 |
93 | El vuelto ver referencias ID intervalo del acelerómetro reloj y puede ser utilizado con `navigator.accelerometer.clearWatch` para dejar de ver el acelerómetro.
94 |
95 | var watchID = navigator.accelerometer.watchAcceleration (accelerometerSuccess, accelerometerError, accelerometerOptions);
96 |
97 |
98 | * **accelerometerOptions**: Un objeto con las llaves opcionales siguientes:
99 | * **periodo**: periodo solicitado de llamadas a accelerometerSuccess con los datos de aceleración en milisegundos. *(Número)* (Por defecto: 10000)
100 |
101 | ### Ejemplo
102 |
103 | function onSuccess(acceleration) {alert ('Aceleración X:' + acceleration.x + '\n' + 'Aceleración Y:' + acceleration.y + '\n' + 'Aceleración Z:' + acceleration.z + '\n' + ' Timestamp: ' + acceleration.timestamp + '\n');};
104 |
105 | función onError() {alert('onError!');};
106 |
107 | var opciones = { frequency: 3000 }; Actualizar cada 3 segundos var watchID = navigator.accelerometer.watchAcceleration (onSuccess, onError, opciones);
108 |
109 |
110 | ### iOS rarezas
111 |
112 | La API llama a la función de devolución de llamada de éxito en el intervalo solicitado, pero restringe la gama de solicitudes que el dispositivo entre 40ms y 1000ms. Por ejemplo, si usted solicita un intervalo de 3 segundos, (3000ms), la API solicita datos desde el dispositivo cada 1 segundo, pero sólo ejecuta el callback de éxito cada 3 segundos.
113 |
114 | ## navigator.accelerometer.clearWatch
115 |
116 | Dejar de mirar el `Acceleration` referenciado por el `watchID` parámetro.
117 |
118 | navigator.accelerometer.clearWatch(watchID);
119 |
120 |
121 | * **watchID**: el identificador devuelto por`navigator.accelerometer.watchAcceleration`.
122 |
123 | ### Ejemplo
124 |
125 | var watchID = navigator.accelerometer.watchAcceleration (onSuccess, onError, opciones);
126 |
127 | ... adelante... navigator.accelerometer.clearWatch(watchID);
128 |
129 |
130 | ## Acceleration
131 |
132 | Contiene `Accelerometer` datos capturados en un punto específico en el tiempo. Valores de aceleración incluyen el efecto de la gravedad (9,81 m/s ^ 2), de modo que cuando se encuentra un dispositivo plano y hacia arriba, *x*, *y*, y *z* valores devueltos deben ser `` , `` , y`9.81`.
133 |
134 | ### Propiedades
135 |
136 | * **x**: Cantidad de aceleración en el eje X. (en m/s^2) *(Number)*
137 | * **y**: Cantidad de aceleración en el eje Y. (en m/s^2) *(Number)*
138 | * **z**: Cantidad de aceleración en el eje Z. (en m/s^2) *(Number)*
139 | * **timestamp**: Momento de la captura en milisegundos.*(DOMTimeStamp)*
140 |
--------------------------------------------------------------------------------
/plugins/cordova-plugin-device-motion/doc/fr/index.md:
--------------------------------------------------------------------------------
1 |
19 |
20 | # cordova-plugin-device-motion
21 |
22 | Ce plugin permet d'accéder à l'accéléromètre de l'appareil. L'accéléromètre est un capteur de mouvement qui détecte la modification (*delta*) en mouvement par rapport à l'orientation actuelle de l'appareil, en trois dimensions le long de l'axe *x*, *y*et *z* .
23 |
24 | Accès se fait par un global `navigator.accelerometer` objet.
25 |
26 | Bien que l'objet est attaché à la portée globale `navigator` , il n'est pas disponible jusqu'après la `deviceready` événement.
27 |
28 | document.addEventListener (« deviceready », onDeviceReady, false) ;
29 | function onDeviceReady() {console.log(navigator.accelerometer);}
30 |
31 |
32 | ## Installation
33 |
34 | Cordova plugin ajouter cordova-plugin-device-motion
35 |
36 |
37 | ## Plates-formes prises en charge
38 |
39 | * Amazon Fire OS
40 | * Android
41 | * BlackBerry 10
42 | * Navigateur
43 | * Firefox OS
44 | * iOS
45 | * Paciarelli
46 | * Windows Phone 8
47 | * Windows
48 |
49 | ## Méthodes
50 |
51 | * navigator.accelerometer.getCurrentAcceleration
52 | * navigator.accelerometer.watchAcceleration
53 | * navigator.accelerometer.clearWatch
54 |
55 | ## Objets
56 |
57 | * Acceleration
58 |
59 | ## navigator.accelerometer.getCurrentAcceleration
60 |
61 | Obtenir l'accélération courante le long des axes *x*, *y*et *z* .
62 |
63 | Ces valeurs d'accélération sont retournés à la `accelerometerSuccess` fonction de rappel.
64 |
65 | navigator.accelerometer.getCurrentAcceleration (accelerometerSuccess, accelerometerError) ;
66 |
67 |
68 | ### Exemple
69 |
70 | function onSuccess(acceleration) {alert ("Accélération X:" + acceleration.x + « \n » + "Accélération Y:" + acceleration.y + « \n » + « Accélération Z: » + acceleration.z + « \n » + ' Timestamp: "+ acceleration.timestamp + « \n »);} ;
71 |
72 | fonction onError() {alert('onError!');} ;
73 |
74 | navigator.accelerometer.getCurrentAcceleration (onSuccess, onError) ;
75 |
76 |
77 | ### Bizarreries navigateur
78 |
79 | Les valeurs x, Y, motion de Z sont tous ordre généré de manière aléatoire dans pour simuler l'accéléromètre.
80 |
81 | ### iOS Quirks
82 |
83 | * iOS ne permet pas d'obtenir l'accélération en cours à un instant donné.
84 |
85 | * Vous devez observer l'accélération et capturer ses données à un intervalle de temps donné.
86 |
87 | * De ce fait, la fonction `getCurrentAcceleration` renvoie la dernière valeur retournée par un appel à `watchAccelerometer`.
88 |
89 | ## navigator.accelerometer.watchAcceleration
90 |
91 | Récupère le dispositif actuel de `Acceleration` à intervalle régulier, l'exécution de la `accelerometerSuccess` fonction de rappel chaque fois. Spécifiez l'intervalle, en millisecondes, via le `acceleratorOptions` de l'objet `frequency` paramètre.
92 |
93 | Le retourné regarder ID références intervalle de surveillance de l'accéléromètre et peut être utilisé avec `navigator.accelerometer.clearWatch` d'arrêter de regarder l'accéléromètre.
94 |
95 | var watchID = navigator.accelerometer.watchAcceleration (accelerometerSuccess, accelerometerError, accelerometerOptions) ;
96 |
97 |
98 | * **accelerometerOptions**: Un objet avec les clés facultatives suivantes :
99 | * **période**: période demandée d'appels à accelerometerSuccess avec les données d'accélération en millisecondes. *(Nombre)* (Par défaut : 10000)
100 |
101 | ### Exemple
102 |
103 | function onSuccess(acceleration) {alert ("Accélération X:" + acceleration.x + « \n » + "Accélération Y:" + acceleration.y + « \n » + « Accélération Z: » + acceleration.z + « \n » + ' Timestamp: "+ acceleration.timestamp + « \n »);} ;
104 |
105 | fonction onError() {alert('onError!');} ;
106 |
107 | options de var = { frequency: 3000 } ; Mise à jour chaque 3 secondes var watchID = navigator.accelerometer.watchAcceleration (onSuccess, onError, options) ;
108 |
109 |
110 | ### iOS Quirks
111 |
112 | L'API appelle la fonction de rappel de succès à l'intervalle demandé, mais restreint l'éventail des demandes à l'appareil entre 40ms et 1000ms. Par exemple, si vous demandez un intervalle de 3 secondes, (3000ms), l'API demande des données de l'appareil toutes les 1 seconde, mais seulement exécute le rappel réussi toutes les 3 secondes.
113 |
114 | ## navigator.accelerometer.clearWatch
115 |
116 | Arrêter de regarder le `Acceleration` référencé par le `watchID` paramètre.
117 |
118 | navigator.accelerometer.clearWatch(watchID) ;
119 |
120 |
121 | * **watchID**: l'ID retourné par`navigator.accelerometer.watchAcceleration`.
122 |
123 | ### Exemple
124 |
125 | var watchID = navigator.accelerometer.watchAcceleration (onSuccess, onError, options) ;
126 |
127 | ... plus tard... navigator.accelerometer.clearWatch(watchID) ;
128 |
129 |
130 | ## Accélération
131 |
132 | Contient `Accelerometer` données capturées à un point précis dans le temps. Valeurs d'accélération comprennent l'effet de la pesanteur (9,81 m/s ^ 2), de sorte que lorsqu'un périphérique se trouve plat et face vers le haut, *x*, *y*, et *z* valeurs retournées doivent être `` , `` , et`9.81`.
133 |
134 | ### Propriétés
135 |
136 | * **x**: Valeur de l'accélération sur l'axe des x. (en m/s^2) *(Number)*
137 | * **y**: Valeur de l'accélération sur l'axe des y. (en m/s^2) *(Number)*
138 | * **y**: Valeur de l'accélération sur l'axe des z. (en m/s^2) *(Number)*
139 | * **timestamp**: Date de création en millisecondes. *(DOMTimeStamp)*
140 |
--------------------------------------------------------------------------------
/plugins/cordova-plugin-device-motion/plugin.xml:
--------------------------------------------------------------------------------
1 |
2 |
20 |
21 |
24 |
25 | Device Motion
26 | Cordova Device Motion Plugin
27 | Apache 2.0
28 | cordova,device,motion
29 | https://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion.git
30 | https://issues.apache.org/jira/browse/CB/component/12320636
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
--------------------------------------------------------------------------------
/plugins/cordova-plugin-device-motion/doc/pl/index.md:
--------------------------------------------------------------------------------
1 |
19 |
20 | # cordova-plugin-device-motion
21 |
22 | Ten plugin umożliwia dostęp do akcelerometru. Akcelerometr jest czujnikiem ruchu, który wykrywa zmiany (*delta*) w ruchu względem bieżącej orientacji urządzenia, w trzech wymiarach na osi *x*, *y*i *z* .
23 |
24 | Dostęp odbywa się za pomocą obiektu globalnego `navigator.accelerometer`.
25 |
26 | Mimo, że obiekt jest dołączony do globalnego zakresu `navigator`, to nie dostępne dopiero po zdarzeniu `deviceready`.
27 |
28 | document.addEventListener("deviceready", onDeviceReady, false);
29 | function onDeviceReady() {
30 | console.log(navigator.accelerometer);
31 | }
32 |
33 |
34 | ## Instalacja
35 |
36 | cordova plugin add cordova-plugin-device-motion
37 |
38 |
39 | ## Obsługiwane platformy
40 |
41 | * Amazon Fire OS
42 | * Android
43 | * BlackBerry 10
44 | * Przeglądarka
45 | * Firefox OS
46 | * iOS
47 | * Tizen
48 | * Windows Phone 8
49 | * Windows
50 |
51 | ## Metody
52 |
53 | * navigator.accelerometer.getCurrentAcceleration
54 | * navigator.accelerometer.watchAcceleration
55 | * navigator.accelerometer.clearWatch
56 |
57 | ## Obiekty
58 |
59 | * Acceleration
60 |
61 | ## navigator.accelerometer.getCurrentAcceleration
62 |
63 | Uzyskać aktualne przyspieszenie wzdłuż osi *x*, *y* i *z*.
64 |
65 | Te wartości przyspieszenia są zwracane do funkcji wywołania zwrotnego `accelerometerSuccess`.
66 |
67 | navigator.accelerometer.getCurrentAcceleration(accelerometerSuccess, accelerometerError);
68 |
69 |
70 | ### Przykład
71 |
72 | function onSuccess(acceleration) {
73 | alert('Acceleration X: ' + acceleration.x + '\n' +
74 | 'Acceleration Y: ' + acceleration.y + '\n' +
75 | 'Acceleration Z: ' + acceleration.z + '\n' +
76 | 'Timestamp: ' + acceleration.timestamp + '\n');
77 | };
78 |
79 | function onError() {
80 | alert('onError!');
81 | };
82 |
83 | navigator.accelerometer.getCurrentAcceleration(onSuccess, onError);
84 |
85 |
86 | ### Quirks przeglądarki
87 |
88 | Wartości dla osi X, Y, Z ruchu są losowo generowane w celu symulacji akcelerometr.
89 |
90 | ### Dziwactwa iOS
91 |
92 | * W iOS nie wprowadzono możliwości zmierzenia aktualnego przyspieszenia w dowolnym punkcie.
93 |
94 | * Musisz obserwować przyspieszenie i odbierać wyniki w określonych odstępach czasu.
95 |
96 | * Podsumowując, funkcja `getCurrentAcceleration` zwraca ostatnią wartość zgłoszoną przez wywołanie `watchAccelerometer`.
97 |
98 | ## navigator.accelerometer.watchAcceleration
99 |
100 | Pobiera bieżącego urządzenia `Acceleration` w regularnych odstępach czasu, wykonywanie funkcji wywołania zwrotnego `accelerometerSuccess` każdorazowe. Określ interwał w milisekundach przez parametr obiektu `acceleratorOptions` `frequency`.
101 |
102 | Identyfikator zwrócony zegarek odwołuje akcelerometr zegarek interwał i może być używany z `navigator.accelerometer.clearWatch`, aby zatrzymać obejrzeniu akcelerometru.
103 |
104 | var watchID = navigator.accelerometer.watchAcceleration(accelerometerSuccess,
105 | accelerometerError,
106 | accelerometerOptions);
107 |
108 |
109 | * **accelerometerOptions**: Obiekt z następującymi opcjonalnymi kluczami:
110 | * **okres**: żądany okres wzywa do accelerometerSuccess z danych przyspieszenia w milisekundach. *(Liczba)* (Domyślnie: 10000)
111 |
112 | ### Przykład
113 |
114 | function onSuccess(acceleration) {
115 | alert('Acceleration X: ' + acceleration.x + '\n' +
116 | 'Acceleration Y: ' + acceleration.y + '\n' +
117 | 'Acceleration Z: ' + acceleration.z + '\n' +
118 | 'Timestamp: ' + acceleration.timestamp + '\n');
119 | };
120 |
121 | function onError() {
122 | alert('onError!');
123 | };
124 |
125 | var options = { frequency: 3000 }; // Update every 3 seconds
126 |
127 | var watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);
128 |
129 |
130 | ### Dziwactwa iOS
131 |
132 | Interfejs API wymaga sukcesu funkcji wywołania zwrotnego w interwał żądana, ale ogranicza zakres żądania do urządzenia między 40ms i 1000ms. Na przykład jeśli poprosisz o odstępie 3 sekundy (3000ms), interfejs API żądania danych z urządzenia co 1 sekundę, ale tylko wykonuje wywołanie zwrotne sukces co 3 sekundy.
133 |
134 | ## navigator.accelerometer.clearWatch
135 |
136 | Przestać oglądać `Acceleration` określany przez parametr `watchID`.
137 |
138 | navigator.accelerometer.clearWatch(watchID);
139 |
140 |
141 | * **watchID**: Identyfikator zwrócony przez `navigator.accelerometer.watchAcceleration`.
142 |
143 | ### Przykład
144 |
145 | var watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);
146 |
147 | // ... later on ...
148 |
149 | navigator.accelerometer.clearWatch(watchID);
150 |
151 |
152 | ## Acceleration
153 |
154 | Zawiera `Accelerometer` dane przechwycone w określonym czasie. Wartości przyśpieszenia to efekt grawitacji (9.81 m/s ^ 2), tak, że kiedy urządzenie znajduje się płaska i górę, *x*, *y*, i *z* wartości zwracane powinno być ``, `` i `9.81`.
155 |
156 | ### Właściwości
157 |
158 | * **x**: Wartość przyśpieszenia na osi x. (w m/s^2) *(Liczba)*
159 | * **y**: Wartość przyśpieszenia na osi y. (w m/s^2) *(Liczba)*
160 | * **z**: Wartość przyśpieszenia na osi z. (w m/s^2) *(Liczba)*
161 | * **timestamp**: Znacznik czasu w milisekundach. *(DOMTimeStamp)*
162 |
--------------------------------------------------------------------------------
/plugins/cordova-plugin-device-motion/doc/fr/README.md:
--------------------------------------------------------------------------------
1 |
19 |
20 | # cordova-plugin-device-motion
21 |
22 | [](https://travis-ci.org/apache/cordova-plugin-device-motion)
23 |
24 | Ce plugin permet d'accéder à l'accéléromètre de l'appareil. L'accéléromètre est un capteur de mouvement qui détecte la modification (*delta*) en mouvement par rapport à l'orientation actuelle de l'appareil, en trois dimensions le long de l'axe *x*, *y*et *z* .
25 |
26 | Accès se fait par un global `navigator.accelerometer` objet.
27 |
28 | Bien que l'objet est attaché à la portée globale `navigator` , il n'est pas disponible jusqu'après la `deviceready` événement.
29 |
30 | document.addEventListener (« deviceready », onDeviceReady, false) ;
31 | function onDeviceReady() {console.log(navigator.accelerometer);}
32 |
33 |
34 | ## Installation
35 |
36 | cordova plugin add cordova-plugin-device-motion
37 |
38 |
39 | ## Plates-formes supportées
40 |
41 | * Amazon Fire OS
42 | * Android
43 | * BlackBerry 10
44 | * Navigateur
45 | * Firefox OS
46 | * iOS
47 | * Paciarelli
48 | * Windows Phone 8
49 | * Windows
50 |
51 | ## Méthodes
52 |
53 | * navigator.accelerometer.getCurrentAcceleration
54 | * navigator.accelerometer.watchAcceleration
55 | * navigator.accelerometer.clearWatch
56 |
57 | ## Objets
58 |
59 | * Acceleration
60 |
61 | ## navigator.accelerometer.getCurrentAcceleration
62 |
63 | Obtenir l'accélération courante le long des axes *x*, *y*et *z* .
64 |
65 | Ces valeurs d'accélération sont retournés à la `accelerometerSuccess` fonction de rappel.
66 |
67 | navigator.accelerometer.getCurrentAcceleration (accelerometerSuccess, accelerometerError) ;
68 |
69 |
70 | ### Exemple
71 |
72 | function onSuccess(acceleration) {alert ("Accélération X:" + acceleration.x + « \n » + "Accélération Y:" + acceleration.y + « \n » + « Accélération Z: » + acceleration.z + « \n » + ' Timestamp: "+ acceleration.timestamp + « \n »);} ;
73 |
74 | fonction onError() {alert('onError!');} ;
75 |
76 | navigator.accelerometer.getCurrentAcceleration (onSuccess, onError) ;
77 |
78 |
79 | ### Bizarreries navigateur
80 |
81 | Les valeurs x, Y, motion de Z sont tous ordre généré de manière aléatoire dans pour simuler l'accéléromètre.
82 |
83 | ### Notes au sujet d'iOS
84 |
85 | * iOS ne permet pas d'obtenir l'accélération en cours à un instant donné.
86 |
87 | * Vous devez observer l'accélération et capturer ses données à un intervalle de temps donné.
88 |
89 | * De ce fait, la fonction `getCurrentAcceleration` renvoie la dernière valeur retournée par un appel à `watchAccelerometer`.
90 |
91 | ## navigator.accelerometer.watchAcceleration
92 |
93 | Récupère le dispositif actuel de `Acceleration` à intervalle régulier, l'exécution de la `accelerometerSuccess` fonction de rappel chaque fois. Spécifiez l'intervalle, en millisecondes, via le `acceleratorOptions` de l'objet `frequency` paramètre.
94 |
95 | Le retourné regarder ID références intervalle de surveillance de l'accéléromètre et peut être utilisé avec `navigator.accelerometer.clearWatch` d'arrêter de regarder l'accéléromètre.
96 |
97 | var watchID = navigator.accelerometer.watchAcceleration (accelerometerSuccess, accelerometerError, accelerometerOptions) ;
98 |
99 |
100 | * **accelerometerOptions**: Un objet avec les clés facultatives suivantes :
101 | * **période**: période demandée d'appels à accelerometerSuccess avec les données d'accélération en millisecondes. *(Nombre)* (Par défaut : 10000)
102 |
103 | ### Exemple
104 |
105 | function onSuccess(acceleration) {alert ("Accélération X:" + acceleration.x + « \n » + "Accélération Y:" + acceleration.y + « \n » + « Accélération Z: » + acceleration.z + « \n » + ' Timestamp: "+ acceleration.timestamp + « \n »);} ;
106 |
107 | fonction onError() {alert('onError!');} ;
108 |
109 | options de var = { frequency: 3000 } ; Mise à jour chaque 3 secondes var watchID = navigator.accelerometer.watchAcceleration (onSuccess, onError, options) ;
110 |
111 |
112 | ### Notes au sujet d'iOS
113 |
114 | L'API appelle la fonction de rappel de succès à l'intervalle demandé, mais restreint l'éventail des demandes à l'appareil entre 40ms et 1000ms. Par exemple, si vous demandez un intervalle de 3 secondes, (3000ms), l'API demande des données de l'appareil toutes les 1 seconde, mais seulement exécute le rappel réussi toutes les 3 secondes.
115 |
116 | ## navigator.accelerometer.clearWatch
117 |
118 | Arrêter de regarder le `Acceleration` référencé par le `watchID` paramètre.
119 |
120 | navigator.accelerometer.clearWatch(watchID) ;
121 |
122 |
123 | * **watchID**: l'ID retourné par`navigator.accelerometer.watchAcceleration`.
124 |
125 | ### Exemple
126 |
127 | var watchID = navigator.accelerometer.watchAcceleration (onSuccess, onError, options) ;
128 |
129 | ... plus tard... navigator.accelerometer.clearWatch(watchID) ;
130 |
131 |
132 | ## Acceleration
133 |
134 | Contient `Accelerometer` données capturées à un point précis dans le temps. Valeurs d'accélération comprennent l'effet de la pesanteur (9,81 m/s ^ 2), de sorte que lorsqu'un périphérique se trouve plat et face vers le haut, *x*, *y*, et *z* valeurs retournées doivent être `` , `` , et`9.81`.
135 |
136 | ### Propriétés
137 |
138 | * **x**: Valeur de l'accélération sur l'axe des x. (en m/s^2) *(Number)*
139 | * **y**: Valeur de l'accélération sur l'axe des y. (en m/s^2) *(Number)*
140 | * **y**: Valeur de l'accélération sur l'axe des z. (en m/s^2) *(Number)*
141 | * **timestamp**: Date de création en millisecondes. *(DOMTimeStamp)*
--------------------------------------------------------------------------------
/plugins/cordova-plugin-device-motion/doc/it/index.md:
--------------------------------------------------------------------------------
1 |
19 |
20 | # cordova-plugin-device-motion
21 |
22 | Questo plugin consente di accedere all'accelerometro del dispositivo. L'accelerometro è un sensore di movimento che rileva il cambiamento (*delta*) nel movimento relativo l'orientamento corrente del dispositivo, in tre dimensioni lungo l'asse *x*, *y*e *z* .
23 |
24 | L'accesso avviene tramite un oggetto globale `navigator.accelerometer`.
25 |
26 | Anche se l'oggetto è associato con ambito globale del `navigator`, non è disponibile fino a dopo l'evento `deviceready`.
27 |
28 | document.addEventListener("deviceready", onDeviceReady, false);
29 | function onDeviceReady() {
30 | console.log(navigator.accelerometer);
31 | }
32 |
33 |
34 | ## Installazione
35 |
36 | cordova plugin add cordova-plugin-device-motion
37 |
38 |
39 | ## Piattaforme supportate
40 |
41 | * Amazon fuoco OS
42 | * Android
43 | * BlackBerry 10
44 | * Browser
45 | * Firefox OS
46 | * iOS
47 | * Tizen
48 | * Windows Phone 8
49 | * Windows
50 |
51 | ## Metodi
52 |
53 | * navigator.accelerometer.getCurrentAcceleration
54 | * navigator.accelerometer.watchAcceleration
55 | * navigator.accelerometer.clearWatch
56 |
57 | ## Oggetti
58 |
59 | * Accelerazione
60 |
61 | ## navigator.accelerometer.getCurrentAcceleration
62 |
63 | Ottenere l'attuale accelerazione lungo gli assi *x*, *y* e *z*.
64 |
65 | I valori di accelerazione vengono restituiti alla funzione di callback `accelerometerSuccess`.
66 |
67 | navigator.accelerometer.getCurrentAcceleration(accelerometerSuccess, accelerometerError);
68 |
69 |
70 | ### Esempio
71 |
72 | function onSuccess(acceleration) {
73 | alert('Acceleration X: ' + acceleration.x + '\n' +
74 | 'Acceleration Y: ' + acceleration.y + '\n' +
75 | 'Acceleration Z: ' + acceleration.z + '\n' +
76 | 'Timestamp: ' + acceleration.timestamp + '\n');
77 | };
78 |
79 | function onError() {
80 | alert('onError!');
81 | };
82 |
83 | navigator.accelerometer.getCurrentAcceleration(onSuccess, onError);
84 |
85 |
86 | ### Stranezze Browser
87 |
88 | I valori per X, Y, movimento Z sono tutti generati casualmente in ordine per simulare l'accelerometro.
89 |
90 | ### iOS stranezze
91 |
92 | * iOS non riconosce il concetto di ottenere l'accelerazione della corrente in un dato punto.
93 |
94 | * Si deve guardare l'accelerazione e acquisire i dati di intervalli di tempo dato.
95 |
96 | * Così, il `getCurrentAcceleration` funzione restituisce l'ultimo valore segnalato da un `watchAccelerometer` chiamare.
97 |
98 | ## navigator.accelerometer.watchAcceleration
99 |
100 | Recupera corrente del dispositivo `Acceleration` a intervalli regolari, l'esecuzione della funzione di callback `accelerometerSuccess` ogni volta. Specificare l'intervallo in millisecondi tramite parametro `frequency` dell'oggetto `acceleratorOptions`.
101 |
102 | L'orologio restituito ID fa riferimento intervallo orologio di accelerometro e può essere utilizzato con `navigator.accelerometer.clearWatch` a smettere di guardare l'accelerometro.
103 |
104 | var watchID = navigator.accelerometer.watchAcceleration(accelerometerSuccess,
105 | accelerometerError,
106 | accelerometerOptions);
107 |
108 |
109 | * **accelerometerOptions**: Un oggetto con le seguenti chiavi opzionali:
110 | * **periodo**: periodo richiesto di chiamate a accelerometerSuccess con i dati di accelerazione in millisecondi. *(Numero)* (Default: 10000)
111 |
112 | ### Esempio
113 |
114 | function onSuccess(acceleration) {
115 | alert('Acceleration X: ' + acceleration.x + '\n' +
116 | 'Acceleration Y: ' + acceleration.y + '\n' +
117 | 'Acceleration Z: ' + acceleration.z + '\n' +
118 | 'Timestamp: ' + acceleration.timestamp + '\n');
119 | };
120 |
121 | function onError() {
122 | alert('onError!');
123 | };
124 |
125 | var options = { frequency: 3000 }; // Update every 3 seconds
126 |
127 | var watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);
128 |
129 |
130 | ### iOS stranezze
131 |
132 | L'API chiama la funzione di callback di successo nell'intervallo richiesto, ma limita la gamma di richieste alla periferica tra 40ms e 1000ms. Ad esempio, se si richiede un intervallo di 3 secondi, (3000ms), l'API richiede i dati dal dispositivo ogni secondo, ma esegue solo il callback di successo ogni 3 secondi.
133 |
134 | ## navigator.accelerometer.clearWatch
135 |
136 | Smettere di guardare l' `Acceleration` a cui fa riferimento il parametro `watchID`.
137 |
138 | navigator.accelerometer.clearWatch(watchID);
139 |
140 |
141 | * **watchID**: l'ID restituito da`navigator.accelerometer.watchAcceleration`.
142 |
143 | ### Esempio
144 |
145 | var watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);
146 |
147 | // ... later on ...
148 |
149 | navigator.accelerometer.clearWatch(watchID);
150 |
151 |
152 | ## Accelerazione
153 |
154 | Contiene i dati dell'`Accelerometer` catturati in un punto specifico nel tempo. I valori di accelerazione includono l'effetto della gravità (9,81 m/s ^ 2), in modo che quando un dispositivo si trova piatta e rivolto in su, *x*, *y*, e *z* valori restituiti dovrebbero essere ``, `` e `9,81`.
155 |
156 | ### Proprietà
157 |
158 | * **x**: quantità di accelerazione sull'asse x. (in m/s ^ 2) *(Numero)*
159 | * **y**: quantità di accelerazione sull'asse y. (in m/s ^ 2) *(Numero)*
160 | * **z**: quantità di accelerazione sull'asse z. (in m/s ^ 2) *(Numero)*
161 | * **timestamp**: creazione timestamp in millisecondi. *(DOMTimeStamp)*
162 |
--------------------------------------------------------------------------------
/plugins/cordova-plugin-device-motion/doc/pl/README.md:
--------------------------------------------------------------------------------
1 |
19 |
20 | # cordova-plugin-device-motion
21 |
22 | [](https://travis-ci.org/apache/cordova-plugin-device-motion)
23 |
24 | Ten plugin umożliwia dostęp do akcelerometru. Akcelerometr jest czujnikiem ruchu, który wykrywa zmiany (*delta*) w ruchu względem bieżącej orientacji urządzenia, w trzech wymiarach na osi *x*, *y*i *z* .
25 |
26 | Dostęp odbywa się za pomocą obiektu globalnego `navigator.accelerometer`.
27 |
28 | Mimo, że obiekt jest dołączony do globalnego zakresu `navigator`, to nie dostępne dopiero po zdarzeniu `deviceready`.
29 |
30 | document.addEventListener("deviceready", onDeviceReady, false);
31 | function onDeviceReady() {
32 | console.log(navigator.accelerometer);
33 | }
34 |
35 |
36 | ## Instalacja
37 |
38 | cordova plugin add cordova-plugin-device-motion
39 |
40 |
41 | ## Obsługiwane platformy
42 |
43 | * Amazon Fire OS
44 | * Android
45 | * BlackBerry 10
46 | * Przeglądarka
47 | * Firefox OS
48 | * iOS
49 | * Tizen
50 | * Windows Phone 8
51 | * Windows
52 |
53 | ## Metody
54 |
55 | * navigator.accelerometer.getCurrentAcceleration
56 | * navigator.accelerometer.watchAcceleration
57 | * navigator.accelerometer.clearWatch
58 |
59 | ## Obiekty
60 |
61 | * Acceleration
62 |
63 | ## navigator.accelerometer.getCurrentAcceleration
64 |
65 | Uzyskać aktualne przyspieszenie wzdłuż osi *x*, *y* i *z*.
66 |
67 | Te wartości przyspieszenia są zwracane do funkcji wywołania zwrotnego `accelerometerSuccess`.
68 |
69 | navigator.accelerometer.getCurrentAcceleration(accelerometerSuccess, accelerometerError);
70 |
71 |
72 | ### Przykład
73 |
74 | function onSuccess(acceleration) {
75 | alert('Acceleration X: ' + acceleration.x + '\n' +
76 | 'Acceleration Y: ' + acceleration.y + '\n' +
77 | 'Acceleration Z: ' + acceleration.z + '\n' +
78 | 'Timestamp: ' + acceleration.timestamp + '\n');
79 | };
80 |
81 | function onError() {
82 | alert('onError!');
83 | };
84 |
85 | navigator.accelerometer.getCurrentAcceleration(onSuccess, onError);
86 |
87 |
88 | ### Quirks przeglądarki
89 |
90 | Wartości dla osi X, Y, Z ruchu są losowo generowane w celu symulacji akcelerometr.
91 |
92 | ### Dziwactwa iOS
93 |
94 | * W iOS nie wprowadzono możliwości zmierzenia aktualnego przyspieszenia w dowolnym punkcie.
95 |
96 | * Musisz obserwować przyspieszenie i odbierać wyniki w określonych odstępach czasu.
97 |
98 | * Podsumowując, funkcja `getCurrentAcceleration` zwraca ostatnią wartość zgłoszoną przez wywołanie `watchAccelerometer`.
99 |
100 | ## navigator.accelerometer.watchAcceleration
101 |
102 | Pobiera bieżącego urządzenia `Acceleration` w regularnych odstępach czasu, wykonywanie funkcji wywołania zwrotnego `accelerometerSuccess` każdorazowe. Określ interwał w milisekundach przez parametr obiektu `acceleratorOptions` `frequency`.
103 |
104 | Identyfikator zwrócony zegarek odwołuje akcelerometr zegarek interwał i może być używany z `navigator.accelerometer.clearWatch`, aby zatrzymać obejrzeniu akcelerometru.
105 |
106 | var watchID = navigator.accelerometer.watchAcceleration(accelerometerSuccess,
107 | accelerometerError,
108 | accelerometerOptions);
109 |
110 |
111 | * **accelerometerOptions**: Obiekt z następującymi opcjonalnymi kluczami:
112 | * **okres**: żądany okres wzywa do accelerometerSuccess z danych przyspieszenia w milisekundach. *(Liczba)* (Domyślnie: 10000)
113 |
114 | ### Przykład
115 |
116 | function onSuccess(acceleration) {
117 | alert('Acceleration X: ' + acceleration.x + '\n' +
118 | 'Acceleration Y: ' + acceleration.y + '\n' +
119 | 'Acceleration Z: ' + acceleration.z + '\n' +
120 | 'Timestamp: ' + acceleration.timestamp + '\n');
121 | };
122 |
123 | function onError() {
124 | alert('onError!');
125 | };
126 |
127 | var options = { frequency: 3000 }; // Update every 3 seconds
128 |
129 | var watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);
130 |
131 |
132 | ### Dziwactwa iOS
133 |
134 | Interfejs API wymaga sukcesu funkcji wywołania zwrotnego w interwał żądana, ale ogranicza zakres żądania do urządzenia między 40ms i 1000ms. Na przykład jeśli poprosisz o odstępie 3 sekundy (3000ms), interfejs API żądania danych z urządzenia co 1 sekundę, ale tylko wykonuje wywołanie zwrotne sukces co 3 sekundy.
135 |
136 | ## navigator.accelerometer.clearWatch
137 |
138 | Przestać oglądać `Acceleration` określany przez parametr `watchID`.
139 |
140 | navigator.accelerometer.clearWatch(watchID);
141 |
142 |
143 | * **watchID**: Identyfikator zwrócony przez `navigator.accelerometer.watchAcceleration`.
144 |
145 | ### Przykład
146 |
147 | var watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);
148 |
149 | // ... later on ...
150 |
151 | navigator.accelerometer.clearWatch(watchID);
152 |
153 |
154 | ## Acceleration
155 |
156 | Zawiera `Accelerometer` dane przechwycone w określonym czasie. Wartości przyśpieszenia to efekt grawitacji (9.81 m/s ^ 2), tak, że kiedy urządzenie znajduje się płaska i górę, *x*, *y*, i *z* wartości zwracane powinno być ``, `` i `9.81`.
157 |
158 | ### Właściwości
159 |
160 | * **x**: Wartość przyśpieszenia na osi x. (w m/s^2) *(Liczba)*
161 | * **y**: Wartość przyśpieszenia na osi y. (w m/s^2) *(Liczba)*
162 | * **z**: Wartość przyśpieszenia na osi z. (w m/s^2) *(Liczba)*
163 | * **timestamp**: Znacznik czasu w milisekundach. *(DOMTimeStamp)*
--------------------------------------------------------------------------------
/plugins/cordova-plugin-device-motion/doc/es/README.md:
--------------------------------------------------------------------------------
1 |
19 |
20 | # cordova-plugin-device-motion
21 |
22 | [](https://travis-ci.org/apache/cordova-plugin-device-motion)
23 |
24 | Este plugin proporciona acceso a acelerómetro del dispositivo. El acelerómetro es un sensor de movimiento que detecta el cambio (*delta*) en movimiento con respecto a la orientación actual del dispositivo, en tres dimensiones sobre el eje *x*, *y*y *z* .
25 |
26 | El acceso es por un global `navigator.accelerometer` objeto.
27 |
28 | Aunque el objeto está unido al ámbito global `navigator` , no estará disponible hasta después de la `deviceready` evento.
29 |
30 | document.addEventListener ("deviceready", onDeviceReady, false);
31 | function onDeviceReady() {console.log(navigator.accelerometer)};
32 |
33 |
34 | ## Instalación
35 |
36 | cordova plugin add cordova-plugin-device-motion
37 |
38 |
39 | ## Plataformas soportadas
40 |
41 | * Amazon fire OS
42 | * Android
43 | * BlackBerry 10
44 | * Explorador
45 | * Firefox OS
46 | * iOS
47 | * Tizen
48 | * Windows Phone 8
49 | * Windows
50 |
51 | ## Métodos
52 |
53 | * navigator.accelerometer.getCurrentAcceleration
54 | * navigator.accelerometer.watchAcceleration
55 | * navigator.accelerometer.clearWatch
56 |
57 | ## Objetos
58 |
59 | * Acceleration
60 |
61 | ## navigator.accelerometer.getCurrentAcceleration
62 |
63 | Tienes la aceleración actual a lo largo de los ejes *x*, *y*y *z* .
64 |
65 | Estos valores de aceleración son devueltos a la `accelerometerSuccess` función de callback.
66 |
67 | navigator.accelerometer.getCurrentAcceleration(accelerometerSuccess, accelerometerError);
68 |
69 |
70 | ### Ejemplo
71 |
72 | function onSuccess(acceleration) {
73 | alert('Acceleration X: ' + acceleration.x + '\n' +
74 | 'Acceleration Y: ' + acceleration.y + '\n' +
75 | 'Acceleration Z: ' + acceleration.z + '\n' +
76 | 'Timestamp: ' + acceleration.timestamp + '\n');
77 | };
78 |
79 | function onError() {
80 | alert('onError!');
81 | };
82 |
83 | navigator.accelerometer.getCurrentAcceleration(onSuccess, onError);
84 |
85 |
86 | ### Navegador rarezas
87 |
88 | Los valores para X, Y, movimiento Z son todo generada aleatoriamente en orden para simular el acelerómetro.
89 |
90 | ### iOS rarezas
91 |
92 | * iOS no reconoce el concepto de conseguir la aceleración actual en cualquier momento dado.
93 |
94 | * Debes ver la aceleración y capturar los datos en determinados intervalos de tiempo.
95 |
96 | * Así, la función de `getCurrentAcceleration` rinde el último valor informado de una llamada de `watchAccelerometer`.
97 |
98 | ## navigator.accelerometer.watchAcceleration
99 |
100 | Recupera el dispositivo actual de `Acceleration` a intervalos regulares, ejecutar el `accelerometerSuccess` función callback cada vez. Especificar el intervalo en milisegundos mediante la `acceleratorOptions` del objeto `frequency` parámetro.
101 |
102 | El vuelto ver referencias ID intervalo del acelerómetro reloj y puede ser utilizado con `navigator.accelerometer.clearWatch` para dejar de ver el acelerómetro.
103 |
104 | var watchID = navigator.accelerometer.watchAcceleration (accelerometerSuccess, accelerometerError, accelerometerOptions);
105 |
106 |
107 | * **accelerometerOptions**: Un objeto con las llaves opcionales siguientes:
108 | * **periodo**: periodo solicitado de llamadas a accelerometerSuccess con los datos de aceleración en milisegundos. *(Número)* (Por defecto: 10000)
109 |
110 | ### Ejemplo
111 |
112 | function onSuccess(acceleration) {
113 | alert('Acceleration X: ' + acceleration.x + '\n' +
114 | 'Acceleration Y: ' + acceleration.y + '\n' +
115 | 'Acceleration Z: ' + acceleration.z + '\n' +
116 | 'Timestamp: ' + acceleration.timestamp + '\n');
117 | };
118 |
119 | function onError() {
120 | alert('onError!');
121 | };
122 |
123 | var options = { frequency: 3000 }; // Update every 3 seconds
124 |
125 | var watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);
126 |
127 |
128 | ### iOS rarezas
129 |
130 | La API llama a la función de devolución de llamada de éxito en el intervalo solicitado, pero restringe la gama de solicitudes que el dispositivo entre 40ms y 1000ms. Por ejemplo, si usted solicita un intervalo de 3 segundos, (3000ms), la API solicita datos desde el dispositivo cada 1 segundo, pero sólo ejecuta el callback de éxito cada 3 segundos.
131 |
132 | ## navigator.accelerometer.clearWatch
133 |
134 | Dejar de mirar el `Acceleration` referenciado por el `watchID` parámetro.
135 |
136 | navigator.accelerometer.clearWatch(watchID);
137 |
138 |
139 | * **watchID**: el identificador devuelto por`navigator.accelerometer.watchAcceleration`.
140 |
141 | ### Ejemplo
142 |
143 | var watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);
144 |
145 | // ... later on ...
146 |
147 | navigator.accelerometer.clearWatch(watchID);
148 |
149 |
150 | ## Acceleration
151 |
152 | Contiene `Accelerometer` datos capturados en un punto específico en el tiempo. Valores de aceleración incluyen el efecto de la gravedad (9,81 m/s ^ 2), de modo que cuando se encuentra un dispositivo plano y hacia arriba, *x*, *y*, y *z* valores devueltos deben ser `` , `` , y`9.81`.
153 |
154 | ### Propiedades
155 |
156 | * **x**: Cantidad de aceleración en el eje X. (en m/s^2) *(Number)*
157 | * **y**: Cantidad de aceleración en el eje Y. (en m/s^2) *(Number)*
158 | * **z**: Cantidad de aceleración en el eje Z. (en m/s^2) *(Number)*
159 | * **timestamp**: Momento de la captura en milisegundos.*(DOMTimeStamp)*
--------------------------------------------------------------------------------
/plugins/cordova-plugin-device-motion/doc/de/index.md:
--------------------------------------------------------------------------------
1 |
19 |
20 | # cordova-plugin-device-motion
21 |
22 | Dieses Plugin ermöglicht den Zugriff auf das Gerät Beschleunigungsmesser. Der Beschleunigungsmesser ist ein Bewegungssensor, der die Änderung (*Delta*) erkennt Bewegung im Verhältnis zu der aktuellen Geräte-Orientierung, in drei Dimensionen entlang der *x-*, *y-*und *Z* -Achse.
23 |
24 | Der Zugang ist über eine globale `navigator.accelerometer`-Objekt.
25 |
26 | Obwohl das Objekt mit der globalen Gültigkeitsbereich `navigator` verbunden ist, steht es nicht bis nach dem `Deviceready`-Ereignis.
27 |
28 | document.addEventListener("deviceready", onDeviceReady, false);
29 | function onDeviceReady() {
30 | console.log(navigator.accelerometer);
31 | }
32 |
33 |
34 | ## Installation
35 |
36 | cordova plugin add cordova-plugin-device-motion
37 |
38 |
39 | ## Unterstützte Plattformen
40 |
41 | * Amazon Fire OS
42 | * Android
43 | * BlackBerry 10
44 | * Browser
45 | * Firefox OS
46 | * iOS
47 | * Tizen
48 | * Windows Phone 8
49 | * Windows
50 |
51 | ## Methoden
52 |
53 | * navigator.accelerometer.getCurrentAcceleration
54 | * navigator.accelerometer.watchAcceleration
55 | * navigator.accelerometer.clearWatch
56 |
57 | ## Objekte
58 |
59 | * Beschleunigung
60 |
61 | ## navigator.accelerometer.getCurrentAcceleration
62 |
63 | Erhalten Sie die aktuelle Beschleunigung entlang der *x-*, *y-* und *z*-Achsen.
64 |
65 | Diese Beschleunigungswerte werden an die `accelerometerSuccess`-Callback-Funktion zurückgegeben.
66 |
67 | navigator.accelerometer.getCurrentAcceleration(accelerometerSuccess, accelerometerError);
68 |
69 |
70 | ### Beispiel
71 |
72 | function onSuccess(acceleration) {
73 | alert('Acceleration X: ' + acceleration.x + '\n' +
74 | 'Acceleration Y: ' + acceleration.y + '\n' +
75 | 'Acceleration Z: ' + acceleration.z + '\n' +
76 | 'Timestamp: ' + acceleration.timestamp + '\n');
77 | };
78 |
79 | function onError() {
80 | alert('onError!');
81 | };
82 |
83 | navigator.accelerometer.getCurrentAcceleration(onSuccess, onError);
84 |
85 |
86 | ### Browser-Eigenheiten
87 |
88 | Werte für X, Y, Z-Bewegung sind alle zufällig generierten in Ordnung, den Beschleunigungsmesser zu simulieren.
89 |
90 | ### iOS Macken
91 |
92 | * iOS erkennt nicht das Konzept die aktuelle Beschleunigung zu einem bestimmten Zeitpunkt zu bekommen.
93 |
94 | * Müssen Sie die Beschleunigung zu sehen und erfassen die Daten zu bestimmten Zeitintervallen.
95 |
96 | * So die `getCurrentAcceleration` -Funktion führt zu den letzten Wert berichtet von einer `watchAccelerometer` rufen.
97 |
98 | ## navigator.accelerometer.watchAcceleration
99 |
100 | Ruft das Gerät aktuelle `Accelerometer` in regelmäßigen Abständen, die `accelerometerSuccess`-Callback-Funktion jedes Mal ausgeführt. Gibt das Intervall in Millisekunden über das `AcceleratorOptions`-Objekt-`frequency`-Parameter.
101 |
102 | Die zurückgegebenen Watch-ID verweist der Beschleunigungsmesser Uhr Intervall und kann mit `navigator.accelerometer.clearWatch` um zu stoppen, beobachten den Beschleunigungsmesser verwendet werden.
103 |
104 | var watchID = navigator.accelerometer.watchAcceleration(accelerometerSuccess,
105 | accelerometerError,
106 | accelerometerOptions);
107 |
108 |
109 | * **accelerometerOptions**: Ein Objekt mit den folgenden optionalen Elementen:
110 | * **Zeitraum**: gewünschten Zeitraum der Aufrufe von AccelerometerSuccess mit Beschleunigungsdaten in Millisekunden. *(Anzahl)* (Default: 10000)
111 |
112 | ### Beispiel
113 |
114 | function onSuccess(acceleration) {
115 | alert('Acceleration X: ' + acceleration.x + '\n' +
116 | 'Acceleration Y: ' + acceleration.y + '\n' +
117 | 'Acceleration Z: ' + acceleration.z + '\n' +
118 | 'Timestamp: ' + acceleration.timestamp + '\n');
119 | };
120 |
121 | function onError() {
122 | alert('onError!');
123 | };
124 |
125 | var options = { frequency: 3000 }; // Update every 3 seconds
126 |
127 | var watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);
128 |
129 |
130 | ### iOS Macken
131 |
132 | Die API ruft die Erfolg-Callback-Funktion im Intervall angefordert, aber schränkt den Bereich der Anforderungen an das Gerät zwischen 40ms und 1000ms. Beispielsweise wenn Sie ein Intervall von 3 Sekunden, (3000ms), beantragen die API fordert Daten vom Gerät jede 1 Sekunde, aber nur den Erfolg-Rückruf führt alle 3 Sekunden.
133 |
134 | ## navigator.accelerometer.clearWatch
135 |
136 | Hör auf, beobachten die `Beschleunigung` durch den `watchID`-Parameter verwiesen.
137 |
138 | navigator.accelerometer.clearWatch(watchID);
139 |
140 |
141 | * **WatchID**: die ID von zurückgegeben`navigator.accelerometer.watchAcceleration`.
142 |
143 | ### Beispiel
144 |
145 | var watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);
146 |
147 | // ... later on ...
148 |
149 | navigator.accelerometer.clearWatch(watchID);
150 |
151 |
152 | ## Beschleunigung
153 |
154 | Zu einem bestimmten Zeitpunkt im Zeit erfasste `Accelerometer`-Daten enthält. Beschleunigungswerte sind die Auswirkungen der Schwerkraft (9.81 m/s ^ 2), so dass wenn ein Gerät flach und nach oben, *X*, *y liegt*, und *Z*-Werte zurückgegeben werden, ``, `` und `9.81 sollte`.
155 |
156 | ### Eigenschaften
157 |
158 | * **X**: Betrag der Beschleunigung auf der x-Achse. (in m/s ^ 2) *(Anzahl)*
159 | * **y**: Betrag der Beschleunigung auf der y-Achse. (in m/s ^ 2) *(Anzahl)*
160 | * **Z**: Betrag der Beschleunigung auf die z-Achse. (in m/s ^ 2) *(Anzahl)*
161 | * **Timestamp**: Zeitstempel der Erstellung in Millisekunden. *(DOMTimeStamp)*
162 |
--------------------------------------------------------------------------------
/plugins/cordova-plugin-device-motion/doc/it/README.md:
--------------------------------------------------------------------------------
1 |
19 |
20 | # cordova-plugin-device-motion
21 |
22 | [](https://travis-ci.org/apache/cordova-plugin-device-motion)
23 |
24 | Questo plugin consente di accedere all'accelerometro del dispositivo. L'accelerometro è un sensore di movimento che rileva il cambiamento (*delta*) nel movimento relativo l'orientamento corrente del dispositivo, in tre dimensioni lungo l'asse *x*, *y*e *z* .
25 |
26 | L'accesso avviene tramite un oggetto globale `navigator.accelerometer`.
27 |
28 | Anche se l'oggetto è associato con ambito globale del `navigator`, non è disponibile fino a dopo l'evento `deviceready`.
29 |
30 | document.addEventListener("deviceready", onDeviceReady, false);
31 | function onDeviceReady() {
32 | console.log(navigator.accelerometer);
33 | }
34 |
35 |
36 | ## Installazione
37 |
38 | cordova plugin add cordova-plugin-device-motion
39 |
40 |
41 | ## Piattaforme supportate
42 |
43 | * Amazon fuoco OS
44 | * Android
45 | * BlackBerry 10
46 | * Browser
47 | * Firefox OS
48 | * iOS
49 | * Tizen
50 | * Windows Phone 8
51 | * Windows
52 |
53 | ## Metodi
54 |
55 | * navigator.accelerometer.getCurrentAcceleration
56 | * navigator.accelerometer.watchAcceleration
57 | * navigator.accelerometer.clearWatch
58 |
59 | ## Oggetti
60 |
61 | * Accelerazione
62 |
63 | ## navigator.accelerometer.getCurrentAcceleration
64 |
65 | Ottenere l'attuale accelerazione lungo gli assi *x*, *y* e *z*.
66 |
67 | I valori di accelerazione vengono restituiti alla funzione di callback `accelerometerSuccess`.
68 |
69 | navigator.accelerometer.getCurrentAcceleration(accelerometerSuccess, accelerometerError);
70 |
71 |
72 | ### Esempio
73 |
74 | function onSuccess(acceleration) {
75 | alert('Acceleration X: ' + acceleration.x + '\n' +
76 | 'Acceleration Y: ' + acceleration.y + '\n' +
77 | 'Acceleration Z: ' + acceleration.z + '\n' +
78 | 'Timestamp: ' + acceleration.timestamp + '\n');
79 | };
80 |
81 | function onError() {
82 | alert('onError!');
83 | };
84 |
85 | navigator.accelerometer.getCurrentAcceleration(onSuccess, onError);
86 |
87 |
88 | ### Stranezze browser
89 |
90 | I valori per X, Y, movimento Z sono tutti generati casualmente in ordine per simulare l'accelerometro.
91 |
92 | ### iOS stranezze
93 |
94 | * iOS non riconosce il concetto di ottenere l'accelerazione della corrente in un dato punto.
95 |
96 | * Si deve guardare l'accelerazione e acquisire i dati di intervalli di tempo dato.
97 |
98 | * Così, il `getCurrentAcceleration` funzione restituisce l'ultimo valore segnalato da un `watchAccelerometer` chiamare.
99 |
100 | ## navigator.accelerometer.watchAcceleration
101 |
102 | Recupera corrente del dispositivo `Acceleration` a intervalli regolari, l'esecuzione della funzione di callback `accelerometerSuccess` ogni volta. Specificare l'intervallo in millisecondi tramite parametro `frequency` dell'oggetto `acceleratorOptions`.
103 |
104 | L'orologio restituito ID fa riferimento intervallo orologio di accelerometro e può essere utilizzato con `navigator.accelerometer.clearWatch` a smettere di guardare l'accelerometro.
105 |
106 | var watchID = navigator.accelerometer.watchAcceleration(accelerometerSuccess,
107 | accelerometerError,
108 | accelerometerOptions);
109 |
110 |
111 | * **accelerometerOptions**: Un oggetto con le seguenti chiavi opzionali:
112 | * **periodo**: periodo richiesto di chiamate a accelerometerSuccess con i dati di accelerazione in millisecondi. *(Numero)* (Default: 10000)
113 |
114 | ### Esempio
115 |
116 | function onSuccess(acceleration) {
117 | alert('Acceleration X: ' + acceleration.x + '\n' +
118 | 'Acceleration Y: ' + acceleration.y + '\n' +
119 | 'Acceleration Z: ' + acceleration.z + '\n' +
120 | 'Timestamp: ' + acceleration.timestamp + '\n');
121 | };
122 |
123 | function onError() {
124 | alert('onError!');
125 | };
126 |
127 | var options = { frequency: 3000 }; // Update every 3 seconds
128 |
129 | var watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);
130 |
131 |
132 | ### iOS stranezze
133 |
134 | L'API chiama la funzione di callback di successo nell'intervallo richiesto, ma limita la gamma di richieste alla periferica tra 40ms e 1000ms. Ad esempio, se si richiede un intervallo di 3 secondi, (3000ms), l'API richiede i dati dal dispositivo ogni secondo, ma esegue solo il callback di successo ogni 3 secondi.
135 |
136 | ## navigator.accelerometer.clearWatch
137 |
138 | Smettere di guardare l' `Acceleration` a cui fa riferimento il parametro `watchID`.
139 |
140 | navigator.accelerometer.clearWatch(watchID);
141 |
142 |
143 | * **watchID**: l'ID restituito da`navigator.accelerometer.watchAcceleration`.
144 |
145 | ### Esempio
146 |
147 | var watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);
148 |
149 | // ... later on ...
150 |
151 | navigator.accelerometer.clearWatch(watchID);
152 |
153 |
154 | ## Accelerazione
155 |
156 | Contiene i dati dell'`Accelerometer` catturati in un punto specifico nel tempo. I valori di accelerazione includono l'effetto della gravità (9,81 m/s ^ 2), in modo che quando un dispositivo si trova piatta e rivolto in su, *x*, *y*, e *z* valori restituiti dovrebbero essere ``, `` e `9,81`.
157 |
158 | ### Proprietà
159 |
160 | * **x**: quantità di accelerazione sull'asse x. (in m/s ^ 2) *(Numero)*
161 | * **y**: quantità di accelerazione sull'asse y. (in m/s ^ 2) *(Numero)*
162 | * **z**: quantità di accelerazione sull'asse z. (in m/s ^ 2) *(Numero)*
163 | * **timestamp**: creazione timestamp in millisecondi. *(DOMTimeStamp)*
--------------------------------------------------------------------------------
/plugins/cordova-plugin-device-motion/src/wp/Accelerometer.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed under the Apache License, Version 2.0 (the "License");
3 | you may not use this file except in compliance with the License.
4 | You may obtain a copy of the License at
5 |
6 | http://www.apache.org/licenses/LICENSE-2.0
7 |
8 | Unless required by applicable law or agreed to in writing, software
9 | distributed under the License is distributed on an "AS IS" BASIS,
10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | See the License for the specific language governing permissions and
12 | limitations under the License.
13 | */
14 |
15 |
16 | using System;
17 | using System.Collections.Generic;
18 | using System.Runtime.Serialization;
19 | using System.Threading;
20 | using Microsoft.Devices.Sensors;
21 | using System.Globalization;
22 | using System.Diagnostics;
23 | using System.Windows.Threading;
24 |
25 | namespace WPCordovaClassLib.Cordova.Commands
26 | {
27 | ///
28 | /// Captures device motion in the x, y, and z direction.
29 | ///
30 | public class Accelerometer : BaseCommand
31 | {
32 | #region Status codes and Constants
33 |
34 | public const int Stopped = 0;
35 | public const int Starting = 1;
36 | public const int Running = 2;
37 | public const int ErrorFailedToStart = 3;
38 |
39 | public const double gConstant = -9.81;
40 |
41 | #endregion
42 |
43 | #region Static members
44 |
45 | ///
46 | /// Status of listener
47 | ///
48 | private static int currentStatus;
49 |
50 | ///
51 | /// Accelerometer
52 | ///
53 | private static readonly Windows.Devices.Sensors.Accelerometer accelerometer = Windows.Devices.Sensors.Accelerometer.GetDefault();
54 |
55 | ///
56 | /// Timer which is used to update
57 | ///
58 | private static Timer updateTimer;
59 |
60 | ///
61 | /// Callback Id to report acceleration result in watch mode
62 | ///
63 | private static string watchCallbackId;
64 |
65 | #endregion
66 |
67 | ///
68 | /// Starts listening for acceleration sensor
69 | ///
70 | /// status of listener
71 | public void start(string options)
72 | {
73 | watchCallbackId = GetCallbackIdFromOptions(options);
74 |
75 | if (currentStatus == Running)
76 | {
77 | return;
78 | }
79 |
80 | try
81 | {
82 | // we use 20ms as a minimum allowed update interval
83 | int minReportInterval = Math.Max((int)accelerometer.MinimumReportInterval, 20);
84 |
85 | updateTimer = new Timer(ReportAccelerationValue, null, 0, minReportInterval);
86 | this.SetStatus(Running);
87 |
88 | PluginResult result = new PluginResult(PluginResult.Status.OK, GetCurrentAccelerationFormatted());
89 | result.KeepCallback = true;
90 | DispatchCommandResult(result, watchCallbackId);
91 | }
92 | catch (Exception ex)
93 | {
94 | this.SetStatus(ErrorFailedToStart);
95 | DispatchCommandResult(new PluginResult(PluginResult.Status.IO_EXCEPTION, ErrorFailedToStart), watchCallbackId);
96 | }
97 | }
98 |
99 | public void stop(string options)
100 | {
101 | string callbackId = GetCallbackIdFromOptions(options);
102 |
103 | if (currentStatus == Running)
104 | {
105 | watchCallbackId = null;
106 | updateTimer.Dispose();
107 | this.SetStatus(Stopped);
108 | }
109 |
110 | DispatchCommandResult(new PluginResult(PluginResult.Status.OK), callbackId);
111 | }
112 |
113 | public void getCurrentAcceleration(string options)
114 | {
115 | string callbackId = GetCallbackIdFromOptions(options);
116 |
117 | DispatchCommandResult(new PluginResult(PluginResult.Status.OK, GetCurrentAccelerationFormatted()), callbackId);
118 | }
119 |
120 | private void ReportAccelerationValue(object stateInfo)
121 | {
122 | if (String.IsNullOrEmpty(watchCallbackId)) {
123 | // soemthing goes wrong, callback has been called after stop..
124 | return;
125 | }
126 | string currentAccelerationFormatted = GetCurrentAccelerationFormatted();
127 | var result = currentAccelerationFormatted == null ? new PluginResult(PluginResult.Status.NO_RESULT)
128 | : new PluginResult(PluginResult.Status.OK, currentAccelerationFormatted);
129 | result.KeepCallback = true;
130 | DispatchCommandResult(result, watchCallbackId);
131 | }
132 |
133 | ///
134 | /// Formats current coordinates into JSON format
135 | ///
136 | /// Coordinates in JSON format
137 | private string GetCurrentAccelerationFormatted()
138 | {
139 | try
140 | {
141 | var currentReading = accelerometer.GetCurrentReading();
142 | var currentCoordinates = String.Format("\"x\":{0},\"y\":{1},\"z\":{2}",
143 | (currentReading.AccelerationX * gConstant).ToString("0.00000", CultureInfo.InvariantCulture),
144 | (currentReading.AccelerationY * gConstant).ToString("0.00000", CultureInfo.InvariantCulture),
145 | (currentReading.AccelerationZ * gConstant).ToString("0.00000", CultureInfo.InvariantCulture));
146 |
147 | return "{" + currentCoordinates + "}";
148 | }
149 | catch
150 | {
151 | return null;
152 | }
153 | }
154 |
155 | ///
156 | /// Sets current status
157 | ///
158 | /// current status
159 | private void SetStatus(int status)
160 | {
161 | currentStatus = status;
162 | }
163 |
164 | private string GetCallbackIdFromOptions(string options)
165 | {
166 | try
167 | {
168 | string[] optionsString = JSON.JsonHelper.Deserialize(options);
169 |
170 | return optionsString[0];
171 | }
172 | catch (Exception)
173 | {
174 | DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION), this.CurrentCommandCallbackId);
175 | return null;
176 | }
177 | }
178 | }
179 | }
180 |
--------------------------------------------------------------------------------
/plugins/cordova-plugin-device-motion/doc/de/README.md:
--------------------------------------------------------------------------------
1 |
19 |
20 | # cordova-plugin-device-motion
21 |
22 | [](https://travis-ci.org/apache/cordova-plugin-device-motion)
23 |
24 | Dieses Plugin ermöglicht den Zugriff auf das Gerät Beschleunigungsmesser. Der Beschleunigungsmesser ist ein Bewegungssensor, der die Änderung (*Delta*) erkennt Bewegung im Verhältnis zu der aktuellen Geräte-Orientierung, in drei Dimensionen entlang der *x-*, *y-*und *Z* -Achse.
25 |
26 | Der Zugang ist über eine globale `navigator.accelerometer`-Objekt.
27 |
28 | Obwohl das Objekt mit der globalen Gültigkeitsbereich `navigator` verbunden ist, steht es nicht bis nach dem `Deviceready`-Ereignis.
29 |
30 | document.addEventListener("deviceready", onDeviceReady, false);
31 | function onDeviceReady() {
32 | console.log(navigator.accelerometer);
33 | }
34 |
35 |
36 | ## Installation
37 |
38 | cordova plugin add cordova-plugin-device-motion
39 |
40 |
41 | ## Unterstützte Plattformen
42 |
43 | * Amazon Fire OS
44 | * Android
45 | * BlackBerry 10
46 | * Browser
47 | * Firefox OS
48 | * iOS
49 | * Tizen
50 | * Windows Phone 8
51 | * Windows
52 |
53 | ## Methoden
54 |
55 | * navigator.accelerometer.getCurrentAcceleration
56 | * navigator.accelerometer.watchAcceleration
57 | * navigator.accelerometer.clearWatch
58 |
59 | ## Objekte
60 |
61 | * Beschleunigung
62 |
63 | ## navigator.accelerometer.getCurrentAcceleration
64 |
65 | Erhalten Sie die aktuelle Beschleunigung entlang der *x-*, *y-* und *z*-Achsen.
66 |
67 | Diese Beschleunigungswerte werden an die `accelerometerSuccess`-Callback-Funktion zurückgegeben.
68 |
69 | navigator.accelerometer.getCurrentAcceleration(accelerometerSuccess, accelerometerError);
70 |
71 |
72 | ### Beispiel
73 |
74 | function onSuccess(acceleration) {
75 | alert('Acceleration X: ' + acceleration.x + '\n' +
76 | 'Acceleration Y: ' + acceleration.y + '\n' +
77 | 'Acceleration Z: ' + acceleration.z + '\n' +
78 | 'Timestamp: ' + acceleration.timestamp + '\n');
79 | };
80 |
81 | function onError() {
82 | alert('onError!');
83 | };
84 |
85 | navigator.accelerometer.getCurrentAcceleration(onSuccess, onError);
86 |
87 |
88 | ### Browser-Eigenheiten
89 |
90 | Werte für X, Y, Z-Bewegung sind alle zufällig generierten in Ordnung, den Beschleunigungsmesser zu simulieren.
91 |
92 | ### iOS Macken
93 |
94 | * iOS erkennt nicht das Konzept die aktuelle Beschleunigung zu einem bestimmten Zeitpunkt zu bekommen.
95 |
96 | * Müssen Sie die Beschleunigung zu sehen und erfassen die Daten zu bestimmten Zeitintervallen.
97 |
98 | * So die `getCurrentAcceleration` -Funktion führt zu den letzten Wert berichtet von einer `watchAccelerometer` rufen.
99 |
100 | ## navigator.accelerometer.watchAcceleration
101 |
102 | Ruft das Gerät aktuelle `Accelerometer` in regelmäßigen Abständen, die `accelerometerSuccess`-Callback-Funktion jedes Mal ausgeführt. Gibt das Intervall in Millisekunden über das `AcceleratorOptions`-Objekt-`frequency`-Parameter.
103 |
104 | Die zurückgegebenen Watch-ID verweist der Beschleunigungsmesser Uhr Intervall und kann mit `navigator.accelerometer.clearWatch` um zu stoppen, beobachten den Beschleunigungsmesser verwendet werden.
105 |
106 | var watchID = navigator.accelerometer.watchAcceleration(accelerometerSuccess,
107 | accelerometerError,
108 | accelerometerOptions);
109 |
110 |
111 | * **accelerometerOptions**: Ein Objekt mit den folgenden optionalen Elementen:
112 | * **Zeitraum**: gewünschten Zeitraum der Aufrufe von AccelerometerSuccess mit Beschleunigungsdaten in Millisekunden. *(Anzahl)* (Default: 10000)
113 |
114 | ### Beispiel
115 |
116 | function onSuccess(acceleration) {
117 | alert('Acceleration X: ' + acceleration.x + '\n' +
118 | 'Acceleration Y: ' + acceleration.y + '\n' +
119 | 'Acceleration Z: ' + acceleration.z + '\n' +
120 | 'Timestamp: ' + acceleration.timestamp + '\n');
121 | };
122 |
123 | function onError() {
124 | alert('onError!');
125 | };
126 |
127 | var options = { frequency: 3000 }; // Update every 3 seconds
128 |
129 | var watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);
130 |
131 |
132 | ### iOS Macken
133 |
134 | Die API ruft die Erfolg-Callback-Funktion im Intervall angefordert, aber schränkt den Bereich der Anforderungen an das Gerät zwischen 40ms und 1000ms. Beispielsweise wenn Sie ein Intervall von 3 Sekunden, (3000ms), beantragen die API fordert Daten vom Gerät jede 1 Sekunde, aber nur den Erfolg-Rückruf führt alle 3 Sekunden.
135 |
136 | ## navigator.accelerometer.clearWatch
137 |
138 | Hör auf, beobachten die `Beschleunigung` durch den `watchID`-Parameter verwiesen.
139 |
140 | navigator.accelerometer.clearWatch(watchID);
141 |
142 |
143 | * **WatchID**: die ID von zurückgegeben`navigator.accelerometer.watchAcceleration`.
144 |
145 | ### Beispiel
146 |
147 | var watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);
148 |
149 | // ... later on ...
150 |
151 | navigator.accelerometer.clearWatch(watchID);
152 |
153 |
154 | ## Beschleunigung
155 |
156 | Zu einem bestimmten Zeitpunkt im Zeit erfasste `Accelerometer`-Daten enthält. Beschleunigungswerte sind die Auswirkungen der Schwerkraft (9.81 m/s ^ 2), so dass wenn ein Gerät flach und nach oben, *X*, *y liegt*, und *Z*-Werte zurückgegeben werden, ``, `` und `9.81 sollte`.
157 |
158 | ### Eigenschaften
159 |
160 | * **X**: Betrag der Beschleunigung auf der x-Achse. (in m/s ^ 2) *(Anzahl)*
161 | * **y**: Betrag der Beschleunigung auf der y-Achse. (in m/s ^ 2) *(Anzahl)*
162 | * **Z**: Betrag der Beschleunigung auf die z-Achse. (in m/s ^ 2) *(Anzahl)*
163 | * **Timestamp**: Zeitstempel der Erstellung in Millisekunden. *(DOMTimeStamp)*
--------------------------------------------------------------------------------
/plugins/cordova-plugin-device-motion/www/accelerometer.js:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Licensed to the Apache Software Foundation (ASF) under one
4 | * or more contributor license agreements. See the NOTICE file
5 | * distributed with this work for additional information
6 | * regarding copyright ownership. The ASF licenses this file
7 | * to you under the Apache License, Version 2.0 (the
8 | * "License"); you may not use this file except in compliance
9 | * with the License. You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing,
14 | * software distributed under the License is distributed on an
15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | * KIND, either express or implied. See the License for the
17 | * specific language governing permissions and limitations
18 | * under the License.
19 | *
20 | */
21 |
22 | /**
23 | * This class provides access to device accelerometer data.
24 | * @constructor
25 | */
26 | var argscheck = require('cordova/argscheck'),
27 | utils = require("cordova/utils"),
28 | exec = require("cordova/exec"),
29 | Acceleration = require('./Acceleration');
30 |
31 | // Is the accel sensor running?
32 | var running = false;
33 |
34 | // Keeps reference to watchAcceleration calls.
35 | var timers = {};
36 |
37 | // Array of listeners; used to keep track of when we should call start and stop.
38 | var listeners = [];
39 |
40 | // Last returned acceleration object from native
41 | var accel = null;
42 |
43 | // Timer used when faking up devicemotion events
44 | var eventTimerId = null;
45 |
46 | // Tells native to start.
47 | function start() {
48 | exec(function (a) {
49 | var tempListeners = listeners.slice(0);
50 | accel = new Acceleration(a.x, a.y, a.z, a.timestamp);
51 | for (var i = 0, l = tempListeners.length; i < l; i++) {
52 | tempListeners[i].win(accel);
53 | }
54 | }, function (e) {
55 | var tempListeners = listeners.slice(0);
56 | for (var i = 0, l = tempListeners.length; i < l; i++) {
57 | tempListeners[i].fail(e);
58 | }
59 | }, "Accelerometer", "start", []);
60 | running = true;
61 | }
62 |
63 | // Tells native to stop.
64 | function stop() {
65 | exec(null, null, "Accelerometer", "stop", []);
66 | accel = null;
67 | running = false;
68 | }
69 |
70 | // Adds a callback pair to the listeners array
71 | function createCallbackPair(win, fail) {
72 | return { win: win, fail: fail };
73 | }
74 |
75 | // Removes a win/fail listener pair from the listeners array
76 | function removeListeners(l) {
77 | var idx = listeners.indexOf(l);
78 | if (idx > -1) {
79 | listeners.splice(idx, 1);
80 | if (listeners.length === 0) {
81 | stop();
82 | }
83 | }
84 | }
85 |
86 | var accelerometer = {
87 | /**
88 | * Asynchronously acquires the current acceleration.
89 | *
90 | * @param {Function} successCallback The function to call when the acceleration data is available
91 | * @param {Function} errorCallback The function to call when there is an error getting the acceleration data. (OPTIONAL)
92 | * @param {AccelerationOptions} options The options for getting the accelerometer data such as timeout. (OPTIONAL)
93 | */
94 | getCurrentAcceleration: function (successCallback, errorCallback, options) {
95 | argscheck.checkArgs('fFO', 'accelerometer.getCurrentAcceleration', arguments);
96 |
97 | if (cordova.platformId === "windowsphone") {
98 | exec(function (a) {
99 | accel = new Acceleration(a.x, a.y, a.z, a.timestamp);
100 | successCallback(accel);
101 | }, function (e) {
102 | errorCallback(e);
103 | }, "Accelerometer", "getCurrentAcceleration", []);
104 |
105 | return;
106 | }
107 |
108 | var p;
109 | var win = function (a) {
110 | removeListeners(p);
111 | successCallback(a);
112 | };
113 | var fail = function (e) {
114 | removeListeners(p);
115 | if (errorCallback) {
116 | errorCallback(e);
117 | }
118 | };
119 |
120 | p = createCallbackPair(win, fail);
121 | listeners.push(p);
122 |
123 | if (!running) {
124 | start();
125 | }
126 | },
127 |
128 | /**
129 | * Asynchronously acquires the acceleration repeatedly at a given interval.
130 | *
131 | * @param {Function} successCallback The function to call each time the acceleration data is available
132 | * @param {Function} errorCallback The function to call when there is an error getting the acceleration data. (OPTIONAL)
133 | * @param {AccelerationOptions} options The options for getting the accelerometer data such as timeout. (OPTIONAL)
134 | * @return String The watch id that must be passed to #clearWatch to stop watching.
135 | */
136 | watchAcceleration: function (successCallback, errorCallback, options) {
137 | argscheck.checkArgs('fFO', 'accelerometer.watchAcceleration', arguments);
138 | // Default interval (10 sec)
139 | var frequency = (options && options.frequency && typeof options.frequency == 'number') ? options.frequency : 10000;
140 |
141 | // Keep reference to watch id, and report accel readings as often as defined in frequency
142 | var id = utils.createUUID();
143 |
144 | var p = createCallbackPair(function () { }, function (e) {
145 | removeListeners(p);
146 | if (errorCallback) {
147 | errorCallback(e);
148 | }
149 | });
150 | listeners.push(p);
151 |
152 | timers[id] = {
153 | timer: window.setInterval(function () {
154 | if (accel) {
155 | successCallback(accel);
156 | }
157 | }, frequency),
158 | listeners: p
159 | };
160 |
161 | if (running) {
162 | // If we're already running then immediately invoke the success callback
163 | // but only if we have retrieved a value, sample code does not check for null ...
164 | if (accel) {
165 | successCallback(accel);
166 | }
167 | } else {
168 | start();
169 | }
170 |
171 | if (cordova.platformId === "browser" && !eventTimerId) {
172 | // Start firing devicemotion events if we haven't already
173 | var devicemotionEvent = new Event('devicemotion');
174 | eventTimerId = window.setInterval(function() {
175 | window.dispatchEvent(devicemotionEvent);
176 | }, 200);
177 | }
178 |
179 | return id;
180 | },
181 |
182 | /**
183 | * Clears the specified accelerometer watch.
184 | *
185 | * @param {String} id The id of the watch returned from #watchAcceleration.
186 | */
187 | clearWatch: function (id) {
188 | // Stop javascript timer & remove from timer list
189 | if (id && timers[id]) {
190 | window.clearInterval(timers[id].timer);
191 | removeListeners(timers[id].listeners);
192 | delete timers[id];
193 |
194 | if (eventTimerId && Object.keys(timers).length === 0) {
195 | // No more watchers, so stop firing 'devicemotion' events
196 | window.clearInterval(eventTimerId);
197 | eventTimerId = null;
198 | }
199 | }
200 | }
201 | };
202 | module.exports = accelerometer;
203 |
--------------------------------------------------------------------------------
/plugins/cordova-plugin-device-motion/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Device Motion
3 | description: Access accelerometer data.
4 | ---
5 |
23 |
24 | |Android|iOS| Windows 8.1 Store | Windows 8.1 Phone | Windows 10 Store | Travis CI |
25 | |:-:|:-:|:-:|:-:|:-:|:-:|
26 | |[](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=android,PLUGIN=cordova-plugin-device-motion/)|[](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=ios,PLUGIN=cordova-plugin-device-motion/)|[](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-8.1-store,PLUGIN=cordova-plugin-device-motion/)|[](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-8.1-phone,PLUGIN=cordova-plugin-device-motion/)|[](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-10-store,PLUGIN=cordova-plugin-device-motion/)|[](https://travis-ci.org/apache/cordova-plugin-device-motion)|
27 |
28 | # cordova-plugin-device-motion
29 |
30 | This plugin provides access to the device's accelerometer. The accelerometer is
31 | a motion sensor that detects the change (_delta_) in movement relative to the
32 | current device orientation, in three dimensions along the _x_, _y_, and _z_
33 | axis.
34 |
35 | Access is via a global `navigator.accelerometer` object.
36 |
37 | Although the object is attached to the global scoped `navigator`, it is not available until after the `deviceready` event.
38 |
39 | document.addEventListener("deviceready", onDeviceReady, false);
40 | function onDeviceReady() {
41 | console.log(navigator.accelerometer);
42 | }
43 |
44 | Report issues with this plugin on the [Apache Cordova issue tracker](https://issues.apache.org/jira/issues/?jql=project%20%3D%20CB%20AND%20status%20in%20%28Open%2C%20%22In%20Progress%22%2C%20Reopened%29%20AND%20resolution%20%3D%20Unresolved%20AND%20component%20%3D%20%22Plugin%20Device%20Motion%22%20ORDER%20BY%20priority%20DESC%2C%20summary%20ASC%2C%20updatedDate%20DESC)
45 |
46 | ## Installation
47 |
48 | cordova plugin add cordova-plugin-device-motion
49 |
50 | ## Supported Platforms
51 |
52 | - Amazon Fire OS
53 | - Android
54 | - BlackBerry 10
55 | - Browser
56 | - Firefox OS
57 | - iOS
58 | - Tizen
59 | - Windows Phone 8
60 | - Windows
61 |
62 | ## Methods
63 |
64 | - navigator.accelerometer.getCurrentAcceleration
65 | - navigator.accelerometer.watchAcceleration
66 | - navigator.accelerometer.clearWatch
67 |
68 | ## Objects
69 |
70 | - Acceleration
71 |
72 | ## navigator.accelerometer.getCurrentAcceleration
73 |
74 | Get the current acceleration along the _x_, _y_, and _z_ axes.
75 |
76 | These acceleration values are returned to the `accelerometerSuccess`
77 | callback function.
78 |
79 | navigator.accelerometer.getCurrentAcceleration(accelerometerSuccess, accelerometerError);
80 |
81 |
82 | ### Example
83 |
84 | function onSuccess(acceleration) {
85 | alert('Acceleration X: ' + acceleration.x + '\n' +
86 | 'Acceleration Y: ' + acceleration.y + '\n' +
87 | 'Acceleration Z: ' + acceleration.z + '\n' +
88 | 'Timestamp: ' + acceleration.timestamp + '\n');
89 | }
90 |
91 | function onError() {
92 | alert('onError!');
93 | }
94 |
95 | navigator.accelerometer.getCurrentAcceleration(onSuccess, onError);
96 |
97 | ### Browser Quirks
98 |
99 | Values for X, Y, Z motion are all randomly generated in order to simulate the accelerometer.
100 |
101 | ### Android Quirks
102 |
103 | The accelerometer is called with the `SENSOR_DELAY_UI` flag, which limits the maximum readout frequency to something between 20 and 60 Hz, depending on the device. Values for __period__ corresponding to higher frequencies will result in duplicate samples. More details can be found in the [Android API Guide](http://developer.android.com/guide/topics/sensors/sensors_overview.html#sensors-monitor).
104 |
105 |
106 | ### iOS Quirks
107 |
108 | - iOS doesn't recognize the concept of getting the current acceleration at any given point.
109 |
110 | - You must watch the acceleration and capture the data at given time intervals.
111 |
112 | - Thus, the `getCurrentAcceleration` function yields the last value reported from a `watchAccelerometer` call.
113 |
114 | ## navigator.accelerometer.watchAcceleration
115 |
116 | Retrieves the device's current `Acceleration` at a regular interval, executing
117 | the `accelerometerSuccess` callback function each time. Specify the interval in
118 | milliseconds via the `acceleratorOptions` object's `frequency` parameter.
119 |
120 | The returned watch ID references the accelerometer's watch interval,
121 | and can be used with `navigator.accelerometer.clearWatch` to stop watching the
122 | accelerometer.
123 |
124 | var watchID = navigator.accelerometer.watchAcceleration(accelerometerSuccess,
125 | accelerometerError,
126 | accelerometerOptions);
127 |
128 | - __accelerometerOptions__: An object with the following optional keys:
129 | - __frequency__: requested frequency of calls to accelerometerSuccess with acceleration data in Milliseconds. _(Number)_ (Default: 10000)
130 |
131 |
132 | ### Example
133 |
134 | function onSuccess(acceleration) {
135 | alert('Acceleration X: ' + acceleration.x + '\n' +
136 | 'Acceleration Y: ' + acceleration.y + '\n' +
137 | 'Acceleration Z: ' + acceleration.z + '\n' +
138 | 'Timestamp: ' + acceleration.timestamp + '\n');
139 | }
140 |
141 | function onError() {
142 | alert('onError!');
143 | }
144 |
145 | var options = { frequency: 3000 }; // Update every 3 seconds
146 |
147 | var watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);
148 |
149 | ### iOS Quirks
150 |
151 | The API calls the success callback function at the interval requested,
152 | but restricts the range of requests to the device between 40ms and
153 | 1000ms. For example, if you request an interval of 3 seconds,
154 | (3000ms), the API requests data from the device every 1 second, but
155 | only executes the success callback every 3 seconds.
156 |
157 | ## navigator.accelerometer.clearWatch
158 |
159 | Stop watching the `Acceleration` referenced by the `watchID` parameter.
160 |
161 | navigator.accelerometer.clearWatch(watchID);
162 |
163 | - __watchID__: The ID returned by `navigator.accelerometer.watchAcceleration`.
164 |
165 | ### Example
166 |
167 | var watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);
168 |
169 | // ... later on ...
170 |
171 | navigator.accelerometer.clearWatch(watchID);
172 |
173 | ## Acceleration
174 |
175 | Contains `Accelerometer` data captured at a specific point in time.
176 | Acceleration values include the effect of gravity (9.81 m/s^2), so that when a
177 | device lies flat and facing up, _x_, _y_, and _z_ values returned should be
178 | `0`, `0`, and `9.81`.
179 |
180 | ### Properties
181 |
182 | - __x__: Amount of acceleration on the x-axis. (in m/s^2) _(Number)_
183 | - __y__: Amount of acceleration on the y-axis. (in m/s^2) _(Number)_
184 | - __z__: Amount of acceleration on the z-axis. (in m/s^2) _(Number)_
185 | - __timestamp__: Creation timestamp in milliseconds. _(DOMTimeStamp)_
186 |
--------------------------------------------------------------------------------
/plugins/cordova-plugin-device-motion/RELEASENOTES.md:
--------------------------------------------------------------------------------
1 |
21 | # Release Notes
22 |
23 | ### 1.2.2 (Sep 08, 2016)
24 | * [CB-11795](https://issues.apache.org/jira/browse/CB-11795) Add 'protective' entry to cordovaDependencies
25 | * [CB-11482](https://issues.apache.org/jira/browse/CB-11482) Fix unreliable tests on **Android**
26 | * [CB-11531](https://issues.apache.org/jira/browse/CB-11531) Restart `Accelerometer` on `CyanogenMod 13`
27 | * Add badges for paramedic builds on Jenkins
28 | * Add pull request template.
29 | * [CB-11188](https://issues.apache.org/jira/browse/CB-11188) `cordova-plugin-device-motion-tests` are failing in CI
30 | * [CB-10996](https://issues.apache.org/jira/browse/CB-10996) Adding front matter to README.md
31 |
32 | ### 1.2.1 (Apr 15, 2016)
33 | * [CB-10636](https://issues.apache.org/jira/browse/CB-10636) Add `JSHint` for plugins
34 |
35 | ### 1.2.0 (Nov 18, 2015)
36 | * [CB-10035](https://issues.apache.org/jira/browse/CB-10035) Updated `RELEASENOTES` to be newest to oldest
37 | * access all `accel` properties via getters
38 | * Return error when `accelerometer` not available, skip/pending tests when accel not available, use getters for properties
39 | * Returning an `OK PluginResult.Status` when starting
40 | * Update `README.md`
41 | * Added **Android** quirk
42 | * Fixing contribute link.
43 | * [CB-9426](https://issues.apache.org/jira/browse/CB-9426) Fix exception when using device motion plugin on **browser** platform.
44 | * [CB-9339](https://issues.apache.org/jira/browse/CB-9339) Increase the default sensor accuracy
45 |
46 | ### 1.1.1 (Jun 17, 2015)
47 | * [CB-9128](https://issues.apache.org/jira/browse/CB-9128) cordova-plugin-device-motion documentation translation: cordova-plugin-device-motion
48 | * fix npm md issue
49 | * [CB-8842](https://issues.apache.org/jira/browse/CB-8842) Return cached values on Android if there is no updates from sensor
50 |
51 | ### 1.1.0 (May 06, 2015)
52 | * [CB-8926](https://issues.apache.org/jira/browse/CB-8926): The tests module tries to access an undefined global `Accelerometer` on fail callbacks. This results in another JS error, `ReferenceError: 'Accelerometer' is undefined.` This change passes through the error message instead of attempting to index into it.
53 | * [CB-8876](https://issues.apache.org/jira/browse/CB-8876) Introduced a small timeout between tests
54 | * [CB-8876](https://issues.apache.org/jira/browse/CB-8876) Rewrote **wp8** impementation to be more stable
55 |
56 | ### 1.0.0 (Apr 15, 2015)
57 | * [CB-8746](https://issues.apache.org/jira/browse/CB-8746) gave plugin major version bump
58 | * [CB-8683](https://issues.apache.org/jira/browse/CB-8683) updated windows and tizen specific references of old id to new id
59 | * [CB-8683](https://issues.apache.org/jira/browse/CB-8683) changed plugin-id to pacakge-name
60 | * [CB-8653](https://issues.apache.org/jira/browse/CB-8653) properly updated translated docs to use new id
61 | * [CB-8653](https://issues.apache.org/jira/browse/CB-8653) updated translated docs to use new id
62 | * Use TRAVIS_BUILD_DIR, install paramedic by npm
63 | * [CB-8312](https://issues.apache.org/jira/browse/CB-8312) Multiply accelerometer values by -g on Windows
64 | * [CB-8653](https://issues.apache.org/jira/browse/CB-8653) Updated Readme
65 | * [CB-8562](https://issues.apache.org/jira/browse/CB-8562) Integrate TravisCI
66 | * [CB-8438](https://issues.apache.org/jira/browse/CB-8438) cordova-plugin-device-motion documentation translation: cordova-plugin-device-motion
67 | * [CB-8538](https://issues.apache.org/jira/browse/CB-8538) Added package.json file
68 | * [CB-8096](https://issues.apache.org/jira/browse/CB-8096) Pended recently added spec.12 if accelerometer doesn't exist on the device
69 | * [CB-8096](https://issues.apache.org/jira/browse/CB-8096) Pended auto tests if accelerometer doesn't exist on the device
70 | * [CB-8083](https://issues.apache.org/jira/browse/CB-8083) Adds test to make sure success callback is called each time
71 |
72 | ### 0.2.11 (Dec 02, 2014)
73 | * [CB-8083](https://issues.apache.org/jira/browse/CB-8083) Fix `accelerometer` callback on **Windows**
74 | * Renamed **Windows8** -> **Windows**
75 | * [CB-7977](https://issues.apache.org/jira/browse/CB-7977) Mention `deviceready` in plugin docs
76 | * [CB-7700](https://issues.apache.org/jira/browse/CB-7700) cordova-plugin-device-motion documentation translation: cordova-plugin-device-motion
77 | * [CB-7571](https://issues.apache.org/jira/browse/CB-7571) Bump version of nested plugin to match parent plugin
78 |
79 | ### 0.2.10 (Sep 17, 2014)
80 | * [CB-7471](https://issues.apache.org/jira/browse/CB-7471) cordova-plugin-device-motion documentation translation: cordova-plugin-device-motion
81 | * Updated doc for browser
82 | * Added support for the browser
83 | * [CB-7249](https://issues.apache.org/jira/browse/CB-7249) cordova-plugin-device-motion documentation translation
84 | * [CB-7313](https://issues.apache.org/jira/browse/CB-7313) minor tweak to documentation of watchAcceleration function parameters
85 | * [CB-7160](https://issues.apache.org/jira/browse/CB-7160) move to tests dir, add nested plugin.xml
86 | * Removed js-module for tests from plugin.xml
87 | * [CB-7160](https://issues.apache.org/jira/browse/CB-7160) added manual tests
88 | * added documentation for manual tests
89 | * Removed js-module for tests from plugin.xml
90 | * [CB-7160](https://issues.apache.org/jira/browse/CB-7160) added manual tests
91 | * Changing cdvtest format to use module exports
92 | * register tests using new style
93 | * update
94 | * Feature Branch: First attempt at new-style-tests
95 |
96 | ### 0.2.9 (Aug 06, 2014)
97 | * [FFOS] update accelerometer.js
98 | * [CB-6127](https://issues.apache.org/jira/browse/CB-6127) Updated translations for docs
99 | * FFOS added to supported platforms
100 |
101 | ### 0.2.8 (Jun 05, 2014)
102 | * [CB-6127](https://issues.apache.org/jira/browse/CB-6127) Spanish and French Translations added. Github close #10. Github close #12. Github close #11
103 | * ubuntu: don't destroy callback after use
104 | * [CB-6798](https://issues.apache.org/jira/browse/CB-6798) Add license
105 | * [CB-6491](https://issues.apache.org/jira/browse/CB-6491) add CONTRIBUTING.md
106 | * FFOS added to supported platforms
107 |
108 | ### 0.2.7 (Apr 17, 2014)
109 | * [CB-6422](https://issues.apache.org/jira/browse/CB-6422): [windows8] use cordova/exec/proxy
110 | * [CB-6460](https://issues.apache.org/jira/browse/CB-6460): Update license headers
111 | * [CB-6465](https://issues.apache.org/jira/browse/CB-6465): Add license headers to Tizen code
112 | * Add NOTICE file
113 |
114 | ### 0.2.6 (Feb 05, 2014)
115 | * Add Tizen support
116 |
117 | ### 0.2.5 (Jan 02, 2014)
118 | * [CB-5658](https://issues.apache.org/jira/browse/CB-5658) Add doc/index.md for Device Motion plugin
119 |
120 | ### 0.2.4 (Dec 4, 2013)
121 | * add ubuntu platform
122 | * 1. Added amazon-fireos platform. 2. Change to use amazon-fireos as the platform if the user agent string contains 'cordova-amazon-fireos'
123 |
124 | ### 0.2.3 (Oct 28, 2013)
125 | * tweak scoping
126 | * fixed the scope
127 | * properly stop watching...
128 | * adding timestamp to the response
129 | * fix acceleromter for firefox os
130 | * update firefoxos integration
131 | * fixed callbacks
132 | * accelerometer registers, but is not responding
133 | * fxos added, not working
134 | * [CB-5128](https://issues.apache.org/jira/browse/CB-5128): added repo + issue tag to plugin.xml for device motion
135 | * [CB-5012](https://issues.apache.org/jira/browse/CB-5012) ensure result is returned
136 | * [CB-4825](https://issues.apache.org/jira/browse/CB-4825) Add CoreMotion.framework to plugin.xml
137 | * [CB-4825](https://issues.apache.org/jira/browse/CB-4825) avoid retain cycle in update block
138 | * [CB-4825](https://issues.apache.org/jira/browse/CB-4825) use CoreMotion framework for accelerometer
139 | * [CB-4915](https://issues.apache.org/jira/browse/CB-4915) Incremented plugin version on dev branch.
140 |
141 | ### 0.2.2 (Sept 25, 2013)
142 | * [CB-4889](https://issues.apache.org/jira/browse/CB-4889) bumping&resetting version
143 | * [windows8] commandProxy was moved
144 | * [CB-4889](https://issues.apache.org/jira/browse/CB-4889)
145 | * [CB-4889](https://issues.apache.org/jira/browse/CB-4889) renaming core inside windows8
146 | * [CB-4889](https://issues.apache.org/jira/browse/CB-4889) renaming org.apache.cordova.core.device-motion to org.apache.cordova.device-motion
147 | * Rename CHANGELOG.md -> RELEASENOTES.md
148 | * [CB-4752](https://issues.apache.org/jira/browse/CB-4752) Incremented plugin version on dev branch.
149 |
--------------------------------------------------------------------------------
/plugins/cordova-plugin-device-motion/src/android/AccelListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed to the Apache Software Foundation (ASF) under one
3 | or more contributor license agreements. See the NOTICE file
4 | distributed with this work for additional information
5 | regarding copyright ownership. The ASF licenses this file
6 | to you under the Apache License, Version 2.0 (the
7 | "License"); you may not use this file except in compliance
8 | with the License. You may obtain a copy of the License at
9 |
10 | http://www.apache.org/licenses/LICENSE-2.0
11 |
12 | Unless required by applicable law or agreed to in writing,
13 | software distributed under the License is distributed on an
14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | KIND, either express or implied. See the License for the
16 | specific language governing permissions and limitations
17 | under the License.
18 | */
19 | package org.apache.cordova.devicemotion;
20 |
21 | import java.util.List;
22 |
23 | import org.apache.cordova.CordovaWebView;
24 | import org.apache.cordova.CallbackContext;
25 | import org.apache.cordova.CordovaInterface;
26 | import org.apache.cordova.CordovaPlugin;
27 | import org.apache.cordova.PluginResult;
28 | import org.json.JSONArray;
29 | import org.json.JSONException;
30 | import org.json.JSONObject;
31 |
32 | import android.content.Context;
33 | import android.hardware.Sensor;
34 | import android.hardware.SensorEvent;
35 | import android.hardware.SensorEventListener;
36 | import android.hardware.SensorManager;
37 |
38 | import android.os.Handler;
39 | import android.os.Looper;
40 |
41 | /**
42 | * This class listens to the accelerometer sensor and stores the latest
43 | * acceleration values x,y,z.
44 | */
45 | public class AccelListener extends CordovaPlugin implements SensorEventListener {
46 |
47 | public static int STOPPED = 0;
48 | public static int STARTING = 1;
49 | public static int RUNNING = 2;
50 | public static int ERROR_FAILED_TO_START = 3;
51 |
52 | private float x,y,z; // most recent acceleration values
53 | private long timestamp; // time of most recent value
54 | private int status; // status of listener
55 | private int accuracy = SensorManager.SENSOR_STATUS_ACCURACY_MEDIUM;
56 |
57 | private SensorManager sensorManager; // Sensor manager
58 | private Sensor mSensor; // Acceleration sensor returned by sensor manager
59 |
60 | private CallbackContext callbackContext; // Keeps track of the JS callback context.
61 |
62 | private Handler mainHandler=null;
63 | private Runnable mainRunnable =new Runnable() {
64 | public void run() {
65 | AccelListener.this.timeout();
66 | }
67 | };
68 |
69 | /**
70 | * Create an accelerometer listener.
71 | */
72 | public AccelListener() {
73 | this.x = 0;
74 | this.y = 0;
75 | this.z = 0;
76 | this.timestamp = 0;
77 | this.setStatus(AccelListener.STOPPED);
78 | }
79 |
80 | /**
81 | * Sets the context of the Command. This can then be used to do things like
82 | * get file paths associated with the Activity.
83 | *
84 | * @param cordova The context of the main Activity.
85 | * @param webView The associated CordovaWebView.
86 | */
87 | @Override
88 | public void initialize(CordovaInterface cordova, CordovaWebView webView) {
89 | super.initialize(cordova, webView);
90 | this.sensorManager = (SensorManager) cordova.getActivity().getSystemService(Context.SENSOR_SERVICE);
91 | }
92 |
93 | /**
94 | * Executes the request.
95 | *
96 | * @param action The action to execute.
97 | * @param args The exec() arguments.
98 | * @param callbackId The callback id used when calling back into JavaScript.
99 | * @return Whether the action was valid.
100 | */
101 | public boolean execute(String action, JSONArray args, CallbackContext callbackContext) {
102 | if (action.equals("start")) {
103 | this.callbackContext = callbackContext;
104 | if (this.status != AccelListener.RUNNING) {
105 | // If not running, then this is an async call, so don't worry about waiting
106 | // We drop the callback onto our stack, call start, and let start and the sensor callback fire off the callback down the road
107 | this.start();
108 | }
109 | }
110 | else if (action.equals("stop")) {
111 | if (this.status == AccelListener.RUNNING) {
112 | this.stop();
113 | }
114 | } else {
115 | // Unsupported action
116 | return false;
117 | }
118 |
119 | PluginResult result = new PluginResult(PluginResult.Status.NO_RESULT, "");
120 | result.setKeepCallback(true);
121 | callbackContext.sendPluginResult(result);
122 | return true;
123 | }
124 |
125 | /**
126 | * Called by AccelBroker when listener is to be shut down.
127 | * Stop listener.
128 | */
129 | public void onDestroy() {
130 | this.stop();
131 | }
132 |
133 | //--------------------------------------------------------------------------
134 | // LOCAL METHODS
135 | //--------------------------------------------------------------------------
136 | //
137 | /**
138 | * Start listening for acceleration sensor.
139 | *
140 | * @return status of listener
141 | */
142 | private int start() {
143 | // If already starting or running, then restart timeout and return
144 | if ((this.status == AccelListener.RUNNING) || (this.status == AccelListener.STARTING)) {
145 | startTimeout();
146 | return this.status;
147 | }
148 |
149 | this.setStatus(AccelListener.STARTING);
150 |
151 | // Get accelerometer from sensor manager
152 | List list = this.sensorManager.getSensorList(Sensor.TYPE_ACCELEROMETER);
153 |
154 | // If found, then register as listener
155 | if ((list != null) && (list.size() > 0)) {
156 | this.mSensor = list.get(0);
157 | if (this.sensorManager.registerListener(this, this.mSensor, SensorManager.SENSOR_DELAY_UI)) {
158 | this.setStatus(AccelListener.STARTING);
159 | // CB-11531: Mark accuracy as 'reliable' - this is complementary to
160 | // setting it to 'unreliable' 'stop' method
161 | this.accuracy = SensorManager.SENSOR_STATUS_ACCURACY_MEDIUM;
162 | } else {
163 | this.setStatus(AccelListener.ERROR_FAILED_TO_START);
164 | this.fail(AccelListener.ERROR_FAILED_TO_START, "Device sensor returned an error.");
165 | return this.status;
166 | };
167 |
168 | } else {
169 | this.setStatus(AccelListener.ERROR_FAILED_TO_START);
170 | this.fail(AccelListener.ERROR_FAILED_TO_START, "No sensors found to register accelerometer listening to.");
171 | return this.status;
172 | }
173 |
174 | startTimeout();
175 |
176 | return this.status;
177 | }
178 | private void startTimeout() {
179 | // Set a timeout callback on the main thread.
180 | stopTimeout();
181 | mainHandler = new Handler(Looper.getMainLooper());
182 | mainHandler.postDelayed(mainRunnable, 2000);
183 | }
184 | private void stopTimeout() {
185 | if(mainHandler!=null){
186 | mainHandler.removeCallbacks(mainRunnable);
187 | }
188 | }
189 | /**
190 | * Stop listening to acceleration sensor.
191 | */
192 | private void stop() {
193 | stopTimeout();
194 | if (this.status != AccelListener.STOPPED) {
195 | this.sensorManager.unregisterListener(this);
196 | }
197 | this.setStatus(AccelListener.STOPPED);
198 | this.accuracy = SensorManager.SENSOR_STATUS_UNRELIABLE;
199 | }
200 |
201 | /**
202 | * Returns latest cached position if the sensor hasn't returned newer value.
203 | *
204 | * Called two seconds after starting the listener.
205 | */
206 | private void timeout() {
207 | if (this.status == AccelListener.STARTING &&
208 | this.accuracy >= SensorManager.SENSOR_STATUS_ACCURACY_MEDIUM) {
209 | // call win with latest cached position
210 | // but first check if cached position is reliable
211 | this.timestamp = System.currentTimeMillis();
212 | this.win();
213 | }
214 | }
215 |
216 | /**
217 | * Called when the accuracy of the sensor has changed.
218 | *
219 | * @param sensor
220 | * @param accuracy
221 | */
222 | public void onAccuracyChanged(Sensor sensor, int accuracy) {
223 | // Only look at accelerometer events
224 | if (sensor.getType() != Sensor.TYPE_ACCELEROMETER) {
225 | return;
226 | }
227 |
228 | // If not running, then just return
229 | if (this.status == AccelListener.STOPPED) {
230 | return;
231 | }
232 | this.accuracy = accuracy;
233 | }
234 |
235 | /**
236 | * Sensor listener event.
237 | *
238 | * @param SensorEvent event
239 | */
240 | public void onSensorChanged(SensorEvent event) {
241 | // Only look at accelerometer events
242 | if (event.sensor.getType() != Sensor.TYPE_ACCELEROMETER) {
243 | return;
244 | }
245 |
246 | // If not running, then just return
247 | if (this.status == AccelListener.STOPPED) {
248 | return;
249 | }
250 | this.setStatus(AccelListener.RUNNING);
251 |
252 | if (this.accuracy >= SensorManager.SENSOR_STATUS_ACCURACY_MEDIUM) {
253 |
254 | // Save time that event was received
255 | this.timestamp = System.currentTimeMillis();
256 | this.x = event.values[0];
257 | this.y = event.values[1];
258 | this.z = event.values[2];
259 |
260 | this.win();
261 | }
262 | }
263 |
264 | /**
265 | * Called when the view navigates.
266 | */
267 | @Override
268 | public void onReset() {
269 | if (this.status == AccelListener.RUNNING) {
270 | this.stop();
271 | }
272 | }
273 |
274 | // Sends an error back to JS
275 | private void fail(int code, String message) {
276 | // Error object
277 | JSONObject errorObj = new JSONObject();
278 | try {
279 | errorObj.put("code", code);
280 | errorObj.put("message", message);
281 | } catch (JSONException e) {
282 | e.printStackTrace();
283 | }
284 | PluginResult err = new PluginResult(PluginResult.Status.ERROR, errorObj);
285 | err.setKeepCallback(true);
286 | callbackContext.sendPluginResult(err);
287 | }
288 |
289 | private void win() {
290 | // Success return object
291 | PluginResult result = new PluginResult(PluginResult.Status.OK, this.getAccelerationJSON());
292 | result.setKeepCallback(true);
293 | callbackContext.sendPluginResult(result);
294 | }
295 |
296 | private void setStatus(int status) {
297 | this.status = status;
298 | }
299 | private JSONObject getAccelerationJSON() {
300 | JSONObject r = new JSONObject();
301 | try {
302 | r.put("x", this.x);
303 | r.put("y", this.y);
304 | r.put("z", this.z);
305 | r.put("timestamp", this.timestamp);
306 | } catch (JSONException e) {
307 | e.printStackTrace();
308 | }
309 | return r;
310 | }
311 | }
312 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright 2015 Adobe Systems Incorporated.
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/plugins/cordova-plugin-device-motion/LICENSE:
--------------------------------------------------------------------------------
1 |
2 | Apache License
3 | Version 2.0, January 2004
4 | http://www.apache.org/licenses/
5 |
6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 |
8 | 1. Definitions.
9 |
10 | "License" shall mean the terms and conditions for use, reproduction,
11 | and distribution as defined by Sections 1 through 9 of this document.
12 |
13 | "Licensor" shall mean the copyright owner or entity authorized by
14 | the copyright owner that is granting the License.
15 |
16 | "Legal Entity" shall mean the union of the acting entity and all
17 | other entities that control, are controlled by, or are under common
18 | control with that entity. For the purposes of this definition,
19 | "control" means (i) the power, direct or indirect, to cause the
20 | direction or management of such entity, whether by contract or
21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | outstanding shares, or (iii) beneficial ownership of such entity.
23 |
24 | "You" (or "Your") shall mean an individual or Legal Entity
25 | exercising permissions granted by this License.
26 |
27 | "Source" form shall mean the preferred form for making modifications,
28 | including but not limited to software source code, documentation
29 | source, and configuration files.
30 |
31 | "Object" form shall mean any form resulting from mechanical
32 | transformation or translation of a Source form, including but
33 | not limited to compiled object code, generated documentation,
34 | and conversions to other media types.
35 |
36 | "Work" shall mean the work of authorship, whether in Source or
37 | Object form, made available under the License, as indicated by a
38 | copyright notice that is included in or attached to the work
39 | (an example is provided in the Appendix below).
40 |
41 | "Derivative Works" shall mean any work, whether in Source or Object
42 | form, that is based on (or derived from) the Work and for which the
43 | editorial revisions, annotations, elaborations, or other modifications
44 | represent, as a whole, an original work of authorship. For the purposes
45 | of this License, Derivative Works shall not include works that remain
46 | separable from, or merely link (or bind by name) to the interfaces of,
47 | the Work and Derivative Works thereof.
48 |
49 | "Contribution" shall mean any work of authorship, including
50 | the original version of the Work and any modifications or additions
51 | to that Work or Derivative Works thereof, that is intentionally
52 | submitted to Licensor for inclusion in the Work by the copyright owner
53 | or by an individual or Legal Entity authorized to submit on behalf of
54 | the copyright owner. For the purposes of this definition, "submitted"
55 | means any form of electronic, verbal, or written communication sent
56 | to the Licensor or its representatives, including but not limited to
57 | communication on electronic mailing lists, source code control systems,
58 | and issue tracking systems that are managed by, or on behalf of, the
59 | Licensor for the purpose of discussing and improving the Work, but
60 | excluding communication that is conspicuously marked or otherwise
61 | designated in writing by the copyright owner as "Not a Contribution."
62 |
63 | "Contributor" shall mean Licensor and any individual or Legal Entity
64 | on behalf of whom a Contribution has been received by Licensor and
65 | subsequently incorporated within the Work.
66 |
67 | 2. Grant of Copyright License. Subject to the terms and conditions of
68 | this License, each Contributor hereby grants to You a perpetual,
69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | copyright license to reproduce, prepare Derivative Works of,
71 | publicly display, publicly perform, sublicense, and distribute the
72 | Work and such Derivative Works in Source or Object form.
73 |
74 | 3. Grant of Patent License. Subject to the terms and conditions of
75 | this License, each Contributor hereby grants to You a perpetual,
76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | (except as stated in this section) patent license to make, have made,
78 | use, offer to sell, sell, import, and otherwise transfer the Work,
79 | where such license applies only to those patent claims licensable
80 | by such Contributor that are necessarily infringed by their
81 | Contribution(s) alone or by combination of their Contribution(s)
82 | with the Work to which such Contribution(s) was submitted. If You
83 | institute patent litigation against any entity (including a
84 | cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | or a Contribution incorporated within the Work constitutes direct
86 | or contributory patent infringement, then any patent licenses
87 | granted to You under this License for that Work shall terminate
88 | as of the date such litigation is filed.
89 |
90 | 4. Redistribution. You may reproduce and distribute copies of the
91 | Work or Derivative Works thereof in any medium, with or without
92 | modifications, and in Source or Object form, provided that You
93 | meet the following conditions:
94 |
95 | (a) You must give any other recipients of the Work or
96 | Derivative Works a copy of this License; and
97 |
98 | (b) You must cause any modified files to carry prominent notices
99 | stating that You changed the files; and
100 |
101 | (c) You must retain, in the Source form of any Derivative Works
102 | that You distribute, all copyright, patent, trademark, and
103 | attribution notices from the Source form of the Work,
104 | excluding those notices that do not pertain to any part of
105 | the Derivative Works; and
106 |
107 | (d) If the Work includes a "NOTICE" text file as part of its
108 | distribution, then any Derivative Works that You distribute must
109 | include a readable copy of the attribution notices contained
110 | within such NOTICE file, excluding those notices that do not
111 | pertain to any part of the Derivative Works, in at least one
112 | of the following places: within a NOTICE text file distributed
113 | as part of the Derivative Works; within the Source form or
114 | documentation, if provided along with the Derivative Works; or,
115 | within a display generated by the Derivative Works, if and
116 | wherever such third-party notices normally appear. The contents
117 | of the NOTICE file are for informational purposes only and
118 | do not modify the License. You may add Your own attribution
119 | notices within Derivative Works that You distribute, alongside
120 | or as an addendum to the NOTICE text from the Work, provided
121 | that such additional attribution notices cannot be construed
122 | as modifying the License.
123 |
124 | You may add Your own copyright statement to Your modifications and
125 | may provide additional or different license terms and conditions
126 | for use, reproduction, or distribution of Your modifications, or
127 | for any such Derivative Works as a whole, provided Your use,
128 | reproduction, and distribution of the Work otherwise complies with
129 | the conditions stated in this License.
130 |
131 | 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | any Contribution intentionally submitted for inclusion in the Work
133 | by You to the Licensor shall be under the terms and conditions of
134 | this License, without any additional terms or conditions.
135 | Notwithstanding the above, nothing herein shall supersede or modify
136 | the terms of any separate license agreement you may have executed
137 | with Licensor regarding such Contributions.
138 |
139 | 6. Trademarks. This License does not grant permission to use the trade
140 | names, trademarks, service marks, or product names of the Licensor,
141 | except as required for reasonable and customary use in describing the
142 | origin of the Work and reproducing the content of the NOTICE file.
143 |
144 | 7. Disclaimer of Warranty. Unless required by applicable law or
145 | agreed to in writing, Licensor provides the Work (and each
146 | Contributor provides its Contributions) on an "AS IS" BASIS,
147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | implied, including, without limitation, any warranties or conditions
149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | PARTICULAR PURPOSE. You are solely responsible for determining the
151 | appropriateness of using or redistributing the Work and assume any
152 | risks associated with Your exercise of permissions under this License.
153 |
154 | 8. Limitation of Liability. In no event and under no legal theory,
155 | whether in tort (including negligence), contract, or otherwise,
156 | unless required by applicable law (such as deliberate and grossly
157 | negligent acts) or agreed to in writing, shall any Contributor be
158 | liable to You for damages, including any direct, indirect, special,
159 | incidental, or consequential damages of any character arising as a
160 | result of this License or out of the use or inability to use the
161 | Work (including but not limited to damages for loss of goodwill,
162 | work stoppage, computer failure or malfunction, or any and all
163 | other commercial damages or losses), even if such Contributor
164 | has been advised of the possibility of such damages.
165 |
166 | 9. Accepting Warranty or Additional Liability. While redistributing
167 | the Work or Derivative Works thereof, You may choose to offer,
168 | and charge a fee for, acceptance of support, warranty, indemnity,
169 | or other liability obligations and/or rights consistent with this
170 | License. However, in accepting such obligations, You may act only
171 | on Your own behalf and on Your sole responsibility, not on behalf
172 | of any other Contributor, and only if You agree to indemnify,
173 | defend, and hold each Contributor harmless for any liability
174 | incurred by, or claims asserted against, such Contributor by reason
175 | of your accepting any such warranty or additional liability.
176 |
177 | END OF TERMS AND CONDITIONS
178 |
179 | APPENDIX: How to apply the Apache License to your work.
180 |
181 | To apply the Apache License to your work, attach the following
182 | boilerplate notice, with the fields enclosed by brackets "[]"
183 | replaced with your own identifying information. (Don't include
184 | the brackets!) The text should be enclosed in the appropriate
185 | comment syntax for the file format. We also recommend that a
186 | file or class name and description of purpose be included on the
187 | same "printed page" as the copyright notice for easier
188 | identification within third-party archives.
189 |
190 | Copyright [yyyy] [name of copyright owner]
191 |
192 | Licensed under the Apache License, Version 2.0 (the "License");
193 | you may not use this file except in compliance with the License.
194 | You may obtain a copy of the License at
195 |
196 | http://www.apache.org/licenses/LICENSE-2.0
197 |
198 | Unless required by applicable law or agreed to in writing, software
199 | distributed under the License is distributed on an "AS IS" BASIS,
200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201 | See the License for the specific language governing permissions and
202 | limitations under the License.
--------------------------------------------------------------------------------