Skip to content

Commit a7b582d

Browse files
authored
Create Adafruit_VCN4000.h
1 parent b84781e commit a7b582d

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// VCNL4000 code adapted from:
2+
// https://github.com/adafruit/VCNL4000
3+
#ifndef ADAFRUIT_VCNL4000_H
4+
#define ADAFRUIT_VCNL4000_H
5+
6+
// the i2c address
7+
#define VCNL4000_ADDRESS 0x13
8+
9+
// commands and constants
10+
#define VCNL4000_COMMAND 0x80
11+
#define VCNL4000_PRODUCTID 0x81
12+
#define VCNL4000_IRLED 0x83
13+
#define VCNL4000_AMBIENTPARAMETER 0x84
14+
#define VCNL4000_AMBIENTDATA 0x85
15+
#define VCNL4000_PROXIMITYDATA 0x87
16+
#define VCNL4000_SIGNALFREQ 0x89
17+
#define VCNL4000_PROXINITYADJUST 0x8A
18+
19+
#define VCNL4000_3M125 0
20+
#define VCNL4000_1M5625 1
21+
#define VCNL4000_781K25 2
22+
#define VCNL4000_390K625 3
23+
24+
#define VCNL4000_MEASUREAMBIENT 0x10
25+
#define VCNL4000_MEASUREPROXIMITY 0x08
26+
#define VCNL4000_AMBIENTREADY 0x40
27+
#define VCNL4000_PROXIMITYREADY 0x20
28+
29+
30+
class Adafruit_VCNL4000 {
31+
public:
32+
Adafruit_VCNL4000() {}
33+
34+
bool begin();
35+
uint16_t readProximity();
36+
37+
private:
38+
uint8_t read8(uint8_t address);
39+
uint16_t read16(uint8_t address);
40+
void write8(uint8_t address, uint8_t data);
41+
42+
};
43+
44+
#endif

0 commit comments

Comments
 (0)