Rick McConney
/
AvnetATT_shape_hackathon
This program simply connects to a HTS221 I2C device to proximity sensor
Proximity.h@43:3979ea0a2df3, 2016-10-10 (annotated)
- Committer:
- elmkom
- Date:
- Mon Oct 10 16:29:34 2016 +0000
- Revision:
- 43:3979ea0a2df3
- Parent:
- 38:532a0d929756
Flush modem buffer before send
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
elmkom | 38:532a0d929756 | 1 | #ifndef Proximity_ |
elmkom | 38:532a0d929756 | 2 | #define Proximity_ |
elmkom | 38:532a0d929756 | 3 | |
elmkom | 38:532a0d929756 | 4 | #define MUXADDRESS 0x70 |
elmkom | 38:532a0d929756 | 5 | #define PROXIMITYADDRESS 0x39 |
elmkom | 38:532a0d929756 | 6 | #define NUM_PROXIMIY_SENSORS 8 |
elmkom | 38:532a0d929756 | 7 | |
elmkom | 38:532a0d929756 | 8 | #define C25ma 0x00 |
elmkom | 38:532a0d929756 | 9 | #define C50ma 0x01 |
elmkom | 38:532a0d929756 | 10 | #define C100m1 0x02 |
elmkom | 38:532a0d929756 | 11 | #define C200ma 0x03 |
elmkom | 38:532a0d929756 | 12 | |
elmkom | 38:532a0d929756 | 13 | #define GainAls1Ir1 (0x00<<2) |
elmkom | 38:532a0d929756 | 14 | #define GainAls2Ir1 (0x04<<2) |
elmkom | 38:532a0d929756 | 15 | #define GainAls2Ir2 (0x05<<2) |
elmkom | 38:532a0d929756 | 16 | #define GainAls64Ir64 (0x0A<<2) |
elmkom | 38:532a0d929756 | 17 | #define GainAls128Ir64 (0x0D<<2) |
elmkom | 38:532a0d929756 | 18 | #define GainAls128Ir128 (0x0F<<2) |
elmkom | 38:532a0d929756 | 19 | |
elmkom | 38:532a0d929756 | 20 | #define Als0Ps0 0x00 |
elmkom | 38:532a0d929756 | 21 | #define Als0Ps10 0x01 |
elmkom | 38:532a0d929756 | 22 | #define Als0Ps40 0x02 |
elmkom | 38:532a0d929756 | 23 | #define Als0Ps100 0x03 |
elmkom | 38:532a0d929756 | 24 | #define Als0Ps400 0x04 |
elmkom | 38:532a0d929756 | 25 | |
elmkom | 38:532a0d929756 | 26 | #define Als100Ps0 0x05 |
elmkom | 38:532a0d929756 | 27 | #define Als100Ps100 0x06 |
elmkom | 38:532a0d929756 | 28 | #define Als100Ps400 0x07 |
elmkom | 38:532a0d929756 | 29 | |
elmkom | 38:532a0d929756 | 30 | #define Als401Ps0 0x08 |
elmkom | 38:532a0d929756 | 31 | #define Als401Ps100 0x09 |
elmkom | 38:532a0d929756 | 32 | #define Als400Ps0 0x0A |
elmkom | 38:532a0d929756 | 33 | #define Als400Ps400 0x0B |
elmkom | 38:532a0d929756 | 34 | |
elmkom | 38:532a0d929756 | 35 | #define Als50Ps50 0x0C |
elmkom | 38:532a0d929756 | 36 | |
elmkom | 38:532a0d929756 | 37 | |
elmkom | 38:532a0d929756 | 38 | class Proximity { |
elmkom | 38:532a0d929756 | 39 | public: |
elmkom | 38:532a0d929756 | 40 | Proximity(void); |
elmkom | 38:532a0d929756 | 41 | void init(void); |
elmkom | 38:532a0d929756 | 42 | void write_reg(char address,char reg, char cmd); |
elmkom | 38:532a0d929756 | 43 | void write(char address, char cmd); |
elmkom | 38:532a0d929756 | 44 | unsigned char read_reg(char address,char reg); |
elmkom | 38:532a0d929756 | 45 | void off(); |
elmkom | 38:532a0d929756 | 46 | void on(); |
elmkom | 38:532a0d929756 | 47 | void scan(); |
elmkom | 38:532a0d929756 | 48 | bool changed(short delta); |
elmkom | 38:532a0d929756 | 49 | short getProximity(int sensor); |
elmkom | 38:532a0d929756 | 50 | short getAmbientLight(int sensor); |
elmkom | 38:532a0d929756 | 51 | short getIR(int sensor); |
elmkom | 38:532a0d929756 | 52 | char* getDataStr(); |
elmkom | 38:532a0d929756 | 53 | }; |
elmkom | 38:532a0d929756 | 54 | |
elmkom | 38:532a0d929756 | 55 | #endif |