PARTYYYY

Dependencies:   mbed MMA8452

Revision:
3:56cd9dff3b5f
Parent:
0:c2282db9d19e
Child:
4:ab14f0e33f2b
--- a/Accelerometre.cpp	Mon Sep 04 20:00:30 2017 +0000
+++ b/Accelerometre.cpp	Mon Sep 04 22:39:02 2017 +0000
@@ -2,19 +2,39 @@
 
 
 
+Accelerometre::Accelerometre():i2c(p9,p10),pc(USBTX, USBRX),acc(p9, p10, 40000){
+    }
+    
+int Accelerometre::readxyzAngle(double *x, double *y, double *z){
+    
+    acc.readXYZGravity(x,y,z);
+    
+}
+    
+    
+    
+    
+//int Accelerometre::readSingleByte(int regis){
+//    int c;
+//    pc.printf("Reading single byte\n");  
+//    i2c.start();
+//    int a=i2c.write(WRITE_DATA);  // A write to device
+//    i2c.write(regis); // Register to read from (acceleration in X)
+//    i2c.start();        // Need to send start condition here
+//    i2c.write(READ_DATA); // tell devide you want to read
+//    c=i2c.read(0);      
+//    i2c.stop();
+//    pc.printf("value is %d\n", c);
+//    pc.printf("end\n");
+//    return c;
+//    }
+    
 
-int Accelerometre::readSingleByte(int regis){
-    char cmd[8];
-    int c;
+void Accelerometre::writeByte(int regis,int data){
     pc.printf("Reading single byte\n");  
     i2c.start();
-    int a=i2c.write(0x38);  // A write to device
+    i2c.write(WRITE_DATA);  // A write to device
     i2c.write(regis); // Register to read from (acceleration in X)
-    i2c.start();        // Need to send start condition here
-    i2c.write(0x39); // tell devide you want to read
-    c=i2c.read(0);      
+    i2c.write(data);
     i2c.stop();
-    pc.printf("value is %d\n", c);
-    pc.printf("end\n");
-    return c;
-    }
\ No newline at end of file
+}