Polo Gyro

Fork of L3GD20 by brian claus

Files at this revision

API Documentation at this revision

Comitter:
Spilly
Date:
Sun Apr 05 01:41:05 2015 +0000
Parent:
0:62dfce144cf7
Commit message:
Changes to format

Changed in this revision

L3GD20.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 62dfce144cf7 -r c7a53a17adef L3GD20.cpp
--- a/L3GD20.cpp	Thu Feb 21 00:21:23 2013 +0000
+++ b/L3GD20.cpp	Sun Apr 05 01:41:05 2015 +0000
@@ -26,16 +26,9 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  */
  
- #include "mbed.h"
- #include "L3GD20.h"
-
-
-// Defines ////////////////////////////////////////////////////////////////
-
-// The Arduino two-wire interface uses a 7-bit number for the address, 
-// and sets the last bit correctly based on reads and writes
-// mbed I2C libraries take the 7-bit address shifted left 1 bit
-// #define GYR_ADDRESS (0xD2 >> 1)
+#include "mbed.h"
+#include "L3GD20.h"
+ 
 #define GYR_ADDRESS 0xD6
 
 
@@ -46,16 +39,13 @@
     _L3GD20(sda, scl)
 {
     char reg_v;
-    _L3GD20.frequency(100000);
+    _L3GD20.frequency(400000);
     
   // 0x0F = 0b00001111
   // Normal power mode, all axes enabled
     reg_v = 0;    
     reg_v |= 0x0F;       
     write_reg(GYR_ADDRESS,L3GD20_CTRL_REG1,reg_v);
-    
-
-
 }
 
 
@@ -65,14 +55,11 @@
  
     if (recv(GYR_ADDRESS, L3GD20_OUT_X_L, gyr, 6)) {
     //scale is 8.75 mdps/digit
-        *gx = float(short(gyr[1] << 8 | gyr[0]))*0.00875;  
-        *gy =  float(short(gyr[3] << 8 | gyr[2]))*0.00875;
-        *gz =  float(short(gyr[5] << 8 | gyr[4]))*0.00875;
-
- 
+        *gx = float(short(gyr[1] << 8 | gyr[0]))*0.00875f;  
+        *gy =  float(short(gyr[3] << 8 | gyr[2]))*0.00875f;
+        *gz =  float(short(gyr[5] << 8 | gyr[4]))*0.00875f;
         return true;
     }
- 
     return false;
 }