Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of StarterKit by
Proximity.h@45:fe90f1fcb4e0, 2016-11-30 (annotated)
- Committer:
- elmkom
- Date:
- Wed Nov 30 14:50:16 2016 +0000
- Revision:
- 45:fe90f1fcb4e0
- Parent:
- 44:60008ebffdd4
gsma version
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 | 44:60008ebffdd4 | 4 | |
| elmkom | 38:532a0d929756 | 5 | #define PROXIMITYADDRESS 0x39 |
| elmkom | 44:60008ebffdd4 | 6 | #define NUM_PROXIMIY_SENSORS 5 |
| 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 | 44:60008ebffdd4 | 39 | private: |
| elmkom | 44:60008ebffdd4 | 40 | I2C *proximityi2c; |
| elmkom | 44:60008ebffdd4 | 41 | short proximityData [NUM_PROXIMIY_SENSORS][3]; |
| elmkom | 44:60008ebffdd4 | 42 | short lastProximityData [NUM_PROXIMIY_SENSORS][3]; |
| elmkom | 44:60008ebffdd4 | 43 | char dataStr[NUM_PROXIMIY_SENSORS*32]; |
| elmkom | 44:60008ebffdd4 | 44 | char muxAddress; |
| elmkom | 38:532a0d929756 | 45 | public: |
| elmkom | 38:532a0d929756 | 46 | Proximity(void); |
| elmkom | 44:60008ebffdd4 | 47 | void init(I2C *i2c, char mAddress); |
| elmkom | 38:532a0d929756 | 48 | void write_reg(char address,char reg, char cmd); |
| elmkom | 38:532a0d929756 | 49 | void write(char address, char cmd); |
| elmkom | 38:532a0d929756 | 50 | unsigned char read_reg(char address,char reg); |
| elmkom | 38:532a0d929756 | 51 | void off(); |
| elmkom | 38:532a0d929756 | 52 | void on(); |
| elmkom | 38:532a0d929756 | 53 | void scan(); |
| elmkom | 38:532a0d929756 | 54 | bool changed(short delta); |
| elmkom | 38:532a0d929756 | 55 | short getProximity(int sensor); |
| elmkom | 38:532a0d929756 | 56 | short getAmbientLight(int sensor); |
| elmkom | 38:532a0d929756 | 57 | short getIR(int sensor); |
| elmkom | 38:532a0d929756 | 58 | char* getDataStr(); |
| elmkom | 38:532a0d929756 | 59 | }; |
| elmkom | 38:532a0d929756 | 60 | |
| elmkom | 38:532a0d929756 | 61 | #endif |
