|
28 | 28 | ** **
|
29 | 29 | ** Vers. Date Developer Comments **
|
30 | 30 | ** ====== ========== ============================= ============================================================== **
|
31 |
| -** 1.0.5 2017-09-02 https://github.com/SV-Zanshin Added option to begin() to all for different I2C Address ** |
| 31 | +** 1.0.6 2018-06-29 https://github.com/SV-Zanshin https://github.com/SV-Zanshin/VCNL4010/issues/8 I2C speed slct ** |
| 32 | +** 1.0.5 2017-09-02 https://github.com/SV-Zanshin Added option to begin() to allow for different I2C Address ** |
32 | 33 | ** 1.0.5c 2017-09-01 https://github.com/SV-Zanshin Re-introduced 170?s delay in I2C read statements after hangs **
|
33 | 34 | ** 1.0.5b 2017-08-31 https://github.com/SV-Zanshin Removed 170?s delay in I2C read statements **
|
34 | 35 | ** 1.0.5a 2017-08-31 https://github.com/Koepel Bug https://github.com/SV-Zanshin/VCNL4010/issues/4 **
|
|
50 | 51 | /***************************************************************************************************************
|
51 | 52 | ** Declare constants used in the class **
|
52 | 53 | ***************************************************************************************************************/
|
53 |
| - const uint8_t VCNL4010_ADDRESS = 0x13; // Device address, fixed value // |
54 |
| - const uint8_t VCNL4010_COMMAND_REG = 0x80; // Register containing commands // |
55 |
| - const uint8_t VCNL4010_PRODUCT_REG = 0x81; // Register containing product ID // |
56 |
| - const uint8_t VCNL4010_PROXIMITY_RATE_REG = 0x82; // Register containing sampling rate// |
57 |
| - const uint8_t VCNL4010_LED_CURRENT_REG = 0x83; // Register containing IR LED mA // |
58 |
| - const uint8_t VCNL4010_AMBIENT_PARAMETER_REG = 0x84; // Register containing ambient set // |
59 |
| - const uint8_t VCNL4010_AMBIENT_LIGHT_REG = 0x85; // Register containing ambient data // |
60 |
| - const uint8_t VCNL4010_PROXIMITY_REG = 0x87; // Register containing Proximity // |
61 |
| - const uint8_t VCNL4010_INTERRUPT_REG = 0x89; // Register containing Interrupts // |
62 |
| - const uint8_t VCNL4010_LOW_THRESHOLD_MSB_REG = 0x8A; // MSB of low threshold value // |
63 |
| - const uint8_t VCNL4010_LOW_THRESHOLD_LSB_REG = 0x8B; // LSB of low threshold value // |
64 |
| - const uint8_t VCNL4010_HIGH_THRESHOLD_MSB_REG = 0x8C; // MSB of high threshold value // |
65 |
| - const uint8_t VCNL4010_HIGH_THRESHOLD_LSB_REG = 0x8D; // LSB of high threshold value // |
66 |
| - const uint8_t VCNL4010_INTERRUPT_STATUS_REG = 0x8E; // Interrupt status register // |
67 |
| - const uint8_t VCNL4010_PROXIMITY_TIMING_REG = 0x8F; // Register containing ProxTiming // |
68 |
| - const uint8_t VCNL4010_PRODUCT_VERSION = 0x21; // Current product ID // |
69 |
| - const uint8_t VCNL4010_I2C_DELAY_MICROSECONDS = 200; // I2C Delay in communications // |
| 54 | + const uint16_t I2C_STANDARD_MODE = 100000; // Default normal I2C comms speed // |
| 55 | + const uint16_t I2C_FAST_MODE = 400000; // Fast mode // |
| 56 | + const uint16_t I2C_FAST_MODE_PLUS_MODE = 1000000; // Really fast mode // |
| 57 | + const uint16_t I2C_HIGH_SPEED_MODE = 3400000; // Turbo mode // |
| 58 | + const uint8_t VCNL4010_ADDRESS = 0x13; // Device address, fixed value // |
| 59 | + const uint8_t VCNL4010_COMMAND_REG = 0x80; // Register containing commands // |
| 60 | + const uint8_t VCNL4010_PRODUCT_REG = 0x81; // Register containing product ID // |
| 61 | + const uint8_t VCNL4010_PROXIMITY_RATE_REG = 0x82; // Register containing sampling rate// |
| 62 | + const uint8_t VCNL4010_LED_CURRENT_REG = 0x83; // Register containing IR LED mA // |
| 63 | + const uint8_t VCNL4010_AMBIENT_PARAMETER_REG = 0x84; // Register containing ambient set // |
| 64 | + const uint8_t VCNL4010_AMBIENT_LIGHT_REG = 0x85; // Register containing ambient data // |
| 65 | + const uint8_t VCNL4010_PROXIMITY_REG = 0x87; // Register containing Proximity // |
| 66 | + const uint8_t VCNL4010_INTERRUPT_REG = 0x89; // Register containing Interrupts // |
| 67 | + const uint8_t VCNL4010_LOW_THRESHOLD_MSB_REG = 0x8A; // MSB of low threshold value // |
| 68 | + const uint8_t VCNL4010_LOW_THRESHOLD_LSB_REG = 0x8B; // LSB of low threshold value // |
| 69 | + const uint8_t VCNL4010_HIGH_THRESHOLD_MSB_REG = 0x8C; // MSB of high threshold value // |
| 70 | + const uint8_t VCNL4010_HIGH_THRESHOLD_LSB_REG = 0x8D; // LSB of high threshold value // |
| 71 | + const uint8_t VCNL4010_INTERRUPT_STATUS_REG = 0x8E; // Interrupt status register // |
| 72 | + const uint8_t VCNL4010_PROXIMITY_TIMING_REG = 0x8F; // Register containing ProxTiming // |
| 73 | + const uint8_t VCNL4010_PRODUCT_VERSION = 0x21; // Current product ID // |
| 74 | + const uint8_t VCNL4010_I2C_DELAY_MICROSECONDS = 200; // I2C Delay in communications // |
70 | 75 | class VCNL4010 { // Class definition //
|
71 | 76 | public: // Publicly visible methods //
|
72 | 77 | VCNL4010(); // Class constructor //
|
73 | 78 | ~VCNL4010(); // Class destructor //
|
74 |
| - bool begin(const uint8_t deviceAddress=VCNL4010_ADDRESS); // Start I2C communications // |
| 79 | + bool begin(const uint8_t deviceAddress=VCNL4010_ADDRESS, // Start I2C communications // |
| 80 | + const uint16_t i2CSpeed=I2C_STANDARD_MODE); // defaulting to 100KHz // |
75 | 81 | void setProximityHz(const uint8_t Hz=2); // Set proximity Hz sampling rate //
|
76 | 82 | void setLEDmA(const uint8_t mA=20); // Set milliamperes used by IR LED //
|
77 | 83 | void setProximityFreq(const uint8_t value=0); // Set Frequency value from list //
|
|
0 commit comments