tsl2591

package
v0.0.0-...-5725b45 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 16, 2020 License: BSD-3-Clause Imports: 3 Imported by: 1

Documentation

Overview

Package tsl2591 provides access to the TSL2591 sensor, over I2C/SMBus for RaspBerry.

Index

Constants

View Source
const (
	Addr           uint8 = 0x29
	ReadBit        uint8 = 0x01
	CmdBit         uint8 = 0xA0 // bits 7 and 5 for "command normal"
	ClearBit       uint8 = 0x40 // clears any pending interrupt (write 1 to clear)
	WordBit        uint8 = 0x20 // 1 = read/write word (rather than byte)
	BlockBit       uint8 = 0x10 // 1 = using block read/write
	EnablePowerON  uint8 = 0x01
	EnablePowerOFF uint8 = 0x00
	EnableAEN      uint8 = 0x02
	EnableAIEN     uint8 = 0x10
	ControlReset   uint8 = 0x80

	RegEnable          uint8 = 0x00
	RegControl         uint8 = 0x01
	RegThreshholdLLow  uint8 = 0x02
	RegThreshholdLHigh uint8 = 0x03
	RegThreshholdHLow  uint8 = 0x04
	RegThreshholdHHigh uint8 = 0x05
	RegInterrupt       uint8 = 0x06
	RegCRC             uint8 = 0x08
	RegID              uint8 = 0x0A
	RegChan0Low        uint8 = 0x14
	RegChan0High       uint8 = 0x15
	RegChan1Low        uint8 = 0x16
	RegChan1High       uint8 = 0x17

	LuxDF    = 408.0
	LuxCoefB = 1.64 // CH0 coefficient
	LuxCoefC = 0.59 // CH1 coefficient A
	LuxCoefD = 0.86 // CH2 coefficient B
)

List of register commands

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

type Device struct {
	// contains filtered or unexported fields
}

Device is a TSL2591 sensor.

func Open

func Open(conn *smbus.Conn, addr uint8, integ IntegTimeValue, gain GainValue) (*Device, error)

Open opens a connection to the TSL2591 sensor device at address addr on the provided SMBus.

func (*Device) Close

func (dev *Device) Close() error

func (*Device) FullLuminosity

func (dev *Device) FullLuminosity() (uint16, uint16, error)

func (*Device) Gain

func (dev *Device) Gain() GainValue

Gain returns the gain register value.

func (*Device) Lux

func (dev *Device) Lux(full, ir uint16) float64

func (*Device) Timing

func (dev *Device) Timing() IntegTimeValue

Timing returns the integration time register value.

type GainValue

type GainValue uint8

GainValue describes the gain value used while extracting data from sensor data.

const (
	GainLow  GainValue = 0x00 // Low gain (1x)
	GainMed  GainValue = 0x10 // Medium gain (25x)
	GainHigh GainValue = 0x20 // High gain (428x)
	GainMax  GainValue = 0x30 // Maximum gain (9876x)
)

type IntegTimeValue

type IntegTimeValue uint8

IntegTimeValue describes the integration time used while extracting data from sensor.

const (
	IntegTime100ms IntegTimeValue = 0x00
	IntegTime200ms IntegTimeValue = 0x01
	IntegTime300ms IntegTimeValue = 0x02
	IntegTime400ms IntegTimeValue = 0x03
	IntegTime500ms IntegTimeValue = 0x04
	IntegTime600ms IntegTimeValue = 0x05
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL