Tyler Altenhofen / Mbed 2 deprecated TylerPOV

Dependencies:   mbed

Revision:
3:1e9b4a4bf177
Parent:
2:554edc4b0cf2
Child:
4:f81b40e04a58
diff -r 554edc4b0cf2 -r 1e9b4a4bf177 main.cpp
--- a/main.cpp	Wed Apr 15 20:46:13 2015 +0000
+++ b/main.cpp	Sun Apr 19 23:03:43 2015 +0000
@@ -28,19 +28,20 @@
 double slice_time;
 double rotate_time;
 int current_slice;
-char slice_data [NUMBER_OF_SLICES][8]; //[slice][forSepcificArm][eachBit]
+char slice_data [NUMBER_OF_SLICES][16]; //[slice][specific bit] & with approppriate bit for each arm
 double firstTime;
 
 Serial pc(USBTX, USBRX); // tx, rx
+Serial bt(p9, p10);// tx, rx
 
 
-void pushData (char (*bits) [8]){
-  for (int i = 0; i < 8; i ++){
-    dataArmOne = bits [0][i] & 0x80;
-    dataArmTwo = bits [1][i] & 0x40;
-    dataArmThree = bits [2][i]& 0x20;
-    dataArmFour = bits [3][i]& 0x10;
-   // dataArmFive = *bits [4][i];
+void pushData (char (*bits) [16]){
+  for (int i = 0; i < 16; i ++){
+    dataArmOne = *bits [i] & 0x80;
+    dataArmTwo = *bits [i] & 0x40;
+    dataArmThree = *bits [i]& 0x20;
+    dataArmFour = *bits [i]& 0x10;
+    dataArmFive = *bits [i] & 0x08;
     //dataArmSix = *bits [5][i];
     //dataArmSeven = *bits [6][i];
     //dataArmEight = *bits [7][i];
@@ -65,16 +66,19 @@
 
 //Hall sensor interupt
 void rotate_sense(){
+  pc.printf("interupt");
   if (firstTime){
     rotationTime.reset();
     rotationTime.start();
     firstTime = 0;
-    printf("first time");
+    pc.printf("first time");
+    led = !led;
     return;
   } else if(current_slice < NUMBER_OF_SLICES / 2){
       return;
       }
-  printf("seconod time \n");
+  pc.printf("seconod time \n");
+  led = !led;
     rotate_time = rotationTime.read_us();
     rotationTime.reset();    
     rotationTime.start();
@@ -86,24 +90,25 @@
 
 
 int main() {
-  printf("started");
+  pc.printf("started");
   firstTime = 1;
   current_slice = 90;
     
-    hallSensor.rise(&rotate_sense);
+    hallSensor.fall(&rotate_sense);
     for (int i = 0; i < 45; i ++){
-        slice_data [i][0] = 0x80;
+        slice_data [i][0] = 0x80; // bit 0 is high on arm 0
         //{1,1,1,1,0,0,0,0,1,1,1,0,0,0,1,0};
     }
     for (int i = 45; i < 90; i++){
-      slice_data [i][0] = 0x80;
+      slice_data [i][0] = 0x00;
       //{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
     }
     
     while(1) {
-      //TODO: add in the ability to update the buffers  
-      led = !led;   
-      wait(.25);     
+      if (bt.readable()){
+          pc.printf("%f \n", bt.getc());
+          pc.printf("read that ish");
+      //TODO: add in the ability to update the buffers        
         
     }
 }