dorukeker / gyronorm.js

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

decimalCount 0 doesn't work #17

Closed lgg closed 8 years ago

lgg commented 8 years ago

If I set init args decimalCount to 0. It returns 2 digit after point.

I think we need change something here: https://github.com/dorukeker/gyronorm.js/blob/master/lib/gyronorm.js#L108

dorukeker commented 8 years ago

You are correct. Thanks for noticing it. As far as I see your PR still ignores the decimalCount = 0 I suggest to change that line as follows:

    if (options && options.decimalCount >= 0) _decimalCount = options.decimalCount;

So if you want it to return only integers you can set the decimalCount to zero. Any comments?

lgg commented 8 years ago

@dorukeker which PR you watched? In #19 I changed to checking number.

I think this options.decimalCount >= 0 will throw an error when no options object provided.

dorukeker commented 8 years ago

@littleguga I merged your PR.

I will add the check to be greater than 0 (it does not break even if args is not provided). Also adding a parseInt() so even if the user passes a float (e.g. 2.3) library will use the integer value.

Thanks for pointing out.

lgg commented 8 years ago

@dorukeker I think we need to rebuild /dist/?

dorukeker commented 8 years ago

@littleguga Yes :) It is built. I did not prepare a release for it. But if you check out the repo the dist/ folder contains the new version.

Are you planning to use it on a project? Or research?

lgg commented 8 years ago

@dorukeker big thanks!

I am using it my project - a little game for mobile devices in local network, when it will be done - I will publish it on github.