dorukeker / gyronorm.js

JavaScript project for accessing and normalizing the accelerometer and gyroscope data on mobile devices
MIT License
640 stars 65 forks source link

Support on windows phone #9

Closed CrowdHailer closed 8 years ago

CrowdHailer commented 9 years ago

Hi, I seam to get no calls to the start call back on my windows phone. This is odd because the device api works as it should without any normalisation on that phone. I am using the following code

var args = {
    frequency: 50,                   // ( How often the object sends the values - milliseconds )
    gravityNormalized:true,         // ( If the garvity related values to be normalized )
    orientationBase:GyroNorm.WORLD,      // ( Can be GyroNorm.GAME or GyroNorm.WORLD. gn.GAME returns orientation values with respect to the head direction of the device. gn.WORLD returns the orientation values with respect to the actual north direction of the world. )
    decimalCount:0,                 // ( How many digits after the decimal point will there be in the return values )
    logger:null,                    // ( Function to be called to log messages from gyronorm.js )
    screenAdjusted:true            // ( If set to true it will return screen adjusted values. )
}

  var gn = new GyroNorm();
    gn.init(args).then(function(){
        gn.start(function(data){
            document.querySelector('#heading').innerHTML = data.do.alpha
            document.querySelector('#beta').innerHTML = data.do.beta
            document.querySelector('#gamma').innerHTML = data.do.gamma

        });
    });

The same page works correctly on an android device and an iphone that I have tested it on

dorukeker commented 9 years ago

Hello,

Which Windows Phone are you using? The phone brand and Windows version? Also, did you try to initialise GyroNorm with the default arguments? Such as:

var gn = new GyroNorm();
gn.init().then(function(){
    gn.start(function(data){
        ...
    });
});

I also have another remark about the code above. It is not related with the Windows Phone issue, but general. I see you have the document.querySelector with in the callback function of gn.start().

It means it is called every 50 milliseconds. That would be heavy for the browser. Instead I would do something like this:

// Query outside the function
var alphaText = document.querySelector('#heading');    

var gn = new GyroNorm();
gn.init().then(function(){
    gn.start(function(data){
        // Use in side the callback function
        alphaText.innerHTML = data.do.alpha
        ...
    });
});
dorukeker commented 9 years ago

Hello, I winder if you are having any issues? Else I will close this issue. Cheers, Doruk

karneaud commented 8 years ago

Well I have a Nokia lumina 530 running windows 8.1 using mobile IE 10 and I get nothing as well with the demo application. Though I am able get atleast the X,Y,Z values using other methods.

dorukeker commented 8 years ago

@karneaud which other methods are you using?

karneaud commented 8 years ago

@dorukeker I'm using the sample demo provided with the repo

dorukeker commented 8 years ago

Ok. For my understanding:

If I got it correct:

Cheers, D.

karneaud commented 8 years ago

@dorukeker I have to admit. I had moved on from your framework and went with gyro.js But I think there was some errors concerning how you retrieved the values.

Again. I had opted to use another framework.

I note though that in Windows 8.1 you are unable to retrieve alpha beta or gamma values.