Mini Project 10: Displaying stuff from day 7

Dependencies:   DmTouch_UniGraphic UniGraphic mbed

Revision:
8:bbe3e332fe94
Parent:
7:ee7f2c33d45d
Child:
9:0f4c86e7218a
--- a/acceler_sensor.cpp	Tue Jan 17 19:16:38 2017 +0000
+++ b/acceler_sensor.cpp	Tue Jan 17 19:30:09 2017 +0000
@@ -4,14 +4,13 @@
 void configure_acceleration(void){
     
     const int address = 0x53 << 1; // set 'address' to    
-    i2c_port.start();
+    /*i2c_port.start();
     i2c_port.write(address);
     i2c_port.write(0x1D);   //to set the Tap Threshold
     i2c_port.write(0x50 << 2); 
     i2c_port.stop();
     wait(0.01);
     
-     
     i2c_port.start();
     i2c_port.write(address);
     i2c_port.write(0x21);//set Tap Duration
@@ -53,13 +52,37 @@
     i2c_port.write(0x2F);//set interupt map
     i2c_port.write(0x20|0x40); 
     i2c_port.stop();
-    wait(0.01);
+    wait(0.01);             all the above should confige tap functions for accel sensor, so it's unneccesary*/ 
 
     i2c_port.start();
     i2c_port.write(address);
+    i2c_port.frequency(2000000);
     i2c_port.write(0x2D);//power control register
     i2c_port.write(0x08);//measure mode 
     i2c_port.stop();
     wait(0.01);
-    
-}
\ No newline at end of file
+}
+
+void getacceleration (void){
+    const int address = 0x53 << 1;
+    char buffer[6];
+        int16_t rawdata[3];
+        i2c_port.write(address);
+        i2c_port.write(0x80|0x40|0x32);
+          for(int i=0; i<= 5; i++)
+            {
+                buffer[i]=12c.write(0x00);
+                //pc.printf("x = %+1.2fg\t", buffer[i]);
+            }
+        cs=1;
+        rawdata[0] = buffer[1]<<8 | buffer[0];
+        rawdata[1] = buffer[3]<<8 | buffer[2];
+        rawdata[2] = buffer[5]<<8 | buffer[4];
+        data[0] = rawdata[0]; 
+        data[1] = rawdata[1];
+        float x = data[0];
+        float y = data[1];
+        pc.printf("x = %+1.2fg\t y = %+1.2fg\n\r", rawdata[0],rawdata[1]); //Just grabbed from SPI code. Not formatted right
+        i2c_port.stop();
+        
+    }
\ No newline at end of file