countingstuffpoop?

Dependencies:   SI1143 m3pi mbed

Fork of Proximity_Sensor_2_sense by MF Doom

Files at this revision

API Documentation at this revision

Comitter:
mfillinois
Date:
Mon Jun 16 15:07:07 2014 +0000
Parent:
5:b77b678ed22f
Child:
7:73a722360cdb
Commit message:
fooling with sample rate;

Changed in this revision

SI1143.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/SI1143.lib	Thu Jun 12 20:58:19 2014 +0000
+++ b/SI1143.lib	Mon Jun 16 15:07:07 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mfillinois/code/SI1141_auto_sense/#f90ed8f6f38b
+http://mbed.org/teams/DP/code/SI1143/#72876499ffef
--- a/main.cpp	Thu Jun 12 20:58:19 2014 +0000
+++ b/main.cpp	Mon Jun 16 15:07:07 2014 +0000
@@ -11,8 +11,10 @@
 Serial bt(p13, p14);
 m3pi pi;
 
-DigitalOut led1(LED1); DigitalOut led2(LED2);
-DigitalOut led3(LED3); DigitalOut led4(LED4);
+DigitalOut led1(LED1);
+DigitalOut led2(LED2);
+DigitalOut led3(LED3);
+DigitalOut led4(LED4);
 
 InterruptIn event(p26);
 
@@ -21,6 +23,10 @@
 
 //InterruptIn prox_meas(p26); //26
 int sense1a, sense1b, sense2a, sense2b;
+//int NN = 500;
+int sensor1alog[500];
+int sensor1blog[500];
+int whileflag = 1;
 
 //int total = 1000;
 int countingstuffpoop = 0;
@@ -34,40 +40,66 @@
     //sense2b = sensor2.get_ps2(1);
     //bt.printf("%d,  %d;\r\n",sense1a, sense1b);
     //wait(0.001);
-    
+
     countingstuffpoop++;
-    if(countingstuffpoop > 1000)
+    if(countingstuffpoop < 500)
     {
         led4 = 0;
+        sensor1alog[countingstuffpoop-1] = sense1a;
+        sensor1blog[countingstuffpoop-1] = sense1b;
     }
-    
+    else
+    {
+        __disable_irq(); 
+        whileflag = 0;
+    }
+
     sensor1.clear_int();
     led1 = 0;
 }
 
 int main()
-{   
+{
     // Setup the baseline
     //sensor1.restart(i2c, 0x01);
     //printf("%d    ",sensor1.adrs);
     //sensor2.restart(i2c, 0x02);
-    //printf("%d\r\n",sensor2.adrs);    
+    //printf("%d\r\n",sensor2.adrs);
     led2 = 0;
-    wait(1);
-    
+    wait(10);
+
     event.fall(&meas_int);
     //timer.attach(&meas_int, 0.01);
     sensor1.start_ps_auto();
     led4 = 1;
-    //pi.left(0.1);
+    pi.left(0.1);
 
-    while(1)
+    while(whileflag)
     {
         // Read each led sensor
         //sense1 = sensor.get_ps1(1);
-                
+
         //Numeriacl output through terminal
         led1 = 0;
         led2 = 0;
     }
+    
+    pi.stop();
+    led1 = 1;
+    wait(0.3);
+    led1 = 0;
+    wait(0.3);
+    led1 = 1;
+    bt.printf("d = [");
+    for (int i = 0; i < 500; i++)
+    {
+        bt.printf("%d,  %d;\r\n", sensor1alog[i], sensor1blog[i]);
+        //bt.printf("%d;\r\n", sensorlog[i]);
+    }
+    bt.printf("0, 0];");
+    led1 = 1;
+    wait(0.3);
+    led1 = 0;
+    wait(0.3);
+    led1 = 1;
 }
\ No newline at end of file