From 40072c503b653fe779028136809a0014c87f528e Mon Sep 17 00:00:00 2001 From: moorgar11 Date: Mon, 17 Mar 2014 22:24:08 +0100 Subject: [PATCH] works somehow --- config.xml | 12 +++++++++--- index.html | 5 +++-- main.js | 13 +++++++++---- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/config.xml b/config.xml index 39a61ee..14131eb 100644 --- a/config.xml +++ b/config.xml @@ -26,8 +26,12 @@ - - + + + + + + - + + + diff --git a/index.html b/index.html index 45ceede..451a338 100644 --- a/index.html +++ b/index.html @@ -3,10 +3,11 @@ - + + +
Waiting for heading...
\ No newline at end of file diff --git a/main.js b/main.js index 862d92f..42d8819 100644 --- a/main.js +++ b/main.js @@ -1,14 +1,19 @@ var onSuccess = function(heading) { var element = document.getElementById('heading'); - element.innerHTML = 'Heading: ' + heading; + element.innerHTML = 'Heading: ' + heading.magneticHeading; + drawDial(heading.magneticHeading*Math.PI/180); }; var onErrors = function() { - alert('onError!'); + alert('Compass error: ' + compassError.code); }; var startup = function(){ - var watchID = navigator.compass.getCurrentHeading(onSuccess, onErrors); + watchID = navigator.compass.watchHeading(onSuccess, onErrors, options); lockinit(); } -window.onload = startup; + +var watchID = null; +var options = { frequency: 1000 }; + +document.addEventListener("deviceready", startup, false); \ No newline at end of file