Michael Limbird / Mbed 2 deprecated VideoOutput

Dependencies:   mbed

Revision:
12:509ed716bd58
Parent:
11:65ae1cf6f7d9
Child:
13:83bea035c658
--- a/main.cpp	Sat Jan 10 18:54:57 2015 +0000
+++ b/main.cpp	Sat Jan 10 19:24:38 2015 +0000
@@ -27,30 +27,24 @@
 
 Serial pc(USBTX, USBRX); //tx, rx
 
-//int adxl345_Data[3];
-//int itg3200_Data[3];
-//int hmc5843_Data[3];
+int accelerometer_data[3];
+//int gyro_data[3];
+//int magnetometer_data[3];
 
 PwmOut led(LED1);
 
 float brightness = 0.0;
 
 int main() {
-	//char cmd[2];
 
 	init_adxl345();
 	//init_hmc5843();
 	//init_itg3200();
     
-    pc.printf("Press 'u' to turn LED1 brightness up, 'd' to turn it down.\n");
+    //pc.printf("Press 'u' to turn LED1 brightness up, 'd' to turn it down.\n");
     
-    while(1) {
-        //cmd[0] = 0x01;
-        //cmd[1] = 0x00;
-        //i2c.write(addr, cmd, 2); // i2c.write(address, command, bytes);
-        
-        pc.printf("ADXL345_Address %d", ADXL345_ADDRESS);
-        
+    while(1) {        
+        /*
         char c = pc.getc();
         if((c == 'u') && (brightness < 0.5)) {
         	brightness += 0.01;
@@ -60,12 +54,13 @@
         	brightness -= 0.01;
         	led = brightness;
         }
+        */
+        
+        pc.printf("ACCEL: %i\t%i\t%i\n", accelerometer_data[0], accelerometer_data[1], accelerometer_data[2]);
         
     }
 }
 
-
-
 void init_adxl345() {
 	char data[2];
 	data[0] = ADXL_REGISTER_PWRCTL;
@@ -77,21 +72,23 @@
 
 	i2c.write(ADXL345_ADDRESS, data, 1);
 	i2c.read(ADXL345_ADDRESS, data, 2);
-	pc.printf("%c",(char)data);
+	pc.printf("%i\n",(unsigned int)data);
 }
 
-/*
 void read_adxl345() {
-	bytes bytes[6];
+	char bytes[6];
 	memset(bytes,0,6);
-
-	i2c_read(ADXL345_ADDRESS, ADXL345_REGISTER_XLSB, 6, bytes);
+	bytes[0] = ADXL345_REGISTER_XLSB;
+	
+	i2c.write(ADXL345_ADDRESS, bytes, 1);
+	i2c.read(ADXL345_ADDRESS, bytes, 6);
 
 	for (int i=0;i<3;++i) {
 		accelerometer_data[i] = (int)bytes[2*i] + (((int)bytes[2*i + 1]) << 8);
  	}
 }
 
+/*
 void init_itg3200() {
 	byte data = 0;