GSMA version

Dependencies:   FXOS8700CQ mbed

Fork of AvnetATT_shape_hackathon by Rick McConney

Revision:
44:60008ebffdd4
Parent:
39:3bbb3dbb531b
--- a/Proximity.cpp	Mon Oct 10 16:29:34 2016 +0000
+++ b/Proximity.cpp	Wed Oct 26 18:40:40 2016 +0000
@@ -1,21 +1,17 @@
 #include "mbed.h"
 #include "Proximity.h"
 
-I2C *proximityi2c;
-short proximityData [NUM_PROXIMIY_SENSORS][3];
-short lastProximityData [NUM_PROXIMIY_SENSORS][3];
-char dataStr[NUM_PROXIMIY_SENSORS*32];
+
 
 Proximity::Proximity(void)
 {
-
-
 }
 
-void Proximity::init(void)
+void Proximity::init(I2C *i2c, char mAddress)
 {
-    proximityi2c = new I2C(PTE25, PTE24);
-    proximityi2c->frequency(400000);
+    muxAddress = mAddress;
+    proximityi2c = i2c;
+    proximityi2c->frequency(100000);
 }
 
 void Proximity::write_reg(char address,char reg, char cmd)
@@ -51,7 +47,7 @@
 {
     for(int sensor = 0;sensor<NUM_PROXIMIY_SENSORS;sensor++)
     {
-        write(MUXADDRESS,1<<sensor); 
+        write(muxAddress,1<<sensor); 
         write_reg(PROXIMITYADDRESS,0x41,0x00);
     }
 }
@@ -62,7 +58,7 @@
     {
 
         lastProximityData[sensor][0] = 1000;
-        write(MUXADDRESS,1<<sensor); 
+        write(muxAddress,1<<sensor); 
         write_reg(PROXIMITYADDRESS,0x41,Als400Ps400); // initiate ALS: and PS
         write_reg(PROXIMITYADDRESS,0x42,GainAls64Ir64|C25ma); // set ALS_VIS=ALS_IR GAIN = 64 current 25ma
     }
@@ -73,7 +69,7 @@
 {  
     for(int sensor = 0;sensor<NUM_PROXIMIY_SENSORS;sensor++)
     {
-        write(MUXADDRESS,1<<sensor);
+        write(muxAddress,1<<sensor);
         //proximity_sensor_on(sensor);
         unsigned char prox_lsb = read_reg(PROXIMITYADDRESS,0x44);
         unsigned char prox_msb = read_reg(PROXIMITYADDRESS,0x45);