Exemple #1
0
    def set_integration_time(self, integration_time):
        '''Sets the integration time for the TSL2561'''

        # Enable the device by setting the control bit to 0x03
        self.enable()

        self.integration_time = integration_time

        # Update the timing register
        handle = self.device.i2c_open(bus, self.address)
        io.write8(self.device, handle, TSL2561_COMMAND_BIT | TSL2561_REGISTER_TIMING,
                        self.integration_time | self.gain)
        self.device.i2c_close(handle)

        # Turn the device off to save power
        self.disable()
Exemple #2
0
    def set_gain(self, gain):
        '''Adjusts the gain on the TSL2561 (adjusts the sensitivity to light)
        '''

        # Enable the device by setting the control bit to 0x03
        self.enable()

        self.gain = gain

        # Update the timing register
        handle = self.device.i2c_open(bus, self.address)
        io.write8(self.device, handle, TSL2561_COMMAND_BIT | TSL2561_REGISTER_TIMING,
                        self.integration_time | self.gain)
        self.device.i2c_close(handle)

        # Turn the device off to save power
        self.disable()
Exemple #3
0
 def disable(self):
     '''Disables the device (putting it in lower power sleep mode)'''
     handle = self.device.i2c_open(bus, self.address)
     io.write8(self.device, handle, TSL2561_COMMAND_BIT | TSL2561_REGISTER_CONTROL,
                     TSL2561_CONTROL_POWEROFF)
     self.device.i2c_close(handle)
Exemple #4
0
 def enable(self):
     '''Enable the device by setting the control bit to 0x03'''
     handle = self.device.i2c_open(bus, self.address)
     io.write8(self.device, handle, TSL2561_COMMAND_BIT | TSL2561_REGISTER_CONTROL,
                     TSL2561_CONTROL_POWERON)
     self.device.i2c_close(handle)