python/utils/interfaces/VL6180X.py
def read_lux(self, gain):
        """Read the lux (light value) from the sensor and return it.  Must
        specify the gain value to use for the lux reading:
        - ALS_GAIN_1 = 1x
        - ALS_GAIN_1_25 = 1.25x
        - ALS_GAIN_1_67 = 1.67x
        - ALS_GAIN_2_5 = 2.5x
        - ALS_GAIN_5 = 5x
        - ALS_GAIN_10 = 10x
        - ALS_GAIN_20 = 20x
        - ALS_GAIN_40 = 40x
        """
        reg = self._read_8(_VL6180X_REG_SYSTEM_INTERRUPT_CONFIG)
        reg &= ~0x38
        reg |= 0x4 << 3 # IRQ on ALS ready.
        self._write_8(_VL6180X_REG_SYSTEM_INTERRUPT_CONFIG, reg)

        # 100 ms integration period.
        self._write_8(_VL6180X_REG_SYSALS_INTEGRATION_PERIOD_HI, 0)
        self._write_8(_VL6180X_REG_SYSALS_INTEGRATION_PERIOD_LO, 100)

        # Analog gain.
        if gain > ALS_GAIN_40:
            gain = ALS_GAIN_40
        self._write_8(_VL6180X_REG_SYSALS_ANALOGUE_GAIN, 0x40 | gain)

        # Start ALS.
        self._write_8(_VL6180X_REG_SYSALS_START, 0x1)

        # Poll until "New Sample Ready threshold event" is set.
        while ((self._read_8(_VL6180X_REG_RESULT_INTERRUPT_STATUS_GPIO) >> 3) & 0x7) != 4:
            pass

        # Read lux.
        lux = self._read_16(_VL6180X_REG_RESULT_ALS_VAL)

        # Clear interrupt.
        self._write_8(_VL6180X_REG_SYSTEM_INTERRUPT_CLEAR, 0x07)

        lux *= 0.32 # Calibrated count/lux.
        if gain == ALS_GAIN_1:
            pass
        elif gain == ALS_GAIN_1_25:
            lux /= 1.25
        elif gain == ALS_GAIN_1_67:
            lux /= 1.76
        elif gain == ALS_GAIN_2_5:
            lux /= 2.5
        elif gain == ALS_GAIN_5:
            lux /= 5
        elif gain == ALS_GAIN_10:
            lux /= 10
        elif gain == ALS_GAIN_20:
            lux /= 20
        elif gain == ALS_GAIN_40:
            lux /= 20
        lux *= 100
        lux /= 100 # Integration time in ms.

        return lux
Read the lux (light value) from the sensor and return it.  Must
        specify the gain value to use for the lux reading:
        - ALS_GAIN_1 = 1x
        - ALS_GAIN_1_25 = 1.25x
        - ALS_GAIN_1_67 = 1.67x
        - ALS_GAIN_2_5 = 2.5x
        - ALS_GAIN_5 = 5x
        - ALS_GAIN_10 = 10x
        - ALS_GAIN_20 = 20x
        - ALS_GAIN_40 = 40x
        
Read the lux (light value) from the sensor and return it.
Read the lux ( light value ) from the sensor and return it .
def read_lux(self, gain):
        reg = self._read_8(_VL6180X_REG_SYSTEM_INTERRUPT_CONFIG)
        reg &= ~0x38
        reg |= 0x4 << 3 
        self._write_8(_VL6180X_REG_SYSTEM_INTERRUPT_CONFIG, reg)
        self._write_8(_VL6180X_REG_SYSALS_INTEGRATION_PERIOD_HI, 0)
        self._write_8(_VL6180X_REG_SYSALS_INTEGRATION_PERIOD_LO, 100)
        if gain > ALS_GAIN_40:
            gain = ALS_GAIN_40
        self._write_8(_VL6180X_REG_SYSALS_ANALOGUE_GAIN, 0x40 | gain)
        self._write_8(_VL6180X_REG_SYSALS_START, 0x1)
        while ((self._read_8(_VL6180X_REG_RESULT_INTERRUPT_STATUS_GPIO) >> 3) & 0x7) != 4:
            pass
        lux = self._read_16(_VL6180X_REG_RESULT_ALS_VAL)
        self._write_8(_VL6180X_REG_SYSTEM_INTERRUPT_CLEAR, 0x07)
        lux *= 0.32 
        if gain == ALS_GAIN_1:
            pass
        elif gain == ALS_GAIN_1_25:
            lux /= 1.25
        elif gain == ALS_GAIN_1_67:
            lux /= 1.76
        elif gain == ALS_GAIN_2_5:
            lux /= 2.5
        elif gain == ALS_GAIN_5:
            lux /= 5
        elif gain == ALS_GAIN_10:
            lux /= 10
        elif gain == ALS_GAIN_20:
            lux /= 20
        elif gain == ALS_GAIN_40:
            lux /= 20
        lux *= 100
        lux /= 100 
        return lux
def read_lux ( self , gain ) : reg = self . _read_8 ( _VL6180X_REG_SYSTEM_INTERRUPT_CONFIG ) reg &= ~ 0x38 reg |= 0x4 << 3 self . _write_8 ( _VL6180X_REG_SYSTEM_INTERRUPT_CONFIG , reg ) self . _write_8 ( _VL6180X_REG_SYSALS_INTEGRATION_PERIOD_HI , 0 ) self . _write_8 ( _VL6180X_REG_SYSALS_INTEGRATION_PERIOD_LO , 100 ) if gain > ALS_GAIN_40 : gain = ALS_GAIN_40 self . _write_8 ( _VL6180X_REG_SYSALS_ANALOGUE_GAIN , 0x40 | gain ) self . _write_8 ( _VL6180X_REG_SYSALS_START , 0x1 ) while ( ( self . _read_8 ( _VL6180X_REG_RESULT_INTERRUPT_STATUS_GPIO ) >> 3 ) & 0x7 ) != 4 : pass lux = self . _read_16 ( _VL6180X_REG_RESULT_ALS_VAL ) self . _write_8 ( _VL6180X_REG_SYSTEM_INTERRUPT_CLEAR , 0x07 ) lux *= 0.32 if gain == ALS_GAIN_1 : pass elif gain == ALS_GAIN_1_25 : lux /= 1.25 elif gain == ALS_GAIN_1_67 : lux /= 1.76 elif gain == ALS_GAIN_2_5 : lux /= 2.5 elif gain == ALS_GAIN_5 : lux /= 5 elif gain == ALS_GAIN_10 : lux /= 10 elif gain == ALS_GAIN_20 : lux /= 20 elif gain == ALS_GAIN_40 : lux /= 20 lux *= 100 lux /= 100 return lux
Read the lux (light value) from the sensor and return it.
Read the lux ( light value ) from the sensor and return it .
"""Read the lux (light value) from the sensor and return it.  Must
        specify the gain value to use for the lux reading:
        - ALS_GAIN_1 = 1x
        - ALS_GAIN_1_25 = 1.25x
        - ALS_GAIN_1_67 = 1.67x
        - ALS_GAIN_2_5 = 2.5x
        - ALS_GAIN_5 = 5x
        - ALS_GAIN_10 = 10x
        - ALS_GAIN_20 = 20x
        - ALS_GAIN_40 = 40x
        """ # IRQ on ALS ready. # 100 ms integration period. # Analog gain. # Start ALS. # Poll until "New Sample Ready threshold event" is set. # Read lux. # Clear interrupt. # Calibrated count/lux. # Integration time in ms.
self
gain