mirror of
https://github.com/sigmasternchen/combinationLockPG
synced 2025-03-15 03:38:53 +00:00
works differently
This commit is contained in:
parent
40072c503b
commit
56633995db
3 changed files with 30 additions and 8 deletions
|
@ -26,6 +26,7 @@
|
||||||
<preference name="orientation" value="portrait" />
|
<preference name="orientation" value="portrait" />
|
||||||
|
|
||||||
<gap:plugin name="org.apache.cordova.device-orientation" />
|
<gap:plugin name="org.apache.cordova.device-orientation" />
|
||||||
|
<gap:plugin name="org.apache.cordova.device-motion" />
|
||||||
|
|
||||||
<feature name="Compass">
|
<feature name="Compass">
|
||||||
<param name="android-package" value="org.apache.cordova.deviceorientation.CompassListener" />
|
<param name="android-package" value="org.apache.cordova.deviceorientation.CompassListener" />
|
||||||
|
|
17
main.js
17
main.js
|
@ -1,19 +1,20 @@
|
||||||
var onSuccess = function(heading) {
|
function onSuccess(acceleration) {
|
||||||
var element = document.getElementById('heading');
|
alert('Acceleration X: ' + acceleration.x + '\n' +
|
||||||
element.innerHTML = 'Heading: ' + heading.magneticHeading;
|
'Acceleration Y: ' + acceleration.y + '\n' +
|
||||||
drawDial(heading.magneticHeading*Math.PI/180);
|
'Acceleration Z: ' + acceleration.z + '\n' +
|
||||||
|
'Timestamp: ' + acceleration.timestamp + '\n');
|
||||||
};
|
};
|
||||||
|
|
||||||
var onErrors = function() {
|
function onError() {
|
||||||
alert('Compass error: ' + compassError.code);
|
alert('onError!');
|
||||||
};
|
};
|
||||||
|
|
||||||
var startup = function(){
|
var startup = function(){
|
||||||
watchID = navigator.compass.watchHeading(onSuccess, onErrors, options);
|
watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError);
|
||||||
lockinit();
|
lockinit();
|
||||||
}
|
}
|
||||||
|
|
||||||
var watchID = null;
|
|
||||||
var options = { frequency: 1000 };
|
var options = { frequency: 1000 };
|
||||||
|
|
||||||
document.addEventListener("deviceready", startup, false);
|
document.addEventListener("deviceready", startup, false);
|
20
main2.js
Normal file
20
main2.js
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
var onSuccess = function(heading) {
|
||||||
|
var element = document.getElementById('heading');
|
||||||
|
element.innerHTML = 'Heading: ' + heading.magneticHeading;
|
||||||
|
drawDial(parseInt(heading.magneticHeading)*Math.PI/180);
|
||||||
|
};
|
||||||
|
|
||||||
|
var onErrors = function() {
|
||||||
|
alert('Compass error: ' + compassError.code);
|
||||||
|
};
|
||||||
|
|
||||||
|
var startup = function(){
|
||||||
|
watchID = navigator.accelerometer.getCurrentAcceleration(accelerometerSuccess, accelerometerError);
|
||||||
|
lockinit();
|
||||||
|
}
|
||||||
|
|
||||||
|
var watchID = null;
|
||||||
|
var options = { frequency: 1000 };
|
||||||
|
|
||||||
|
//window.onload = lockinit;
|
||||||
|
document.addEventListener("deviceready", startup, false);
|
Loading…
Reference in a new issue