Dectection take 1. Fixed adaptation step. Detect based on a number of standard deviations away from the mean.

Dependencies:   SI1143 m3pi mbed

Fork of Proximity_Sensor_2_detect by MF Doom

Files at this revision

API Documentation at this revision

Comitter:
mfillinois
Date:
Thu Jun 12 20:58:19 2014 +0000
Parent:
4:5109cfc7cc96
Child:
6:f2c616fa9ffe
Commit message:
sampling experiments

Changed in this revision

Proximity_Sensor_2LED.lib Show diff for this revision Revisions of this file
SI1143.lib Show annotated file Show diff for this revision Revisions of this file
m3pi.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/Proximity_Sensor_2LED.lib	Wed Jun 04 23:14:12 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/teams/DP/code/Proximity_Sensor/#8798491332ed
--- a/SI1143.lib	Wed Jun 04 23:14:12 2014 +0000
+++ b/SI1143.lib	Thu Jun 12 20:58:19 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/dmcohen24/code/SI1142/#a89555c4f62a
+http://mbed.org/users/mfillinois/code/SI1141_auto_sense/#f90ed8f6f38b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m3pi.lib	Thu Jun 12 20:58:19 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/chris/code/m3pi/#4b7d6ea9b35b
--- a/main.cpp	Wed Jun 04 23:14:12 2014 +0000
+++ b/main.cpp	Thu Jun 12 20:58:19 2014 +0000
@@ -1,35 +1,47 @@
 
 #include "mbed.h"
 #include "SI1143.h"
+#include "m3pi.h"
 
 //DigitalOut enable(p30);
 
-Ticker timer;
+//Ticker timer;
 
 I2C* i2c = new I2C(p28, p27);
+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);
 
-//DigitalIn s2(p29);
+InterruptIn event(p26);
 
 SI1143 sensor1(i2c, p30, p29, 0x01);
-SI1143 sensor2(i2c, p25, p26, 0x02); // p25, p26
+//SI1143 sensor2(i2c, p25, p26, 0x02); // p25, p26
 
 //InterruptIn prox_meas(p26); //26
-
 int sense1a, sense1b, sense2a, sense2b;
 
-void meas_int(){
+//int total = 1000;
+int countingstuffpoop = 0;
+
+void meas_int()
+{
     led1 = 1;
-    sense1a = sensor1.get_ps1(1);
-    sense1b = sensor1.get_ps2(1);
-    sense2a = sensor2.get_ps1(1);
-    sense2b = sensor2.get_ps2(1);
-    printf("%d,  %d,  %d,  %d;\r\n",sense1a, sense1b, sense2a, sense2b);
-    //printf("%d\r\n",sense2);
+    sense1a = sensor1.read_ps1();
+    sense1b = sensor1.read_ps2();
+    //sense2a = sensor2.get_ps1(1);
+    //sense2b = sensor2.get_ps2(1);
+    //bt.printf("%d,  %d;\r\n",sense1a, sense1b);
+    //wait(0.001);
+    
+    countingstuffpoop++;
+    if(countingstuffpoop > 1000)
+    {
+        led4 = 0;
+    }
+    
+    sensor1.clear_int();
     led1 = 0;
 }
 
@@ -42,7 +54,12 @@
     //printf("%d\r\n",sensor2.adrs);    
     led2 = 0;
     wait(1);
-    timer.attach(&meas_int, 0.01);
+    
+    event.fall(&meas_int);
+    //timer.attach(&meas_int, 0.01);
+    sensor1.start_ps_auto();
+    led4 = 1;
+    //pi.left(0.1);
 
     while(1)
     {