incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fil...@apache.org
Subject [8/29] ios commit: added unification of accelerometer values on ios (based on android values)
Date Fri, 16 Mar 2012 18:14:49 GMT
added unification of accelerometer values on ios (based on android values)


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/commit/f471cadd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/tree/f471cadd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/diff/f471cadd

Branch: refs/heads/master
Commit: f471cadd6ec3bc6551811903d082ce2fe7c810d2
Parents: f78192e
Author: Fil Maj <maj.fil@gmail.com>
Authored: Thu Mar 15 17:32:43 2012 -0700
Committer: Fil Maj <maj.fil@gmail.com>
Committed: Fri Mar 16 10:56:50 2012 -0700

----------------------------------------------------------------------
 CordovaLib/Classes/CDVAccelerometer.m |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/f471cadd/CordovaLib/Classes/CDVAccelerometer.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVAccelerometer.m b/CordovaLib/Classes/CDVAccelerometer.m
index 9083c7f..611e28d 100644
--- a/CordovaLib/Classes/CDVAccelerometer.m
+++ b/CordovaLib/Classes/CDVAccelerometer.m
@@ -28,6 +28,8 @@
 #define kMinAccelerometerInterval    40  
 // min rate of 1/sec
 #define kMaxAccelerometerInterval   1000
+// g constant: -9.81 m/s^2
+#define kGravitionalConstant        -9.81
 
 - (CDVAccelerometer*) init
 {
@@ -88,9 +90,9 @@
     
     // Create an acceleration object
     NSMutableDictionary *accelProps = [NSMutableDictionary dictionaryWithCapacity:4];
-    [accelProps setValue:[NSNumber numberWithDouble:x] forKey:@"x"];
-    [accelProps setValue:[NSNumber numberWithDouble:y] forKey:@"y"];
-    [accelProps setValue:[NSNumber numberWithDouble:z] forKey:@"z"];
+    [accelProps setValue:[NSNumber numberWithDouble:x*kGravitionalConstant] forKey:@"x"];
+    [accelProps setValue:[NSNumber numberWithDouble:y*kGravitionalConstant] forKey:@"y"];
+    [accelProps setValue:[NSNumber numberWithDouble:z*kGravitionalConstant] forKey:@"z"];
     [accelProps setValue:[NSNumber numberWithDouble:timestamp] forKey:@"timestamp"];
     
     result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:accelProps];


Mime
View raw message