Adafruit_VCNL4010.h
1 // SPDX-FileCopyrightText: 2019 Anne Barela for Adafruit Industries 2 // 3 // SPDX-License-Identifier: MIT 4 5 // VCNL4010 code adapted from: 6 // https://github.com/adafruit/Adafruit_VCNL4010 7 #ifndef ADAFRUIT_VCNL4010_H 8 #define ADAFRUIT_VCNL4010_H 9 10 // the i2c address 11 #define VCNL4010_I2CADDR_DEFAULT 0x13 12 13 // commands and constants 14 #define VCNL4010_COMMAND 0x80 15 #define VCNL4010_PRODUCTID 0x81 16 #define VCNL4010_PROXRATE 0x82 17 #define VCNL4010_IRLED 0x83 18 #define VCNL4010_AMBIENTPARAMETER 0x84 19 #define VCNL4010_AMBIENTDATA 0x85 20 #define VCNL4010_PROXIMITYDATA 0x87 21 #define VCNL4010_INTCONTROL 0x89 22 #define VCNL4010_PROXINITYADJUST 0x8A 23 #define VCNL4010_INTSTAT 0x8E 24 #define VCNL4010_MODTIMING 0x8F 25 26 typedef enum 27 { 28 VCNL4010_3M125 = 3, 29 VCNL4010_1M5625 = 2, 30 VCNL4010_781K25 = 1, 31 VCNL4010_390K625 = 0, 32 } vcnl4010_freq; 33 34 #define VCNL4010_MEASUREAMBIENT 0x10 35 #define VCNL4010_MEASUREPROXIMITY 0x08 36 #define VCNL4010_AMBIENTREADY 0x40 37 #define VCNL4010_PROXIMITYREADY 0x20 38 39 class Adafruit_VCNL4010 { 40 public: 41 Adafruit_VCNL4010() {} 42 43 bool begin(uint8_t a = VCNL4010_I2CADDR_DEFAULT); 44 uint16_t readProximity(); 45 46 private: 47 uint8_t read8(uint8_t address); 48 uint16_t read16(uint8_t address); 49 void write8(uint8_t address, uint8_t data); 50 uint8_t _i2caddr; 51 52 }; 53 54 #endif