Unfinished v0.7, added bearing detection

Fork of Pi_Swarm_Library_v06_alpha by piswarm

Revision:
3:4c0f2f3de33e
Parent:
1:b067a08ff54e
Child:
4:52b3e4c5a425
diff -r 0a739218ab11 -r 4c0f2f3de33e piswarm.cpp
--- a/piswarm.cpp	Sun Feb 02 20:37:48 2014 +0000
+++ b/piswarm.cpp	Sun Feb 02 21:18:05 2014 +0000
@@ -259,6 +259,38 @@
     return app_distance;
 }
 
+// Returns the illuminated raw sensor value for the IR sensor defined by index (range 0-7); turns on the emitters for a 500us pulse
+unsigned short PiSwarm::read_illuminated_raw_ir_value ( char index ){
+    //This function reads the IR strength when illuminated - used for PC system debugging purposes
+    //1.  Check that the IR LDO regulator is on, enable if it isn't
+    if(enable_ir_ldo == 0){
+        enable_ir_ldo = 1;
+        enable_ldo_outputs();
+    }
+    //2.  Enable the relevant IR emitter by turning on its pulse output
+    switch(index){
+        case 0: case 1: case 6: case 7:
+        _irpulse_1 = 1;
+        break;
+        case 2: case 3: case 4: case 5:
+        _irpulse_2 = 1;
+        break;
+    }
+    wait_us(500);               
+    //3.  Read the ADC value now IR emitter is on
+    unsigned short strong_value = read_adc_value ( index );
+    //4.  Turn off IR emitter
+       switch(index){
+        case 0: case 1: case 6: case 7:
+        _irpulse_1 = 0;
+        break;
+        case 2: case 3: case 4: case 5:
+        _irpulse_2 = 0;
+        break;
+    }
+    return strong_value;
+}
+
 // Returns the raw sensor value for the IR sensor defined by index (range 0-7).
 unsigned short PiSwarm::read_adc_value ( char index ){
     short value = 0;