mirror of
https://github.com/sigmasternchen/combinationLockPG
synced 2025-03-15 03:38:53 +00:00
works different again, ut works how it should
This commit is contained in:
parent
56633995db
commit
1631d2ac2b
4 changed files with 21 additions and 6 deletions
BIN
app.zip
Normal file
BIN
app.zip
Normal file
Binary file not shown.
|
@ -3,7 +3,7 @@
|
|||
xmlns:gap = "http://phonegap.com/ns/1.0"
|
||||
id = "com.phonegap.example"
|
||||
versionCode="10"
|
||||
version = "0.0.3">
|
||||
version = "0.0.0.0.0.0.1">
|
||||
|
||||
<!-- versionCode is optional and Android only -->
|
||||
|
||||
|
|
|
@ -8,6 +8,6 @@
|
|||
</head>
|
||||
<body>
|
||||
<canvas id="canvas" width="200px" height="200px" style="background-color: #fff;"></canvas>
|
||||
<div id="heading">Waiting for heading...</div>
|
||||
<div id="textfeld">bitte warten</div>
|
||||
</body>
|
||||
</html>
|
23
main.js
23
main.js
|
@ -1,20 +1,35 @@
|
|||
function onSuccess(acceleration) {
|
||||
alert('Acceleration X: ' + acceleration.x + '\n' +
|
||||
/*alert('Acceleration X: ' + acceleration.x + '\n' +
|
||||
'Acceleration Y: ' + acceleration.y + '\n' +
|
||||
'Acceleration Z: ' + acceleration.z + '\n' +
|
||||
'Timestamp: ' + acceleration.timestamp + '\n');
|
||||
'Timestamp: ' + acceleration.timestamp + '\n' +
|
||||
((Math.atan(acceleration.y / acceleration.x))/Math.PI*180)+90
|
||||
);*/
|
||||
|
||||
var element = document.getElementById('textfeld');
|
||||
element.innerHTML = "x:"+ acceleration.x + "y:"+ acceleration.y +" <br />"+ "<br />"+ "<br />"+getAngle(acceleration.x, acceleration.y);
|
||||
drawDial(-getAngle(acceleration.x, acceleration.y)* Math.PI/180) ;
|
||||
};
|
||||
function getAngle (x, y) {
|
||||
if (x == 0)
|
||||
x += 0.00001;
|
||||
x = -x;
|
||||
if (x < 0)
|
||||
return (360 - Math.atan(y / x) * 360 / 2 / Math.PI - 90);
|
||||
else
|
||||
return -(Math.atan(y / x) * 360 / 2 / Math.PI - 90);
|
||||
}
|
||||
|
||||
function onError() {
|
||||
alert('onError!');
|
||||
};
|
||||
|
||||
var startup = function(){
|
||||
watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError);
|
||||
watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError,options);
|
||||
lockinit();
|
||||
}
|
||||
|
||||
|
||||
var options = { frequency: 1000 };
|
||||
var options = { frequency: 100 };
|
||||
|
||||
document.addEventListener("deviceready", startup, false);
|
Loading…
Reference in a new issue