.. module:: vcnl4200 ************** VCNL4200 Module ************** .. _datasheet: https://www.vishay.com/docs/84430/vcnl4200.pdf This module contains the Zerynth driver for Vishay VCNL4200. The unit integrates a high sensitivity long distance proximity sensor (PS), ambient light sensor (ALS), and 940 nm IRED into one small package. Communication with this unit is done using I2C. ============== VCNL4200 class ============== .. class:: VCNL4200(drvsel, ps=True, als=True, address=DEFAULT_I2C_ADDR, clk=400000) Initialize an object representing the VCNL4200 board. The I2C communication is started, and enabled sensors are configured with a stanrdard configuration. Note: Default settings enable proximity sensor high definition and faster duty time, this results in more accuracy at the cost of more power usage. Refer to sensor datasheet and use configure_proximity_sensor(), configure_ambient_light_sensor() methods for more advanced settings. :param drvsel: The I2C port to be used. (e.g. I2C0) :param ps: Boolean for enabling the proximity sensor on board (Default: True) :param als: Boolean for enabling the ambient light sensor on board (Default: True) :param address: Byte for selecting the I2C address to be used. (Default: sensor default) :param clk: I2C clock speed to be used (100000 or 400000). (Default: 400000) .. method:: get_distance() Returns an integer representing the proximity read from the sensor. .. method:: get_ambient_light() Returns an integer in range 0-65535 representing the ambient light level read from the sensor. .. method:: configure_proximity_sensor(conf1, conf2, conf3) Write settings for proximity sensor in registers PS_CONF1, PS_CONF2, and PS_CONF3. Refer to datasheet for all the available settings. :param conf1: Byte to be written in PS_CONF1 register. :param conf2: Byte to be written in PS_CONF2 register. :param conf3: Byte to be written in PS_CONF3 register. .. method:: configure_ambient_light_sensor(conf) Write settings for ambient light sensor in register ALS_CONF. Refer to datasheet for all the available settings. :param conf: Byte to be written in ALS_CONF register.