Psi Swarm robot library version 0.9

Dependents:   PsiSwarm_V9_Blank

Fork of PsiSwarmV9 by James Hilder

Revision:
17:bf614e28668f
Parent:
16:50686c07ad07
Child:
18:9204f74069b4
diff -r 50686c07ad07 -r bf614e28668f sensors.h
--- a/sensors.h	Thu Jun 01 23:02:32 2017 +0000
+++ b/sensors.h	Sun Jun 04 13:11:09 2017 +0000
@@ -143,12 +143,32 @@
     
     
     /** Returns the subtraction of the background base IR value from the reflection based on last call of store_base_ir_values()
-    * For most purposes this is the best method of getting values from the base IR sensor as it mitigates for background levels of IR
+    * For most purposes this is the best method of getting uncalibrated values from the base IR sensor as it mitigates for background levels of IR
     * @param index - The index of the sensor to read (range 0 to 4, sensor from left to right viewed from above - 2 is in middle of front)
     * @return Unsigned short of compensated ir value (illuminated value - background value) (range 0 to 4095)
     */
     unsigned short calculate_base_ir_value ( char index );
     
+    /** Returns the calibrated base IR value adjusted for light\dark calibration values 
+    * Range is 0.0 to 1.0 where 0.1 is calibrated black value and 0.9 calibrated white value for given sensor
+    * If sensor calibration has not been performed and stored in EEPROM used pretested values stored in settings.h
+    * NB IR sensor is very material dependant (eg matt paper vs glossy paper): values tested using basic 80gsm copier paper
+    * @param index - The index of the sensor to read (range 0 to 4, sensor from left to right viewed from above - 2 is in middle of front)
+    * @return Float of compensated ir value (range 0-1, black value = 0.1, white value = 0.9)
+    */
+    float get_calibrated_base_ir_value ( char index );
+    
+    /** Determines the position of a black line on a white surface using the base IR sensors
+    * Uses the calibrated sensor values 
+    *
+    * Sets global variable 'line_found' to either 1 if line detected or 0 if line not found
+    * Sets global variable 'line_position' (float) to a value ranging from -1.0 (line fully left) to 1.0 (line fully right)
+    * [Should range from about -0.5 to 0.5 when center sensor can see line]
+    */ 
+    void store_line_position (float line_threshold);
+    void store_line_position ( void );
+    
+    
     // The following functions are used for special programs or to retain backwards compatability but are not documented as part of the API
     
     void store_reflected_ir_distances ( void );
@@ -156,8 +176,11 @@
     float get_reflected_ir_distance ( char index );
     float calculate_reflected_distance ( unsigned short background_value, unsigned short illuminated_value );
     int get_bearing_from_ir_array ( unsigned short * ir_sensor_readings);
-    void store_line_position ( void );
-    void calibrate_base_ir_sensors ( void );
+
+    void store_line_position_old ( void );
+    void calibrate_base_sensors ( void );
+    void IF_set_base_calibration_values(int bir1w, int bir2w, int bir3w, int bir4w, int bir5w, int bir1b, int bir2b, int bir3b, int bir4b, int bir5b);
+
 
 };
 #endif
\ No newline at end of file