diff --git a/Adafruit_VL6180X.cpp b/Adafruit_VL6180X.cpp index f3b737c..7f3b5c4 100644 --- a/Adafruit_VL6180X.cpp +++ b/Adafruit_VL6180X.cpp @@ -396,6 +396,36 @@ float Adafruit_VL6180X::readLux(uint8_t gain) { return lux; } +/**************************************************************************/ +/*! + @brief Set the offset + @param offset Offset setting +*/ +/**************************************************************************/ + +void Adafruit_VL6180X::setOffset(uint8_t offset) { + // write the offset + write8(VL6180X_REG_SYSRANGE_PART_TO_PART_RANGE_OFFSET, offset); +} + +/**************************************************************************/ +/*! + @brief Get the 7 bytes of id + @param id_ptr Pointer to array of id bytes +*/ +/**************************************************************************/ + +void Adafruit_VL6180X::getID(uint8_t *id_ptr) { + + id_ptr[0] = read8(VL6180X_REG_IDENTIFICATION_MODEL_ID + 0); + id_ptr[1] = read8(VL6180X_REG_IDENTIFICATION_MODEL_ID + 1); + id_ptr[2] = read8(VL6180X_REG_IDENTIFICATION_MODEL_ID + 2); + id_ptr[3] = read8(VL6180X_REG_IDENTIFICATION_MODEL_ID + 3); + id_ptr[4] = read8(VL6180X_REG_IDENTIFICATION_MODEL_ID + 4); + id_ptr[6] = read8(VL6180X_REG_IDENTIFICATION_MODEL_ID + 6); + id_ptr[7] = read8(VL6180X_REG_IDENTIFICATION_MODEL_ID + 7); +} + /**************************************************************************/ /*! @brief I2C low level interfacing diff --git a/Adafruit_VL6180X.h b/Adafruit_VL6180X.h index 3ba3b40..2766ca9 100644 --- a/Adafruit_VL6180X.h +++ b/Adafruit_VL6180X.h @@ -33,6 +33,8 @@ #define VL6180X_REG_SYSTEM_FRESH_OUT_OF_RESET 0x016 ///! Trigger Ranging #define VL6180X_REG_SYSRANGE_START 0x018 +///! Part to part range offset +#define VL6180X_REG_SYSRANGE_PART_TO_PART_RANGE_OFFSET 0x024 ///! Trigger Lux Reading #define VL6180X_REG_SYSALS_START 0x038 ///! Lux reading gain @@ -95,6 +97,9 @@ class Adafruit_VL6180X { void stopRangeContinuous(void); // readRangeResult and isRangeComplete apply here is well + void setOffset(uint8_t offset); + void getID(uint8_t *id_ptr); + private: Adafruit_I2CDevice *i2c_dev = NULL; ///< Pointer to I2C bus interface void loadSettings(void);