piicodev

package module
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2024 License: Apache-2.0 Imports: 8 Imported by: 1

README

go-piicodev

A Go implementation of the Core Electronics PiicoDev drivers

The company, Core Electronics (https://core-electronics.com.au/), produce a set of products called PiicoDev. They supply a set of drivers written in Python (https://github.com/CoreElectronics). This is a port of those drivers to Go for the Raspberry Pi.

Currently supported are the Core Electronics PiicoDev:

  • Pressure Seneor MS5637
  • Temperature Sensor TMP117
  • Ambient Light Sensor VEML6030
  • Colour Sensor VEML6040
  • Distance Sensor VL53L1X
  • Motion Sensor MPU-6050
  • Capacitive Touch Sensor CAP1203
  • Air Quality Sensor ENS160
  • 3 x RGB LED
  • Buzzer
  • Potentiometer
  • Switch

Now adding other I2C devices

  • Qwiic PIR Sensor
  • AHT10 Temperature and humidity sensor
  • LM75a Temperature sensor and thermal watchdog

For example:

package main

import (
	"fmt"
	"github.com/drtimf/go-piicodev"
)

func main() {
	var err error
	var t *piicodev.TMP117

	if t, err = piicodev.NewTMP117(piicodev.TMP117Address, 1); err != nil {
		fmt.Println(err)
		return
	}

	defer t.Close()

	var tempC float64
	if tempC, err = t.ReadTempC(); err != nil {
		fmt.Println(err)
		return
	}

	fmt.Println("Current temperature:", tempC)
}

Documentation

Overview

Core Electronics PiicoDev Buzzer The Python and firmware implementations: https://github.com/CoreElectronics/CE-PiicoDev-Buzzer-MicroPython-Module

Core Electronics PiicoDev Capacitive Touch Sensor CAP1203 Spec sheet: https://ww1.microchip.com/downloads/en/DeviceDoc/00001572B.pdf

Core Electronics PiicoDev Air Quality Sensor ENS160

I2C device access through the Linux /dev/i2c-{bus} for Piicodev devices

Core Electronics PiicoDev Motion Sensor MPU-6050

Core Electronics PiicoDev Pressure Seneor MS5637 The original C implementation is https://github.com/TEConnectivity/MS5637_Generic_C_Driver

Core Electronics PiicoDev Potentiometer

SparkFun Electronics Qwiic PIR The firmware: https://github.com/sparkfun/Qwiic_PIR The Python implementation: https://github.com/sparkfun/Qwiic_PIR_Py

Core Electronics PiicoDev RGB LED The Python and firmware implementations: https://github.com/CoreElectronics/CE-PiicoDev-RGB-LED-MicroPython-Module

Core Electronics PiicoDev Switch

Core Electronics PiicoDev Precision Temperature Sensor TMP117

Core Electronics PiicoDev Ambient Light Sensor VEML6030 Spec sheet: https://www.vishay.com/docs/84366/veml6030.pdf

Core Electronics PiicoDev Colour Sensor VEML6040 Spec sheet: https://www.vishay.com/docs/84331/designingveml6040.pdf

Core Electronics PiicoDev Distance Sensor VL53L1X

Index

Constants

View Source
const (
	BuzzerStatusReg               = 0x01
	BuzzerFirmwareVersionMajorReg = 0x02
	BuzzerFirmwareVersionMinorReg = 0x03
	BuzzerI2CAddressReg           = 0x04
	BuzzerToneReg                 = 0x05
	BuzzerVolumeReg               = 0x06
	BuzzerPowerLEDReg             = 0x07
	BuzzerDeviceIDReg             = 0x11
)
View Source
const (
	CAP1203MainControlReg    = 0x00
	CAP1203MainControlBitInt = 0

	CAP1203GeneralStatusReg = 0x02
	CAP1203InputStatusReg   = 0x03

	CAP1203Input1DeltaCountReg = 0x10
	CAP1203Input2DeltaCountReg = 0x11
	CAP1203Input3DeltaCountReg = 0x12

	CAP1203SensitivityControlReg           = 0x1F
	CAP1203SensitivityControlBitDeltaSense = 4

	CAP1203MultipleTouchConfigReg = 0x2A

	CAP1203ProdIDReg   = 0xFD
	CAP1203ProdIDValue = 0x6D
)
View Source
const (
	I2C_SLAVE uintptr = 0x0703
	I2C_RDWR  uintptr = 0x0707
)
View Source
const (
	MPU6050Address = 0x68

	GRAVITIY_MS2 = 9.80665

	// Scale Modifiers
	ACC_SCLR_2G  = 16384.0
	ACC_SCLR_4G  = 8192.0
	ACC_SCLR_8G  = 4096.0
	ACC_SCLR_16G = 2048.0

	GYR_SCLR_250DEG  = 131.0
	GYR_SCLR_500DEG  = 65.5
	GYR_SCLR_1000DEG = 32.8
	GYR_SCLR_2000DEG = 16.4

	// MPU-6050 Registers
	PWR_MGMT_1 = 0x6B
	PWR_MGMT_2 = 0x6C

	SELF_TEST_X = 0x0D
	SELF_TEST_Y = 0x0E
	SELF_TEST_Z = 0x0F
	SELF_TEST_A = 0x10

	ACCEL_XOUT0 = 0x3B
	ACCEL_XOUT1 = 0x3C
	ACCEL_YOUT0 = 0x3D
	ACCEL_YOUT1 = 0x3E
	ACCEL_ZOUT0 = 0x3F
	ACCEL_ZOUT1 = 0x40

	TEMP_OUT0 = 0x41
	TEMP_OUT1 = 0x42

	GYRO_XOUT0 = 0x43
	GYRO_XOUT1 = 0x44
	GYRO_YOUT0 = 0x45
	GYRO_YOUT1 = 0x46
	GYRO_ZOUT0 = 0x47
	GYRO_ZOUT1 = 0x48

	ACCEL_CONFIG = 0x1C
	GYRO_CONFIG  = 0x1B
)
View Source
const (
	QwiicPIRAddress = 0x12

	QwiicPIRDeviceIDReg             = 0x00
	QwiicPIRFirmwareVersionMajorReg = 0x01
	QwiicPIRFirmwareVersionMinorReg = 0x02
	QwiicPIREventStatusReg          = 0x03
	QwiicPIRInterruptConfigReg      = 0x04
	QwiicPIREventDebounceTimeReg    = 0x05
	QwiicPIRDetectedQueueStatusReg  = 0x07
	QwiicPIRDetectedQueueFrontReg   = 0x08
	QwiicPIRDetectedQueueBackReg    = 0x0C
	QwiicPIRRemovedQueueStatusReg   = 0x10
	QwiicPIRRemovedQueueFrontReg    = 0x11
	QwiicPIRRemovedQueueBackReg     = 0x15
	QwiicPIRI2cAddressReg           = 0x19

	QwiicPIRDeviceID = 0x72
)
View Source
const (
	RGBLEDDeviceIDReg        = 0x00
	RGBLEDFirmwareVersionReg = 0x01
	RGBLEDControlReg         = 0x03
	RGBLEDClearReg           = 0x04
	RGBLEDBrightnessReg      = 0x06
	RGBLEDValuesReg          = 0x07
)
View Source
const (
	VEML6040Address = 0x10

	VEML6040ConfigReg = 0x00
	VEML6040RedReg    = 0x08
	VEML6040GreenReg  = 0x09
	VEML6040BlueReg   = 0x0A
	VEML6040WhiteReg  = 0x0B

	VEML6040DefaultSettings = 0x00 // initialise gain:1x, integration 40ms, Green Sensitivity 0.25168, Max. Detectable Lux 16496, No Trig, Auto mode, enabled.
	VEML6040Shutdown        = 0x01
)
View Source
const (
	AHT10Address = 0x38
)
View Source
const BuzzerAddress = 0x5C
View Source
const CAP1203Address = 0x28
View Source
const (
	ENS160Address = 0x53
)
View Source
const (
	LM75AAddress = 0x4F
)
View Source
const (
	MS5637Address = 0x76
)
View Source
const (
	PotentiometerAddress = 0x35
)
View Source
const RGBLEDAddress = 0x08
View Source
const (
	SwitchAddress = 0x42
)
View Source
const TMP117Address = 0x48
View Source
const (
	VEML6030Address = 0x10
)
View Source
const (
	VL53L1XAddress = 0x29
)

Variables

This section is empty.

Functions

func CalculateCCT added in v1.0.3

func CalculateCCT(red, green, blue uint16) (cct float64)

CalculateCCT calculates the correlated colour temperature (CCT) from RGB values

func CalculateHSV added in v1.0.3

func CalculateHSV(red, green, blue uint16) (hue, saturation, value float64)

CalculateHSV calculates the hue, saturation and value (HSV) from red, green and blue (RGB) values. The red, green and blue values are 0-65535. The hue is 0-360 and the saturation and value are 0-100.

Types

type AHT10 added in v1.0.4

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

func NewAHT10 added in v1.0.4

func NewAHT10(addr uint8, bus int) (s *AHT10, err error)

func (*AHT10) Close added in v1.0.4

func (s *AHT10) Close()

Close closes the handle to the device

func (*AHT10) GetStatus added in v1.0.4

func (s *AHT10) GetStatus() (status uint8, err error)

* * AHT1x status register controls: * 7 6 5 4 3 2 1 0 * BSY, MOD, MOD, xx, CAL, xx, xx, xx * - BSY: * - 1, sensor busy/measuring * - 0, sensor idle/sleeping * - MOD: * - 00, normal mode * - 01, cycle mode * - 1x, comand mode * - CAL: * - 1, calibration on * - 0, calibration off

func (*AHT10) ReadSensor added in v1.0.4

func (s *AHT10) ReadSensor() (temperature float64, humidity float64, err error)

func (*AHT10) SetInitRegister added in v1.0.4

func (s *AHT10) SetInitRegister(value uint8) (err error)

func (*AHT10) SoftReset added in v1.0.4

func (s *AHT10) SoftReset() (err error)

type Buzzer added in v1.0.3

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

func NewBuzzer added in v1.0.3

func NewBuzzer(addr uint8, bus int) (b *Buzzer, err error)

NewBuzzer creates a new Buzzer instances

func (*Buzzer) Close added in v1.0.3

func (b *Buzzer) Close()

Close cleans up the connection for the Buzzer instances

func (*Buzzer) EnablePowerLED added in v1.0.3

func (b *Buzzer) EnablePowerLED(state bool) (err error)

EnablePowerLED sets the state of the green power LED to on or off depending on the state passed in

func (*Buzzer) GetDeviceID added in v1.0.3

func (b *Buzzer) GetDeviceID() (id byte, err error)

GetDeviceID gets the device ID of the Buzzer (should be 0x51)

func (*Buzzer) GetFirmwareVersion added in v1.0.3

func (b *Buzzer) GetFirmwareVersion() (ver [2]byte, err error)

GetFirmwareVersion gets the firmware version of the Buzzer (currently 1.1)

func (*Buzzer) GetStatus added in v1.0.3

func (b *Buzzer) GetStatus() (status byte, err error)

GetStatus reads the status of the Buzzer where bit 1 is last command succeeded and bit 2 is last command known

func (*Buzzer) NoTone added in v1.0.3

func (b *Buzzer) NoTone() (err error)

NoTone turns off the buzzer

func (*Buzzer) SetTone added in v1.0.3

func (b *Buzzer) SetTone(freq uint16, duration uint16) (err error)

SetTone sets the tone of the buzzer ...

func (*Buzzer) SetVolume added in v1.0.3

func (b *Buzzer) SetVolume(volume int) (err error)

SetVolume sets the volume of the buzzer between 0 which is quietest to 2 which is loudest

type CAP1203 added in v1.0.2

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

func NewCAP1203 added in v1.0.2

func NewCAP1203(addr uint8, bus int) (c *CAP1203, err error)

NewCAP1203 creates a new CAP1203 touch sensor instance

func (*CAP1203) Close added in v1.0.2

func (c *CAP1203) Close()

Close cleans up the connection for the CAP1203 touch sensor instance

func (*CAP1203) GetMultipleTouchEnabled added in v1.0.2

func (c *CAP1203) GetMultipleTouchEnabled() (enabled bool, err error)

GetMultipleTouchEnabled reads whether multiple touch is enabled

func (*CAP1203) GetSensitivity added in v1.0.2

func (c *CAP1203) GetSensitivity() (sensitivity int, err error)

GetSensitivity reads the sensitivity level of the touch sensors where 7 is least sensitive and 0 most sensitive

func (*CAP1203) IsTouched added in v1.0.2

func (c *CAP1203) IsTouched() (touched bool, err error)

IsTouched indicates that the touch interrupt has been flagged since the last clearing of the interrupt

func (*CAP1203) Read added in v1.0.2

func (c *CAP1203) Read() (status1, status2, status3 bool, err error)

Read obtains the status of the touch flags and clears the touch interrupt

func (*CAP1203) ReadDeltaCounts added in v1.0.2

func (c *CAP1203) ReadDeltaCounts() (count1, count2, count3 int, err error)

ReadDeltaCounts obtains the raw readings from the touch sensors

func (*CAP1203) SetMultipleTouchEnabled added in v1.0.2

func (c *CAP1203) SetMultipleTouchEnabled(enabled bool) (err error)

SetMultipleTouchEnabled sets multiple touch mode

func (*CAP1203) SetSensitivity added in v1.0.2

func (c *CAP1203) SetSensitivity(sensitivity int) (err error)

SetSensitivity sets the sensitivity level of the touch sensors where 7 is least sensitive and 0 most sensitive

type ENS160 added in v1.0.4

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

func NewENS160 added in v1.0.4

func NewENS160(addr uint8, bus int) (s *ENS160, err error)

func (*ENS160) Close added in v1.0.4

func (s *ENS160) Close()

Close closes the handle to the device

func (*ENS160) GetHumidity added in v1.0.4

func (s *ENS160) GetHumidity() (humidity float64, err error)

func (*ENS160) GetOperation added in v1.0.4

func (s *ENS160) GetOperation() (operation string, err error)

func (*ENS160) GetStatus added in v1.0.4

func (s *ENS160) GetStatus() (status byte, err error)

func (*ENS160) GetTemperature added in v1.0.4

func (s *ENS160) GetTemperature() (temperature float64, err error)

func (*ENS160) ReadAQI added in v1.0.4

func (s *ENS160) ReadAQI() (aqi byte, rating string, err error)

Read air quality indices (AQIs)

func (*ENS160) ReadECO2 added in v1.0.4

func (s *ENS160) ReadECO2() (eco2 uint16, rating string, err error)

Read CO2-equivalents

func (*ENS160) ReadTVOC added in v1.0.4

func (s *ENS160) ReadTVOC() (tvoc uint16, err error)

Read true volatile organic compounds (TrueVOC) including ethanol, toluene, as well as hydrogen and nitrogen dioxide

func (*ENS160) SetHumidity added in v1.0.4

func (s *ENS160) SetHumidity(humidity float64) (err error)

func (*ENS160) SetTemperature added in v1.0.4

func (s *ENS160) SetTemperature(temperature float64) (err error)

type I2C

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

func OpenI2C

func OpenI2C(address uint8, bus int) (i2c *I2C, err error)

OpenI2C opens an I2C device at a particular address on a bus

func (*I2C) Close

func (i2c *I2C) Close()

Close an I2C device

func (*I2C) ReadReg

func (i2c *I2C) ReadReg(reg byte, length int) (val []byte, err error)

readReg uses the RDWR ioctl call to read from an I2C register

func (*I2C) ReadReg16

func (i2c *I2C) ReadReg16(reg uint16, length int) (val []byte, err error)

ReadReg16 uses the RDWR ioctl call to read from an I2C register with a 16-bit address

func (*I2C) ReadReg16U16BE

func (i2c *I2C) ReadReg16U16BE(reg uint16) (val uint16, err error)

ReadReg16U16BE reads an unsigned 16-bit value in big endian format from a register with a 16-bit address

func (*I2C) ReadReg16U16LE

func (i2c *I2C) ReadReg16U16LE(reg uint16) (val uint16, err error)

ReadReg16U16LE reads an unsigned 16-bit value in little endian format from a register with a 16-bit address

func (*I2C) ReadReg16U8

func (i2c *I2C) ReadReg16U8(reg uint16) (val byte, err error)

ReadReg16U8 reads an unsigned 8-bit value a register

func (*I2C) ReadRegBit added in v1.0.2

func (i2c *I2C) ReadRegBit(reg byte, bitPos uint) (val bool, err error)

ReadRegBit reads a single bit from a register

func (*I2C) ReadRegBits added in v1.0.2

func (i2c *I2C) ReadRegBits(reg byte, bitPos uint, numBits uint) (val int, err error)

ReadRegBits reads multiple bits from a register

func (*I2C) ReadRegS16BE

func (i2c *I2C) ReadRegS16BE(reg byte) (val int16, err error)

ReadRegS16BE reads a signed 16-bit value in big endian format from a register

func (*I2C) ReadRegU16BE

func (i2c *I2C) ReadRegU16BE(reg byte) (val uint16, err error)

ReadRegU16BE reads an unsigned 16-bit value in big endian format from a register

func (*I2C) ReadRegU16LE

func (i2c *I2C) ReadRegU16LE(reg byte) (val uint16, err error)

ReadRegU16LE reads an unsigned 16-bit value in little endian format from a register

func (*I2C) ReadRegU24BE

func (i2c *I2C) ReadRegU24BE(reg byte) (val uint32, err error)

ReadRegU24BE reads an unsigned 24-bit value in big endian format from a register

func (*I2C) ReadRegU32LE added in v1.0.3

func (i2c *I2C) ReadRegU32LE(reg byte) (val uint32, err error)

ReadRegU32LE reads an unsigned 32-bit value in little endian format from a register

func (*I2C) ReadRegU8

func (i2c *I2C) ReadRegU8(reg byte) (val byte, err error)

ReadRegU8 reads an unsigned 8-bit value a register

func (*I2C) Write

func (i2c *I2C) Write(val []byte) (err error)

Write uses the RDWR ioctl call to write

func (*I2C) WriteReg

func (i2c *I2C) WriteReg(reg byte, val []byte) (err error)

WriteReg uses the RDWR ioctl call to write to an I2C register

func (*I2C) WriteReg16

func (i2c *I2C) WriteReg16(reg uint16, val []byte) (err error)

WriteReg16 uses the RDWR ioctl call to write to an I2C register with a 16-bit address

func (*I2C) WriteReg16U16BE

func (i2c *I2C) WriteReg16U16BE(reg uint16, val uint16) (err error)

WriteReg16U16BE writes an unsigned 16-bit big endian value to an I2C register with a 16-bit address

func (*I2C) WriteReg16U16LE

func (i2c *I2C) WriteReg16U16LE(reg uint16, val uint16) (err error)

WriteReg16U16LE writes an unsigned 16-bit little endian value to an I2C register with a 16-bit address

func (*I2C) WriteReg16U8

func (i2c *I2C) WriteReg16U8(reg uint16, val byte) (err error)

WriteReg16U8 writes an unsigned 8-bit value to an I2C register with a 16-bit address

func (*I2C) WriteRegBit added in v1.0.2

func (i2c *I2C) WriteRegBit(reg byte, bitPos uint, val bool) (err error)

WriteRegBit reads the existing registry value and updates the bitPos with val

func (*I2C) WriteRegBits added in v1.0.2

func (i2c *I2C) WriteRegBits(reg byte, bitPos uint, numBits uint, val int) (err error)

WriteRegBits reads the existing registry value and updates the numBits at bitPos with val

func (*I2C) WriteRegU16BE

func (i2c *I2C) WriteRegU16BE(reg byte, val uint16) (err error)

WriteRegU16BE writes an unsigned 16-bit big endian value to an I2C register with a 16-bit address

func (*I2C) WriteRegU16LE

func (i2c *I2C) WriteRegU16LE(reg byte, val uint16) (err error)

WriteRegU16LE writes an unsigned 16-bit little endian value to an I2C register with a 16-bit address

func (*I2C) WriteRegU8

func (i2c *I2C) WriteRegU8(reg byte, val byte) (err error)

WriteRegU8 writes an unsigned 8-bit value to an I2C register

func (*I2C) WriteU8

func (i2c *I2C) WriteU8(val byte) (err error)

WriteU8 uses the RDWR ioctl call to write a byte

type LM75A added in v1.0.4

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

func NewLM75A added in v1.0.4

func NewLM75A(addr uint8, bus int) (s *LM75A, err error)

func (*LM75A) Close added in v1.0.4

func (s *LM75A) Close()

Close closes the handle to the device

func (*LM75A) ReadTemperature added in v1.0.4

func (s *LM75A) ReadTemperature() (temperature float64, err error)

type MPU6050

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

func NewMPU6050

func NewMPU6050(addr uint8, bus int) (t *MPU6050, err error)

func (*MPU6050) Close

func (t *MPU6050) Close()

func (*MPU6050) GetAccelRangeRaw

func (t *MPU6050) GetAccelRangeRaw() (r MPU6050AccelRange, err error)

func (*MPU6050) GetAccelRangeValue

func (t *MPU6050) GetAccelRangeValue() (r int, err error)

func (*MPU6050) GetGyroRangeRaw

func (t *MPU6050) GetGyroRangeRaw() (r MPU6050GyroRange, err error)

func (*MPU6050) GetGyroRangeValue

func (t *MPU6050) GetGyroRangeValue() (r int, err error)

func (*MPU6050) ReadAccelData

func (t *MPU6050) ReadAccelData() (x, y, z float64, err error)

func (*MPU6050) ReadGyroData

func (t *MPU6050) ReadGyroData() (x, y, z float64, err error)

func (*MPU6050) ReadTemperature

func (t *MPU6050) ReadTemperature() (tempC float64, err error)

func (*MPU6050) SetAccelRange

func (t *MPU6050) SetAccelRange(r MPU6050AccelRange) (err error)

func (*MPU6050) SetGyroRange

func (t *MPU6050) SetGyroRange(r MPU6050GyroRange) (err error)

type MPU6050AccelRange

type MPU6050AccelRange uint16
const (
	MPU6050AccelRange2G  MPU6050AccelRange = 0x00
	MPU6050AccelRange4G  MPU6050AccelRange = 0x08
	MPU6050AccelRange8G  MPU6050AccelRange = 0x10
	MPU6050AccelRange16G MPU6050AccelRange = 0x18
)

type MPU6050GyroRange

type MPU6050GyroRange uint16
const (
	MPU6050GyroRange250Deg  MPU6050GyroRange = 0x00
	MPU6050GyroRange500Deg  MPU6050GyroRange = 0x08
	MPU6050GyroRange1000Deg MPU6050GyroRange = 0x10
	MPU6050GyroRange2000Deg MPU6050GyroRange = 0x18
)

type MS5637

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

func NewMS5637

func NewMS5637(addr uint8, bus int) (p *MS5637, err error)

func (*MS5637) Close

func (p *MS5637) Close()

func (*MS5637) Read

func (p *MS5637) Read() (pressure float64, temperature float64, err error)

func (*MS5637) ReadEEPROMCoeffs

func (p *MS5637) ReadEEPROMCoeffs() (coeffs []uint16, err error)

func (*MS5637) SetResolution

func (p *MS5637) SetResolution(res byte)

type MS5637ADCParams

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

type Potentiometer added in v1.0.4

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

func NewPotentiometer added in v1.0.4

func NewPotentiometer(addr uint8, bus int) (s *Potentiometer, err error)

func (*Potentiometer) Close added in v1.0.4

func (s *Potentiometer) Close()

Close closes the handle to the device

func (*Potentiometer) GetLED added in v1.0.4

func (s *Potentiometer) GetLED() (v uint8, err error)

func (*Potentiometer) GetType added in v1.0.4

func (s *Potentiometer) GetType() int

func (*Potentiometer) ReadFirmwareVersion added in v1.0.4

func (s *Potentiometer) ReadFirmwareVersion() (major uint8, minor uint8, err error)

Returns the firmware version

func (*Potentiometer) ReadRawValue added in v1.0.4

func (s *Potentiometer) ReadRawValue() (v uint16, err error)

Returns a value from 0 to 1023 as the raw value from the potentiometer

func (*Potentiometer) ReadValue added in v1.0.4

func (s *Potentiometer) ReadValue() (v float64, err error)

Returns a value from s.minimum to s.maximum from the potentiometer

func (*Potentiometer) SelfTest added in v1.0.4

func (s *Potentiometer) SelfTest() (v uint8, err error)

func (*Potentiometer) SetLED added in v1.0.4

func (s *Potentiometer) SetLED(enable bool) (err error)

func (*Potentiometer) SetMaximum added in v1.0.4

func (s *Potentiometer) SetMaximum(maximum float64)

func (*Potentiometer) SetMinimum added in v1.0.4

func (s *Potentiometer) SetMinimum(minimum float64)

type QwiicPIR added in v1.0.3

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

func NewQwiicPIR added in v1.0.3

func NewQwiicPIR(addr uint8, bus int) (p *QwiicPIR, err error)

NewQwiicPIR creates a new QwiicPIR instances

func (*QwiicPIR) ClearEventBits added in v1.0.3

func (p *QwiicPIR) ClearEventBits() (err error)

ClearEventBits clears the raw object detected, object removed and event available bits

func (*QwiicPIR) Close added in v1.0.3

func (p *QwiicPIR) Close()

Close cleans up the connection for the QwiicPIR instances

func (*QwiicPIR) GetDebounceEvents added in v1.0.3

func (p *QwiicPIR) GetDebounceEvents() (available bool, detected bool, removed bool, err error)

GetDebounceEvents gets the availability of the event, if it is detected or removed and clears the bits after reading

func (*QwiicPIR) GetDebounceTime added in v1.0.3

func (p *QwiicPIR) GetDebounceTime() (debounceTime uint16, err error)

GetDebounceTime returns the debounce time in milliseconds

func (*QwiicPIR) GetDeviceID added in v1.0.3

func (p *QwiicPIR) GetDeviceID() (id byte, err error)

GetDeviceID gets the device ID of the QwiicPIR (should be 0x72)

func (*QwiicPIR) GetFirmwareVersion added in v1.0.3

func (p *QwiicPIR) GetFirmwareVersion() (ver [2]byte, err error)

GetFirmwareVersion gets the firmware version of the QwiicPIR (currently 1.1)

func (*QwiicPIR) GetRawReading added in v1.0.3

func (p *QwiicPIR) GetRawReading() (detected bool, err error)

GetRawReading detected flag returns true if the PIR has detected an object, otherwise false

func (*QwiicPIR) IsAvailable added in v1.0.3

func (p *QwiicPIR) IsAvailable() (available bool, err error)

IsAvailable available flag returns true if the PIR has either a detected or a removal event

func (*QwiicPIR) IsDetectedQueueEmpty added in v1.0.3

func (p *QwiicPIR) IsDetectedQueueEmpty() (empty bool, err error)

IsDetectedQueueEmpty checks in the detect queue is empty

func (*QwiicPIR) IsDetectedQueueFull added in v1.0.3

func (p *QwiicPIR) IsDetectedQueueFull() (full bool, err error)

IsDetectedQueueFull checks in the detect queue is full

func (*QwiicPIR) IsObjectDetected added in v1.0.3

func (p *QwiicPIR) IsObjectDetected() (detected bool, err error)

IsObjectDetected detected flag returns true if the PIR has detected an object after debouncing, otherwise false

func (*QwiicPIR) IsRemovedQueueEmpty added in v1.0.3

func (p *QwiicPIR) IsRemovedQueueEmpty() (empty bool, err error)

IsRemovedQueueEmpty checks in the detect queue is empty

func (*QwiicPIR) IsRemovedQueueFull added in v1.0.3

func (p *QwiicPIR) IsRemovedQueueFull() (full bool, err error)

IsRemovedQueueFull checks in the detect queue is full

func (*QwiicPIR) IstObjectRemoved added in v1.0.3

func (p *QwiicPIR) IstObjectRemoved() (removed bool, err error)

IstObjectRemoved removed flag returns true if the PIR has detected the removal of an object after debouncing, otherwise false

func (*QwiicPIR) PopDetectedQueue added in v1.0.3

func (p *QwiicPIR) PopDetectedQueue() (firstDetect uint32, err error)

PopDetectedQueue returns the oldest value in the detected queue in milliseconds and then removes it

func (*QwiicPIR) PopRemoveQueue added in v1.0.3

func (p *QwiicPIR) PopRemoveQueue() (firstDetect uint32, err error)

PopRemoveQueue returns the oldest value in the remove queue in milliseconds and then removes it

func (*QwiicPIR) SetDebounceTime added in v1.0.3

func (p *QwiicPIR) SetDebounceTime(debounceTime uint16) (err error)

SetDebounceTime the time in milliseconds to set the debounce time in

func (*QwiicPIR) TimeSinceFirstDetect added in v1.0.3

func (p *QwiicPIR) TimeSinceFirstDetect() (firstDetect uint32, err error)

TimeSinceFirstDetect number of milliseconds since the first detect event

func (*QwiicPIR) TimeSinceFirstRemove added in v1.0.3

func (p *QwiicPIR) TimeSinceFirstRemove() (firstDetect uint32, err error)

TimeSinceFirstRemove number of milliseconds since the first remove event

func (*QwiicPIR) TimeSinceLasRemove added in v1.0.3

func (p *QwiicPIR) TimeSinceLasRemove() (lastDetect uint32, err error)

TimeSinceLasRemove number of milliseconds since the last remove event

func (*QwiicPIR) TimeSinceLastDetect added in v1.0.3

func (p *QwiicPIR) TimeSinceLastDetect() (lastDetect uint32, err error)

TimeSinceLastDetect number of milliseconds since the last detect event

type RGBLED added in v1.0.3

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

func NewRGBLED added in v1.0.3

func NewRGBLED(addr uint8, bus int) (l *RGBLED, err error)

NewRGBLED creates a new RGB LED instances

func (*RGBLED) Clear added in v1.0.3

func (l *RGBLED) Clear() (err error)

Clear turns off all the LEDs

func (*RGBLED) ClearPixels added in v1.0.3

func (l *RGBLED) ClearPixels()

ClearPixels sets all the pixel values to off. Note that Show() needs to be called to update the LEDs.

func (*RGBLED) Close added in v1.0.3

func (l *RGBLED) Close()

Close cleans up the connection for the RGB LED instances

func (*RGBLED) EnablePowerLED added in v1.0.3

func (l *RGBLED) EnablePowerLED(state bool) (err error)

EnablePowerLED sets the state of the green power LED to on or off depending on the state passed in

func (*RGBLED) FillPixels added in v1.0.3

func (l *RGBLED) FillPixels(red, green, blue byte)

FillPixels sets all the pixel colors to red, green and blue levels which are each from 0 being least bright to 255 being most bright for that color. Note that Show() needs to be called to update the LEDs.

func (*RGBLED) GetDeviceID added in v1.0.3

func (l *RGBLED) GetDeviceID() (id byte, err error)

GetDeviceID gets the device ID of the RGB LED device: REVISIT - currently failing

func (*RGBLED) GetFirmwareVersion added in v1.0.3

func (l *RGBLED) GetFirmwareVersion() (ver uint16, err error)

GetFirmwareVersion gets the firmware version of the RGB LED device: REVISIT - currently failing

func (*RGBLED) SetBrightness added in v1.0.3

func (l *RGBLED) SetBrightness(b byte) (err error)

SetBrightness sets the brightness of all LEDs to a level from 0 being least bright to 255 being most bright

func (*RGBLED) SetPixel added in v1.0.3

func (l *RGBLED) SetPixel(num int, red, green, blue byte)

SetPixel sets an individual pixel color to a red, green and blue level which are each from 0 being least bright to 255 being most bright for that color. Note that Show() needs to be called to update the LEDs.

func (*RGBLED) Show added in v1.0.3

func (l *RGBLED) Show() (err error)

Show sets the three LEDs to the colors described by the Pixel functions

type Switch added in v1.0.4

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

func NewSwitch added in v1.0.4

func NewSwitch(addr uint8, bus int) (s *Switch, err error)

func (*Switch) Close added in v1.0.4

func (s *Switch) Close()

Close closes the handle to the device

func (*Switch) GetDebounceEMAParameters added in v1.0.4

func (s *Switch) GetDebounceEMAParameters() (parameter uint8, period uint8, err error)

Get the exponential moving average (EMA) parameters for the switch debounce (default parameter is 63 and period is 20)

func (*Switch) GetDoublePressDuration added in v1.0.4

func (s *Switch) GetDoublePressDuration() (duration uint16, err error)

If the button is pressed twice within this period (ms) a double-press will be registered (default duration is 300)

func (*Switch) GetLED added in v1.0.4

func (s *Switch) GetLED() (v uint8, err error)

func (*Switch) GetPressCount added in v1.0.4

func (s *Switch) GetPressCount() (count int, err error)

func (*Switch) IsPressed added in v1.0.4

func (s *Switch) IsPressed() (pressed bool, err error)

func (*Switch) ReadFirmwareVersion added in v1.0.4

func (s *Switch) ReadFirmwareVersion() (major uint8, minor uint8, err error)

Returns the firmware version

func (*Switch) SetDebounceEMAParameters added in v1.0.4

func (s *Switch) SetDebounceEMAParameters(parameter uint8, period uint8) (err error)

Set the exponential moving average (EMA) parameters for the switch debounce

func (*Switch) SetDoublePressDuration added in v1.0.4

func (s *Switch) SetDoublePressDuration(duration uint16) (err error)

If the button is pressed twice within this period (ms) a double-press will be registered

func (*Switch) SetLED added in v1.0.4

func (s *Switch) SetLED(enable bool) (err error)

func (*Switch) WasDoublePressed added in v1.0.4

func (s *Switch) WasDoublePressed() (doublePressed bool, err error)

Was pressed twice within the double-press duration

func (*Switch) WasPressed added in v1.0.4

func (s *Switch) WasPressed() (pressed bool, err error)

type TMP117

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

func NewTMP117

func NewTMP117(addr uint8, bus int) (t *TMP117, err error)

func (*TMP117) Close

func (t *TMP117) Close()

func (*TMP117) ReadTempC

func (t *TMP117) ReadTempC() (tempC float64, err error)

func (*TMP117) ReadTempF

func (t *TMP117) ReadTempF() (tempF float64, err error)

func (*TMP117) ReadTempK

func (t *TMP117) ReadTempK() (tempK float64, err error)

type VEML6030

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

func NewVEML6030

func NewVEML6030(addr uint8, bus int) (l *VEML6030, err error)

func (*VEML6030) Close

func (l *VEML6030) Close()

Close closes the handle to the device

func (*VEML6030) DisablePowerSave added in v1.0.1

func (l *VEML6030) DisablePowerSave() (err error)

func (*VEML6030) EnablePowerSave added in v1.0.1

func (l *VEML6030) EnablePowerSave() (err error)

func (*VEML6030) GetGainRaw added in v1.0.1

func (l *VEML6030) GetGainRaw() (gain VEML6030Gain, err error)

GetGainRaw reads the raw gain setting from: Configuration register bits 12:11

func (*VEML6030) GetGainValue added in v1.0.1

func (l *VEML6030) GetGainValue() (gain float64, err error)

GetGain reads the sensor gain

func (*VEML6030) GetIntegrationTimeRaw added in v1.0.1

func (l *VEML6030) GetIntegrationTimeRaw() (integTime VEML6030IntegrationTime, err error)

GetIntegrationTimeRaw reads the raw integration time setting from: Configuration register bits 9:6

func (*VEML6030) GetIntegrationTimeValue added in v1.0.1

func (l *VEML6030) GetIntegrationTimeValue() (integTime uint16, err error)

GetIntegrationTime reads the integration time in ms

func (*VEML6030) GetPowerSave added in v1.0.1

func (l *VEML6030) GetPowerSave() (enabled bool, err error)

GetPowerSave reads the current power save state

func (*VEML6030) PowerOn added in v1.0.1

func (l *VEML6030) PowerOn() (err error)

func (*VEML6030) Read

func (l *VEML6030) Read() (light float64, err error)

Read samples the raw light level and converts to a lux value

func (*VEML6030) SetGain added in v1.0.1

func (l *VEML6030) SetGain(gain VEML6030Gain) (err error)

SetGain sets the gain

func (*VEML6030) SetIntegrationTime added in v1.0.1

func (l *VEML6030) SetIntegrationTime(integTime VEML6030IntegrationTime) (err error)

SetIntegrationTime sets the integration time

func (*VEML6030) Shutdown added in v1.0.1

func (l *VEML6030) Shutdown() (err error)

type VEML6030Gain added in v1.0.1

type VEML6030Gain uint16
const (
	VEML6030GainOneEighth  VEML6030Gain = 2
	VEML6030GainOneQuarter VEML6030Gain = 3
	VEML6030GainOne        VEML6030Gain = 0
	VEML6030GainTwo        VEML6030Gain = 1
)

type VEML6030IntegrationTime added in v1.0.1

type VEML6030IntegrationTime uint16
const (
	VEML6030IntegrationTime25  VEML6030IntegrationTime = 12
	VEML6030IntegrationTime50  VEML6030IntegrationTime = 8
	VEML6030IntegrationTime100 VEML6030IntegrationTime = 0
	VEML6030IntegrationTime200 VEML6030IntegrationTime = 1
	VEML6030IntegrationTime400 VEML6030IntegrationTime = 2
	VEML6030IntegrationTime800 VEML6030IntegrationTime = 3
)

type VEML6040 added in v1.0.3

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

func NewVEML6040 added in v1.0.3

func NewVEML6040(addr uint8, bus int) (c *VEML6040, err error)

NewVEML6040 creates a new VEML6040 instances

func (*VEML6040) Close added in v1.0.3

func (c *VEML6040) Close()

Close cleans up the connection for the VEML6040 instances

func (*VEML6040) ReadRGBW added in v1.0.3

func (c *VEML6040) ReadRGBW() (red, green, blue, white uint16, err error)

ReadRGB gets the red, green and blue values from the sensor

type VL53L1X

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

func NewVL53L1X

func NewVL53L1X(addr uint8, bus int) (d *VL53L1X, err error)

func (*VL53L1X) Close

func (d *VL53L1X) Close()

func (*VL53L1X) Read

func (d *VL53L1X) Read() (rng uint16, err error)

func (*VL53L1X) ReadModelID

func (d *VL53L1X) ReadModelID() (modelID uint16, err error)

func (*VL53L1X) Reset

func (d *VL53L1X) Reset() (err error)

Jump to

Keyboard shortcuts

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