apds9960

package
v0.0.0-...-2e22e3b Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package apds9960 implements a driver for APDS-9960, a digital proximity, ambient light, RGB and gesture sensor.

Datasheet: https://cdn.sparkfun.com/assets/learn_tutorials/3/2/1/Avago-APDS-9960-datasheet.pdf

Index

Constants

View Source
const (

	// I2C address
	ADPS9960_ADDRESS = 0x39

	// control/status registers
	APDS9960_RAM_REG        = 0x00
	APDS9960_ENABLE_REG     = 0x80
	APDS9960_ATIME_REG      = 0x81
	APDS9960_WTIME_REG      = 0x83
	APDS9960_AILTIL_REG     = 0x84
	APDS9960_AILTH_REG      = 0x85
	APDS9960_AIHTL_REG      = 0x86
	APDS9960_AIHTH_REG      = 0x87
	APDS9960_PILT_REG       = 0x89
	APDS9960_PIHT_REG       = 0x8B
	APDS9960_PERS_REG       = 0x8C
	APDS9960_CONFIG1_REG    = 0x8D
	APDS9960_PPULSE_REG     = 0x8E
	APDS9960_CONTROL_REG    = 0x8F
	APDS9960_CONFIG2_REG    = 0x90
	APDS9960_ID_REG         = 0x92
	APDS9960_STATUS_REG     = 0x93
	APDS9960_CDATAL_REG     = 0x94
	APDS9960_CDATAH_REG     = 0x95
	APDS9960_RDATAL_REG     = 0x96
	APDS9960_RDATAH_REG     = 0x97
	APDS9960_GDATAL_REG     = 0x98
	APDS9960_GDATAH_REG     = 0x99
	APDS9960_BDATAL_REG     = 0x9A
	APDS9960_BDATAH_REG     = 0x9B
	APDS9960_PDATA_REG      = 0x9C
	APDS9960_POFFSET_UR_REG = 0x9D
	APDS9960_POFFSET_DL_REG = 0x9E
	APDS9960_CONFIG3_REG    = 0x9F
	APDS9960_GPENTH_REG     = 0xA0
	APDS9960_GEXTH_REG      = 0xA1
	APDS9960_GCONF1_REG     = 0xA2
	APDS9960_GCONF2_REG     = 0xA3
	APDS9960_GOFFSET_U_REG  = 0xA4
	APDS9960_GOFFSET_D_REG  = 0xA5
	APDS9960_GOFFSET_L_REG  = 0xA7
	APDS9960_GOFFSET_R_REG  = 0xA9
	APDS9960_GPULSE_REG     = 0xA6
	APDS9960_GCONF3_REG     = 0xAA
	APDS9960_GCONF4_REG     = 0xAB
	APDS9960_GFLVL_REG      = 0xAE
	APDS9960_GSTATUS_REG    = 0xAF
	APDS9960_IFORCE_REG     = 0xE4
	APDS9960_PICLEAR_REG    = 0xE5
	APDS9960_CICLEAR_REG    = 0xE6
	APDS9960_AICLEAR_REG    = 0xE7
	APDS9960_GFIFO_U_REG    = 0xFC
	APDS9960_GFIFO_D_REG    = 0xFD
	APDS9960_GFIFO_L_REG    = 0xFE
	APDS9960_GFIFO_R_REG    = 0xFF
)
View Source
const (

	// sensor modes
	MODE_NONE = iota
	MODE_PROXIMITY
	MODE_COLOR
	MODE_GESTURE
)
View Source
const (

	// detected gestures
	GESTURE_NONE = iota
	GESTURE_UP
	GESTURE_DOWN
	GESTURE_LEFT
	GESTURE_RIGHT
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Configuration

type Configuration struct {
	ProximityPulseLength uint8
	ProximityPulseCount  uint8
	GesturePulseLength   uint8
	GesturePulseCount    uint8
	ProximityGain        uint8
	GestureGain          uint8
	ColorGain            uint8
	ADCIntegrationCycles uint16
	LEDBoost             uint16
	// contains filtered or unexported fields
}

Configuration for APDS-9960 device.

type Device

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

Device wraps an I2C connection to a APDS-9960 device.

func New

func New(bus drivers.I2C) Device

New creates a new APDS-9960 connection. The I2C bus must already be configured.

This function only creates the Device object, it does not touch the device.

func (*Device) ColorAvailable

func (d *Device) ColorAvailable() bool

ColorAvailable reports if color data is available

func (*Device) Configure

func (d *Device) Configure(cfg Configuration)

Configure sets up the APDS-9960 device.

func (*Device) Connected

func (d *Device) Connected() bool

Connected returns whether APDS-9960 has been found. It does a "who am I" request and checks the response.

func (*Device) DisableAll

func (d *Device) DisableAll()

DisableAll turns off the device and all functions

func (*Device) EnableColor

func (d *Device) EnableColor()

EnableColor starts the color engine

func (*Device) EnableGesture

func (d *Device) EnableGesture()

EnableGesture starts the gesture engine

func (*Device) EnableProximity

func (d *Device) EnableProximity()

EnableProximity starts the proximity engine

func (*Device) GestureAvailable

func (d *Device) GestureAvailable() bool

GestureAvailable reports if gesture data is available

func (*Device) GetMode

func (d *Device) GetMode() uint8

GetMode returns current engine mode

func (*Device) LEDBoost

func (d *Device) LEDBoost(percent uint16)

LEDBoost sets proximity and gesture LED current level (100, 150, 200, 300 (%)) default: 100

func (*Device) ProximityAvailable

func (d *Device) ProximityAvailable() bool

ProximityAvailable reports if proximity data is available

func (*Device) ReadColor

func (d *Device) ReadColor() (r int32, g int32, b int32, clear int32)

ReadColor reads color data (red, green, blue, clear color/brightness)

func (*Device) ReadGesture

func (d *Device) ReadGesture() (gesture int32)

ReadGesture reads last gesture data

func (*Device) ReadProximity

func (d *Device) ReadProximity() (proximity int32)

ReadProximity reads proximity data (0~255)

func (*Device) SetADCIntegrationCycles

func (d *Device) SetADCIntegrationCycles(cycles uint16)

SetADCIntegrationCycles sets ALS/color ADC internal integration cycles (1~256, 1 cycle = 2.78 ms) default: 4 (~10 ms)

func (*Device) SetGains

func (d *Device) SetGains(proximityGain, gestureGain, colorGain uint8)

SetGains sets proximity/gesture gain (1, 2, 4, 8x) and ALS/color gain (1, 4, 16, 64x) default: 1, 1, 4

func (*Device) SetGesturePulse

func (d *Device) SetGesturePulse(length, count uint8)

SetGesturePulse sets gesture pulse length (4, 8, 16, 32) and count (1~64) default: 16, 64

func (*Device) SetProximityPulse

func (d *Device) SetProximityPulse(length, count uint8)

SetProximityPulse sets proximity pulse length (4, 8, 16, 32) and count (1~64) default: 16, 64

func (*Device) Setsensitivity

func (d *Device) Setsensitivity(s uint8)

Setsensitivity sets sensivity (0~100) for detecting gestures default: 20

func (*Device) Setthreshold

func (d *Device) Setthreshold(t uint8)

Setthreshold sets threshold (0~255) for detecting gestures default: 30

Jump to

Keyboard shortcuts

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