Uses the APDS_9960 Digital Proximity, Ambient Light, RGB and Gesture Sensor library to play detected gesture sounds on a speaker from the SDcard
Dependencies: mbed SDFileSystem wave_player
glibr.h@8:6fa15d4e31fb, 2015-03-06 (annotated)
- Committer:
- kbhagat6
- Date:
- Fri Mar 06 21:50:03 2015 +0000
- Revision:
- 8:6fa15d4e31fb
- Parent:
- 5:3eb4f3091bd8
- Child:
- 9:286d00d9db80
added/organized more.. getting Qualified name erro
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kbhagat6 | 0:437ae08befe3 | 1 | #include "mbed.h" |
kbhagat6 | 0:437ae08befe3 | 2 | |
kbhagat6 | 0:437ae08befe3 | 3 | |
kbhagat6 | 0:437ae08befe3 | 4 | #define DEBUG 0 |
kbhagat6 | 0:437ae08befe3 | 5 | |
kbhagat6 | 0:437ae08befe3 | 6 | /* APDS-9960 I2C address */ |
kbhagat6 | 0:437ae08befe3 | 7 | #define APDS9960_I2C_ADDR 0x39 |
kbhagat6 | 0:437ae08befe3 | 8 | |
kbhagat6 | 0:437ae08befe3 | 9 | /* Gesture parameters */ |
kbhagat6 | 0:437ae08befe3 | 10 | #define GESTURE_THRESHOLD_OUT 10 |
kbhagat6 | 0:437ae08befe3 | 11 | #define GESTURE_SENSITIVITY_1 50 |
kbhagat6 | 0:437ae08befe3 | 12 | #define GESTURE_SENSITIVITY_2 20 |
kbhagat6 | 0:437ae08befe3 | 13 | |
kbhagat6 | 0:437ae08befe3 | 14 | /* Error code for returned values */ |
kbhagat6 | 0:437ae08befe3 | 15 | #define ERROR 0xFF |
kbhagat6 | 0:437ae08befe3 | 16 | |
kbhagat6 | 0:437ae08befe3 | 17 | /* Acceptable device IDs */ |
kbhagat6 | 0:437ae08befe3 | 18 | #define APDS9960_ID_1 0xAB |
kbhagat6 | 0:437ae08befe3 | 19 | #define APDS9960_ID_2 0x9C |
kbhagat6 | 0:437ae08befe3 | 20 | |
kbhagat6 | 0:437ae08befe3 | 21 | /* Misc parameters */ |
kbhagat6 | 0:437ae08befe3 | 22 | #define FIFO_PAUSE_TIME 30 // Wait period (ms) between FIFO reads |
kbhagat6 | 0:437ae08befe3 | 23 | |
kbhagat6 | 0:437ae08befe3 | 24 | /* APDS-9960 register addresses */ |
kbhagat6 | 0:437ae08befe3 | 25 | #define APDS9960_ENABLE 0x80 |
kbhagat6 | 0:437ae08befe3 | 26 | #define APDS9960_ATIME 0x81 |
kbhagat6 | 0:437ae08befe3 | 27 | #define APDS9960_WTIME 0x83 |
kbhagat6 | 0:437ae08befe3 | 28 | #define APDS9960_AILTL 0x84 |
kbhagat6 | 0:437ae08befe3 | 29 | #define APDS9960_AILTH 0x85 |
kbhagat6 | 0:437ae08befe3 | 30 | #define APDS9960_AIHTL 0x86 |
kbhagat6 | 0:437ae08befe3 | 31 | #define APDS9960_AIHTH 0x87 |
kbhagat6 | 0:437ae08befe3 | 32 | #define APDS9960_PILT 0x89 |
kbhagat6 | 0:437ae08befe3 | 33 | #define APDS9960_PIHT 0x8B |
kbhagat6 | 0:437ae08befe3 | 34 | #define APDS9960_PERS 0x8C |
kbhagat6 | 0:437ae08befe3 | 35 | #define APDS9960_CONFIG1 0x8D |
kbhagat6 | 0:437ae08befe3 | 36 | #define APDS9960_PPULSE 0x8E |
kbhagat6 | 0:437ae08befe3 | 37 | #define APDS9960_CONTROL 0x8F |
kbhagat6 | 0:437ae08befe3 | 38 | #define APDS9960_CONFIG2 0x90 |
kbhagat6 | 0:437ae08befe3 | 39 | #define APDS9960_ID 0x92 |
kbhagat6 | 0:437ae08befe3 | 40 | #define APDS9960_STATUS 0x93 |
kbhagat6 | 0:437ae08befe3 | 41 | #define APDS9960_CDATAL 0x94 |
kbhagat6 | 0:437ae08befe3 | 42 | #define APDS9960_CDATAH 0x95 |
kbhagat6 | 0:437ae08befe3 | 43 | #define APDS9960_RDATAL 0x96 |
kbhagat6 | 0:437ae08befe3 | 44 | #define APDS9960_RDATAH 0x97 |
kbhagat6 | 0:437ae08befe3 | 45 | #define APDS9960_GDATAL 0x98 |
kbhagat6 | 0:437ae08befe3 | 46 | #define APDS9960_GDATAH 0x99 |
kbhagat6 | 0:437ae08befe3 | 47 | #define APDS9960_BDATAL 0x9A |
kbhagat6 | 0:437ae08befe3 | 48 | #define APDS9960_BDATAH 0x9B |
kbhagat6 | 0:437ae08befe3 | 49 | #define APDS9960_PDATA 0x9C |
kbhagat6 | 0:437ae08befe3 | 50 | #define APDS9960_POFFSET_UR 0x9D |
kbhagat6 | 0:437ae08befe3 | 51 | #define APDS9960_POFFSET_DL 0x9E |
kbhagat6 | 0:437ae08befe3 | 52 | #define APDS9960_CONFIG3 0x9F |
kbhagat6 | 0:437ae08befe3 | 53 | #define APDS9960_GPENTH 0xA0 |
kbhagat6 | 0:437ae08befe3 | 54 | #define APDS9960_GEXTH 0xA1 |
kbhagat6 | 0:437ae08befe3 | 55 | #define APDS9960_GCONF1 0xA2 |
kbhagat6 | 0:437ae08befe3 | 56 | #define APDS9960_GCONF2 0xA3 |
kbhagat6 | 0:437ae08befe3 | 57 | #define APDS9960_GOFFSET_U 0xA4 |
kbhagat6 | 0:437ae08befe3 | 58 | #define APDS9960_GOFFSET_D 0xA5 |
kbhagat6 | 0:437ae08befe3 | 59 | #define APDS9960_GOFFSET_L 0xA7 |
kbhagat6 | 0:437ae08befe3 | 60 | #define APDS9960_GOFFSET_R 0xA9 |
kbhagat6 | 0:437ae08befe3 | 61 | #define APDS9960_GPULSE 0xA6 |
kbhagat6 | 0:437ae08befe3 | 62 | #define APDS9960_GCONF3 0xAA |
kbhagat6 | 0:437ae08befe3 | 63 | #define APDS9960_GCONF4 0xAB |
kbhagat6 | 0:437ae08befe3 | 64 | #define APDS9960_GFLVL 0xAE |
kbhagat6 | 0:437ae08befe3 | 65 | #define APDS9960_GSTATUS 0xAF |
kbhagat6 | 0:437ae08befe3 | 66 | #define APDS9960_IFORCE 0xE4 |
kbhagat6 | 0:437ae08befe3 | 67 | #define APDS9960_PICLEAR 0xE5 |
kbhagat6 | 0:437ae08befe3 | 68 | #define APDS9960_CICLEAR 0xE6 |
kbhagat6 | 0:437ae08befe3 | 69 | #define APDS9960_AICLEAR 0xE7 |
kbhagat6 | 0:437ae08befe3 | 70 | #define APDS9960_GFIFO_U 0xFC |
kbhagat6 | 0:437ae08befe3 | 71 | #define APDS9960_GFIFO_D 0xFD |
kbhagat6 | 0:437ae08befe3 | 72 | #define APDS9960_GFIFO_L 0xFE |
kbhagat6 | 0:437ae08befe3 | 73 | #define APDS9960_GFIFO_R 0xFF |
kbhagat6 | 0:437ae08befe3 | 74 | |
kbhagat6 | 0:437ae08befe3 | 75 | /* Bit fields */ |
kbhagat6 | 5:3eb4f3091bd8 | 76 | #define APDS9960_PON 0x01 |
kbhagat6 | 5:3eb4f3091bd8 | 77 | #define APDS9960_AEN 0x02 |
kbhagat6 | 5:3eb4f3091bd8 | 78 | #define APDS9960_PEN 0x04 |
kbhagat6 | 5:3eb4f3091bd8 | 79 | #define APDS9960_WEN 0x08 |
kbhagat6 | 5:3eb4f3091bd8 | 80 | #define APSD9960_AIEN 0x10 |
kbhagat6 | 5:3eb4f3091bd8 | 81 | #define APDS9960_PIEN 0x20 |
kbhagat6 | 5:3eb4f3091bd8 | 82 | #define APDS9960_GEN 0x40 |
kbhagat6 | 5:3eb4f3091bd8 | 83 | #define APDS9960_GVALID 0x01 |
kbhagat6 | 0:437ae08befe3 | 84 | |
kbhagat6 | 0:437ae08befe3 | 85 | /* On/Off definitions */ |
kbhagat6 | 0:437ae08befe3 | 86 | #define OFF 0 |
kbhagat6 | 0:437ae08befe3 | 87 | #define ON 1 |
kbhagat6 | 0:437ae08befe3 | 88 | |
kbhagat6 | 0:437ae08befe3 | 89 | /* Acceptable parameters for setMode */ |
kbhagat6 | 0:437ae08befe3 | 90 | #define POWER 0 |
kbhagat6 | 0:437ae08befe3 | 91 | #define AMBIENT_LIGHT 1 |
kbhagat6 | 0:437ae08befe3 | 92 | #define PROXIMITY 2 |
kbhagat6 | 0:437ae08befe3 | 93 | #define WAIT 3 |
kbhagat6 | 0:437ae08befe3 | 94 | #define AMBIENT_LIGHT_INT 4 |
kbhagat6 | 0:437ae08befe3 | 95 | #define PROXIMITY_INT 5 |
kbhagat6 | 0:437ae08befe3 | 96 | #define GESTURE 6 |
kbhagat6 | 0:437ae08befe3 | 97 | #define ALL 7 |
kbhagat6 | 0:437ae08befe3 | 98 | |
kbhagat6 | 0:437ae08befe3 | 99 | /* LED Drive values */ |
kbhagat6 | 0:437ae08befe3 | 100 | #define LED_DRIVE_100MA 0 |
kbhagat6 | 0:437ae08befe3 | 101 | #define LED_DRIVE_50MA 1 |
kbhagat6 | 0:437ae08befe3 | 102 | #define LED_DRIVE_25MA 2 |
kbhagat6 | 0:437ae08befe3 | 103 | #define LED_DRIVE_12_5MA 3 |
kbhagat6 | 0:437ae08befe3 | 104 | |
kbhagat6 | 0:437ae08befe3 | 105 | /* Proximity Gain (PGAIN) values */ |
kbhagat6 | 0:437ae08befe3 | 106 | #define PGAIN_1X 0 |
kbhagat6 | 0:437ae08befe3 | 107 | #define PGAIN_2X 1 |
kbhagat6 | 0:437ae08befe3 | 108 | #define PGAIN_4X 2 |
kbhagat6 | 0:437ae08befe3 | 109 | #define PGAIN_8X 3 |
kbhagat6 | 0:437ae08befe3 | 110 | |
kbhagat6 | 0:437ae08befe3 | 111 | /* ALS Gain (AGAIN) values */ |
kbhagat6 | 0:437ae08befe3 | 112 | #define AGAIN_1X 0 |
kbhagat6 | 0:437ae08befe3 | 113 | #define AGAIN_4X 1 |
kbhagat6 | 0:437ae08befe3 | 114 | #define AGAIN_16X 2 |
kbhagat6 | 0:437ae08befe3 | 115 | #define AGAIN_64X 3 |
kbhagat6 | 0:437ae08befe3 | 116 | |
kbhagat6 | 0:437ae08befe3 | 117 | /* Gesture Gain (GGAIN) values */ |
kbhagat6 | 0:437ae08befe3 | 118 | #define GGAIN_1X 0 |
kbhagat6 | 0:437ae08befe3 | 119 | #define GGAIN_2X 1 |
kbhagat6 | 0:437ae08befe3 | 120 | #define GGAIN_4X 2 |
kbhagat6 | 0:437ae08befe3 | 121 | #define GGAIN_8X 3 |
kbhagat6 | 0:437ae08befe3 | 122 | |
kbhagat6 | 0:437ae08befe3 | 123 | /* LED Boost values */ |
kbhagat6 | 0:437ae08befe3 | 124 | #define LED_BOOST_100 0 |
kbhagat6 | 0:437ae08befe3 | 125 | #define LED_BOOST_150 1 |
kbhagat6 | 0:437ae08befe3 | 126 | #define LED_BOOST_200 2 |
kbhagat6 | 0:437ae08befe3 | 127 | #define LED_BOOST_300 3 |
kbhagat6 | 0:437ae08befe3 | 128 | |
kbhagat6 | 0:437ae08befe3 | 129 | /* Gesture wait time values */ |
kbhagat6 | 0:437ae08befe3 | 130 | #define GWTIME_0MS 0 |
kbhagat6 | 0:437ae08befe3 | 131 | #define GWTIME_2_8MS 1 |
kbhagat6 | 0:437ae08befe3 | 132 | #define GWTIME_5_6MS 2 |
kbhagat6 | 0:437ae08befe3 | 133 | #define GWTIME_8_4MS 3 |
kbhagat6 | 0:437ae08befe3 | 134 | #define GWTIME_14_0MS 4 |
kbhagat6 | 0:437ae08befe3 | 135 | #define GWTIME_22_4MS 5 |
kbhagat6 | 0:437ae08befe3 | 136 | #define GWTIME_30_8MS 6 |
kbhagat6 | 0:437ae08befe3 | 137 | #define GWTIME_39_2MS 7 |
kbhagat6 | 0:437ae08befe3 | 138 | |
kbhagat6 | 0:437ae08befe3 | 139 | /* Default values */ |
kbhagat6 | 0:437ae08befe3 | 140 | #define DEFAULT_ATIME 219 // 103ms |
kbhagat6 | 0:437ae08befe3 | 141 | #define DEFAULT_WTIME 246 // 27ms |
kbhagat6 | 0:437ae08befe3 | 142 | #define DEFAULT_PROX_PPULSE 0x87 // 16us, 8 pulses |
kbhagat6 | 0:437ae08befe3 | 143 | #define DEFAULT_GESTURE_PPULSE 0x89 // 16us, 10 pulses |
kbhagat6 | 0:437ae08befe3 | 144 | #define DEFAULT_POFFSET_UR 0 // 0 offset |
kbhagat6 | 0:437ae08befe3 | 145 | #define DEFAULT_POFFSET_DL 0 // 0 offset |
kbhagat6 | 0:437ae08befe3 | 146 | #define DEFAULT_CONFIG1 0x60 // No 12x wait (WTIME) factor |
kbhagat6 | 0:437ae08befe3 | 147 | #define DEFAULT_LDRIVE LED_DRIVE_100MA |
kbhagat6 | 0:437ae08befe3 | 148 | #define DEFAULT_PGAIN PGAIN_4X |
kbhagat6 | 0:437ae08befe3 | 149 | #define DEFAULT_AGAIN AGAIN_4X |
kbhagat6 | 0:437ae08befe3 | 150 | #define DEFAULT_PILT 0 // Low proximity threshold |
kbhagat6 | 0:437ae08befe3 | 151 | #define DEFAULT_PIHT 50 // High proximity threshold |
kbhagat6 | 0:437ae08befe3 | 152 | #define DEFAULT_AILT 0xFFFF // Force interrupt for calibration |
kbhagat6 | 0:437ae08befe3 | 153 | #define DEFAULT_AIHT 0 |
kbhagat6 | 0:437ae08befe3 | 154 | #define DEFAULT_PERS 0x11 // 2 consecutive prox or ALS for int. |
kbhagat6 | 0:437ae08befe3 | 155 | #define DEFAULT_CONFIG2 0x01 // No saturation interrupts or LED boost |
kbhagat6 | 0:437ae08befe3 | 156 | #define DEFAULT_CONFIG3 0 // Enable all photodiodes, no SAI |
kbhagat6 | 0:437ae08befe3 | 157 | #define DEFAULT_GPENTH 40 // Threshold for entering gesture mode |
kbhagat6 | 0:437ae08befe3 | 158 | #define DEFAULT_GEXTH 30 // Threshold for exiting gesture mode |
kbhagat6 | 0:437ae08befe3 | 159 | #define DEFAULT_GCONF1 0x40 // 4 gesture events for int., 1 for exit |
kbhagat6 | 0:437ae08befe3 | 160 | #define DEFAULT_GGAIN GGAIN_4X |
kbhagat6 | 0:437ae08befe3 | 161 | #define DEFAULT_GLDRIVE LED_DRIVE_100MA |
kbhagat6 | 0:437ae08befe3 | 162 | #define DEFAULT_GWTIME GWTIME_2_8MS |
kbhagat6 | 0:437ae08befe3 | 163 | #define DEFAULT_GOFFSET 0 // No offset scaling for gesture mode |
kbhagat6 | 0:437ae08befe3 | 164 | #define DEFAULT_GPULSE 0xC9 // 32us, 10 pulses |
kbhagat6 | 0:437ae08befe3 | 165 | #define DEFAULT_GCONF3 0 // All photodiodes active during gesture |
kbhagat6 | 0:437ae08befe3 | 166 | #define DEFAULT_GIEN 0 // Disable gesture interrupts |
kbhagat6 | 0:437ae08befe3 | 167 | |
kbhagat6 | 5:3eb4f3091bd8 | 168 | /* Direction definitions */ |
kbhagat6 | 5:3eb4f3091bd8 | 169 | enum { |
kbhagat6 | 5:3eb4f3091bd8 | 170 | DIR_NONE, |
kbhagat6 | 5:3eb4f3091bd8 | 171 | DIR_LEFT, |
kbhagat6 | 5:3eb4f3091bd8 | 172 | DIR_RIGHT, |
kbhagat6 | 5:3eb4f3091bd8 | 173 | DIR_UP, |
kbhagat6 | 5:3eb4f3091bd8 | 174 | DIR_DOWN, |
kbhagat6 | 5:3eb4f3091bd8 | 175 | DIR_NEAR, |
kbhagat6 | 5:3eb4f3091bd8 | 176 | DIR_FAR, |
kbhagat6 | 5:3eb4f3091bd8 | 177 | DIR_ALL |
kbhagat6 | 5:3eb4f3091bd8 | 178 | }; |
kbhagat6 | 5:3eb4f3091bd8 | 179 | |
kbhagat6 | 5:3eb4f3091bd8 | 180 | /* State definitions */ |
kbhagat6 | 5:3eb4f3091bd8 | 181 | enum { |
kbhagat6 | 5:3eb4f3091bd8 | 182 | NA_STATE, |
kbhagat6 | 5:3eb4f3091bd8 | 183 | NEAR_STATE, |
kbhagat6 | 5:3eb4f3091bd8 | 184 | FAR_STATE, |
kbhagat6 | 5:3eb4f3091bd8 | 185 | ALL_STATE |
kbhagat6 | 5:3eb4f3091bd8 | 186 | }; |
kbhagat6 | 5:3eb4f3091bd8 | 187 | |
kbhagat6 | 5:3eb4f3091bd8 | 188 | /* Container for gesture data */ |
kbhagat6 | 5:3eb4f3091bd8 | 189 | typedef struct gesture_data_type { |
kbhagat6 | 5:3eb4f3091bd8 | 190 | uint8_t u_data[32]; |
kbhagat6 | 5:3eb4f3091bd8 | 191 | uint8_t d_data[32]; |
kbhagat6 | 5:3eb4f3091bd8 | 192 | uint8_t l_data[32]; |
kbhagat6 | 5:3eb4f3091bd8 | 193 | uint8_t r_data[32]; |
kbhagat6 | 8:6fa15d4e31fb | 194 | uint8_t sindex; |
kbhagat6 | 5:3eb4f3091bd8 | 195 | uint8_t total_gestures; |
kbhagat6 | 5:3eb4f3091bd8 | 196 | uint8_t in_threshold; |
kbhagat6 | 5:3eb4f3091bd8 | 197 | uint8_t out_threshold; |
kbhagat6 | 5:3eb4f3091bd8 | 198 | } gesture_data_type; |
kbhagat6 | 0:437ae08befe3 | 199 | |
kbhagat6 | 0:437ae08befe3 | 200 | |
kbhagat6 | 0:437ae08befe3 | 201 | class glibr{ |
kbhagat6 | 0:437ae08befe3 | 202 | |
kbhagat6 | 0:437ae08befe3 | 203 | public: |
kbhagat6 | 0:437ae08befe3 | 204 | |
kbhagat6 | 0:437ae08befe3 | 205 | |
kbhagat6 | 0:437ae08befe3 | 206 | glibr(PinName sda, PinName scl); //constructor |
kbhagat6 | 0:437ae08befe3 | 207 | ~glibr(); |
kbhagat6 | 0:437ae08befe3 | 208 | |
kbhagat6 | 0:437ae08befe3 | 209 | |
kbhagat6 | 0:437ae08befe3 | 210 | uint8_t ginit(); |
kbhagat6 | 5:3eb4f3091bd8 | 211 | /* Initialization methods */ |
kbhagat6 | 5:3eb4f3091bd8 | 212 | |
kbhagat6 | 0:437ae08befe3 | 213 | uint8_t getMode(); |
kbhagat6 | 5:3eb4f3091bd8 | 214 | bool setMode(uint8_t mode, uint8_t enable); |
kbhagat6 | 5:3eb4f3091bd8 | 215 | |
kbhagat6 | 5:3eb4f3091bd8 | 216 | /* Turn the APDS-9960 on and off */ |
kbhagat6 | 5:3eb4f3091bd8 | 217 | bool enablePower(); |
kbhagat6 | 5:3eb4f3091bd8 | 218 | bool disablePower(); |
kbhagat6 | 5:3eb4f3091bd8 | 219 | |
kbhagat6 | 5:3eb4f3091bd8 | 220 | /* Enable or disable specific sensors */ |
kbhagat6 | 5:3eb4f3091bd8 | 221 | bool enableLightSensor(bool interrupts = false); |
kbhagat6 | 5:3eb4f3091bd8 | 222 | bool disableLightSensor(); |
kbhagat6 | 5:3eb4f3091bd8 | 223 | bool enableProximitySensor(bool interrupts = false); |
kbhagat6 | 5:3eb4f3091bd8 | 224 | bool disableProximitySensor(); |
kbhagat6 | 5:3eb4f3091bd8 | 225 | bool enableGestureSensor(bool interrupts = true); |
kbhagat6 | 5:3eb4f3091bd8 | 226 | bool disableGestureSensor(); |
kbhagat6 | 5:3eb4f3091bd8 | 227 | |
kbhagat6 | 5:3eb4f3091bd8 | 228 | /* LED drive strength control */ |
kbhagat6 | 5:3eb4f3091bd8 | 229 | uint8_t getLEDDrive(); |
kbhagat6 | 5:3eb4f3091bd8 | 230 | bool setLEDDrive(uint8_t drive); |
kbhagat6 | 5:3eb4f3091bd8 | 231 | uint8_t getGestureLEDDrive(); |
kbhagat6 | 5:3eb4f3091bd8 | 232 | bool setGestureLEDDrive(uint8_t drive); |
kbhagat6 | 5:3eb4f3091bd8 | 233 | |
kbhagat6 | 5:3eb4f3091bd8 | 234 | /* Gain control */ |
kbhagat6 | 2:e31b7064efab | 235 | uint8_t getAmbientLightGain(); |
kbhagat6 | 5:3eb4f3091bd8 | 236 | bool setAmbientLightGain(uint8_t gain); |
kbhagat6 | 5:3eb4f3091bd8 | 237 | uint8_t getProximityGain(); |
kbhagat6 | 5:3eb4f3091bd8 | 238 | bool setProximityGain(uint8_t gain); |
kbhagat6 | 2:e31b7064efab | 239 | uint8_t getGestureGain(); |
kbhagat6 | 2:e31b7064efab | 240 | bool setGestureGain(uint8_t gain); |
kbhagat6 | 0:437ae08befe3 | 241 | |
kbhagat6 | 5:3eb4f3091bd8 | 242 | /* Get and set light interrupt thresholds */ |
kbhagat6 | 5:3eb4f3091bd8 | 243 | bool getLightIntLowThreshold(uint16_t &threshold); |
kbhagat6 | 5:3eb4f3091bd8 | 244 | bool setLightIntLowThreshold(uint16_t threshold); |
kbhagat6 | 5:3eb4f3091bd8 | 245 | bool getLightIntHighThreshold(uint16_t &threshold); |
kbhagat6 | 5:3eb4f3091bd8 | 246 | bool setLightIntHighThreshold(uint16_t threshold); |
kbhagat6 | 5:3eb4f3091bd8 | 247 | |
kbhagat6 | 5:3eb4f3091bd8 | 248 | /* Get and set proximity interrupt thresholds */ |
kbhagat6 | 5:3eb4f3091bd8 | 249 | bool getProximityIntLowThreshold(uint8_t &threshold); |
kbhagat6 | 5:3eb4f3091bd8 | 250 | bool setProximityIntLowThreshold(uint8_t threshold); |
kbhagat6 | 5:3eb4f3091bd8 | 251 | bool getProximityIntHighThreshold(uint8_t &threshold); |
kbhagat6 | 5:3eb4f3091bd8 | 252 | bool setProximityIntHighThreshold(uint8_t threshold); |
kbhagat6 | 3:26146a08bb22 | 253 | |
kbhagat6 | 5:3eb4f3091bd8 | 254 | /* Get and set interrupt enables */ |
kbhagat6 | 5:3eb4f3091bd8 | 255 | uint8_t getAmbientLightIntEnable(); |
kbhagat6 | 5:3eb4f3091bd8 | 256 | bool setAmbientLightIntEnable(uint8_t enable); |
kbhagat6 | 5:3eb4f3091bd8 | 257 | uint8_t getProximityIntEnable(); |
kbhagat6 | 5:3eb4f3091bd8 | 258 | bool setProximityIntEnable(uint8_t enable); |
kbhagat6 | 5:3eb4f3091bd8 | 259 | uint8_t getGestureIntEnable(); |
kbhagat6 | 5:3eb4f3091bd8 | 260 | bool setGestureIntEnable(uint8_t enable); |
kbhagat6 | 5:3eb4f3091bd8 | 261 | |
kbhagat6 | 5:3eb4f3091bd8 | 262 | /* Clear interrupts */ |
kbhagat6 | 5:3eb4f3091bd8 | 263 | bool clearAmbientLightInt(); |
kbhagat6 | 5:3eb4f3091bd8 | 264 | bool clearProximityInt(); |
kbhagat6 | 5:3eb4f3091bd8 | 265 | |
kbhagat6 | 5:3eb4f3091bd8 | 266 | /* Ambient light methods */ |
kbhagat6 | 5:3eb4f3091bd8 | 267 | bool readAmbientLight(uint16_t &val); |
kbhagat6 | 5:3eb4f3091bd8 | 268 | bool readRedLight(uint16_t &val); |
kbhagat6 | 5:3eb4f3091bd8 | 269 | bool readGreenLight(uint16_t &val); |
kbhagat6 | 5:3eb4f3091bd8 | 270 | bool readBlueLight(uint16_t &val); |
kbhagat6 | 5:3eb4f3091bd8 | 271 | |
kbhagat6 | 5:3eb4f3091bd8 | 272 | /* Proximity methods */ |
kbhagat6 | 5:3eb4f3091bd8 | 273 | bool readProximity(uint8_t &val); |
kbhagat6 | 5:3eb4f3091bd8 | 274 | |
kbhagat6 | 5:3eb4f3091bd8 | 275 | /* Gesture methods */ |
kbhagat6 | 3:26146a08bb22 | 276 | bool isGestureAvailable(); |
kbhagat6 | 4:84545b0e63a9 | 277 | int readGesture(); |
kbhagat6 | 4:84545b0e63a9 | 278 | |
kbhagat6 | 0:437ae08befe3 | 279 | private: |
kbhagat6 | 5:3eb4f3091bd8 | 280 | /* Gesture processing */ |
kbhagat6 | 5:3eb4f3091bd8 | 281 | void resetGestureParameters(); |
kbhagat6 | 5:3eb4f3091bd8 | 282 | bool processGestureData(); |
kbhagat6 | 5:3eb4f3091bd8 | 283 | bool decodeGesture(); |
kbhagat6 | 5:3eb4f3091bd8 | 284 | |
kbhagat6 | 5:3eb4f3091bd8 | 285 | /* Proximity Interrupt Threshold */ |
kbhagat6 | 5:3eb4f3091bd8 | 286 | uint8_t getProxIntLowThresh(); |
kbhagat6 | 5:3eb4f3091bd8 | 287 | bool setProxIntLowThresh(uint8_t threshold); |
kbhagat6 | 5:3eb4f3091bd8 | 288 | uint8_t getProxIntHighThresh(); |
kbhagat6 | 5:3eb4f3091bd8 | 289 | bool setProxIntHighThresh(uint8_t threshold); |
kbhagat6 | 5:3eb4f3091bd8 | 290 | |
kbhagat6 | 5:3eb4f3091bd8 | 291 | /* LED Boost Control */ |
kbhagat6 | 5:3eb4f3091bd8 | 292 | uint8_t getLEDBoost(); |
kbhagat6 | 5:3eb4f3091bd8 | 293 | bool setLEDBoost(uint8_t boost); |
kbhagat6 | 5:3eb4f3091bd8 | 294 | |
kbhagat6 | 5:3eb4f3091bd8 | 295 | /* Proximity photodiode select */ |
kbhagat6 | 5:3eb4f3091bd8 | 296 | uint8_t getProxGainCompEnable(); |
kbhagat6 | 5:3eb4f3091bd8 | 297 | bool setProxGainCompEnable(uint8_t enable); |
kbhagat6 | 5:3eb4f3091bd8 | 298 | uint8_t getProxPhotoMask(); |
kbhagat6 | 5:3eb4f3091bd8 | 299 | bool setProxPhotoMask(uint8_t mask); |
kbhagat6 | 5:3eb4f3091bd8 | 300 | |
kbhagat6 | 5:3eb4f3091bd8 | 301 | /* Gesture threshold control */ |
kbhagat6 | 5:3eb4f3091bd8 | 302 | uint8_t getGestureEnterThresh(); |
kbhagat6 | 5:3eb4f3091bd8 | 303 | bool setGestureEnterThresh(uint8_t threshold); |
kbhagat6 | 5:3eb4f3091bd8 | 304 | uint8_t getGestureExitThresh(); |
kbhagat6 | 5:3eb4f3091bd8 | 305 | bool setGestureExitThresh(uint8_t threshold); |
kbhagat6 | 5:3eb4f3091bd8 | 306 | |
kbhagat6 | 5:3eb4f3091bd8 | 307 | /* Gesture LED, gain, and time control */ |
kbhagat6 | 5:3eb4f3091bd8 | 308 | uint8_t getGestureWaitTime(); |
kbhagat6 | 5:3eb4f3091bd8 | 309 | bool setGestureWaitTime(uint8_t time); |
kbhagat6 | 5:3eb4f3091bd8 | 310 | |
kbhagat6 | 5:3eb4f3091bd8 | 311 | /* Gesture mode */ |
kbhagat6 | 5:3eb4f3091bd8 | 312 | uint8_t getGestureMode(); |
kbhagat6 | 5:3eb4f3091bd8 | 313 | bool setGestureMode(uint8_t mode); |
kbhagat6 | 5:3eb4f3091bd8 | 314 | |
kbhagat6 | 5:3eb4f3091bd8 | 315 | /* Members */ |
kbhagat6 | 5:3eb4f3091bd8 | 316 | gesture_data_type gesture_data_; //instanciation from struct |
kbhagat6 | 5:3eb4f3091bd8 | 317 | int gesture_ud_delta_; |
kbhagat6 | 5:3eb4f3091bd8 | 318 | int gesture_lr_delta_; |
kbhagat6 | 5:3eb4f3091bd8 | 319 | int gesture_ud_count_; |
kbhagat6 | 5:3eb4f3091bd8 | 320 | int gesture_lr_count_; |
kbhagat6 | 5:3eb4f3091bd8 | 321 | int gesture_near_count_; |
kbhagat6 | 5:3eb4f3091bd8 | 322 | int gesture_far_count_; |
kbhagat6 | 5:3eb4f3091bd8 | 323 | int gesture_state_; |
kbhagat6 | 5:3eb4f3091bd8 | 324 | int gesture_motion_; |
kbhagat6 | 5:3eb4f3091bd8 | 325 | |
kbhagat6 | 5:3eb4f3091bd8 | 326 | |
kbhagat6 | 5:3eb4f3091bd8 | 327 | |
kbhagat6 | 0:437ae08befe3 | 328 | uint8_t I2CreadByte(char address, char subAddress); |
kbhagat6 | 0:437ae08befe3 | 329 | int I2CwriteByte(char address, char subAddress, char data); |
kbhagat6 | 8:6fa15d4e31fb | 330 | int I2CReadDataBlock(char address, char subAddress, uint8_t *val, unsigned int len); |
kbhagat6 | 0:437ae08befe3 | 331 | I2C i2c; |
kbhagat6 | 0:437ae08befe3 | 332 | |
kbhagat6 | 0:437ae08befe3 | 333 | }; |