Starting library to get the SI1143 Gesture Sensor to work. Currently only works in forced conversion mode.

Dependents:   Gesture_Sensor Gesture_Arm_Robot mbed_gesture Gesture_Sensor_Sample ... more

Revision:
3:cb3e8160f18e
Parent:
2:21381f11a5af
Child:
4:af8f820733e0
--- a/SI1143.h	Thu Oct 17 21:03:01 2013 +0000
+++ b/SI1143.h	Thu Oct 17 22:03:54 2013 +0000
@@ -33,8 +33,16 @@
 #ifndef SI1143_h
 #define SI1143_h
 
+/**
+ * Includes
+ */
+
 #include "mbed.h"
 
+/**
+ * Defines
+ */
+
 #define IR_ADDRESS                  0x5A
 #define HW_KEY_VAL0                 0x17    //Value to write into the HW Key register
 
@@ -146,6 +154,7 @@
 #define ALS_IR_ADC_MISC             0x1F
 
 // Measurement Channel List
+
 #define PS1_TASK                    0x01
 #define PS2_TASK                    0x02
 #define PS3_TASK                    0x04
@@ -153,14 +162,37 @@
 #define ALS_IR_TASK                 0x20
 #define AUX_TASK                    0x40
 
+/**
+ * Parallax SI1143 Gesture Sensor.
+ */
 class SI1143
 {
     public:
     
+        /**
+        * Constructor.
+        *
+        * @param sda mbed pin to use for SDA line of I2C interface.
+        * @param scl mbed pin to use for SCL line of I2C interface.
+        */
         SI1143(PinName sda, PinName scl);
         
+        /**
+         * Sample the device and return a result.
+         *
+         * @param   A value of 1 will output led1
+         *          A value of 2 will output led2
+         *          A value of 3 will output led3
+         *          A value of 4 will output ambient light
+         *          A value of 5 will output infrared light
+         *          A value of anything else will output 0
+         * @return  In forced conversion output mode, will display the raw output minus any baseline
+         */
         int sample(int point);
         
+        /**
+         * Creates a baseline for sampling measurements.
+         */
         void bias(void);
         
     private:
@@ -169,11 +201,20 @@
         int bias1,bias2,bias3,PS1,PS2,PS3,VIS,IR;
         char LowB,HighB;
         
+        /**
+         * Wait for the device to respond, then send it a specific command.
+         */
         void command(char cmd);
         
-        char read_reg(/*unsigned*/ char address, int num_data); // Read a Register
+        /**
+         * Read a register from the device.
+         */
+        char read_reg(/*unsigned*/ char address, int num_data);
         
-        void write_reg(char address, char num_data);// Write a resigter
+        /**
+         * Write to a register on the device.
+         */
+        void write_reg(char address, char num_data);
         
 };