i2c

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2024 License: Apache-2.0, Apache-2.0 Imports: 17 Imported by: 1

README

I2C

This package provides drivers for i2cdevices. It must be used along with an adaptor such as Tinker Board that supports the needed interfaces for i2c devices.

Getting Started

Please refer to the main README.md

Hardware Support

Gobot has a extensible system for connecting to hardware devices. The following i2c devices are currently supported:

  • Adafruit 1109 2x16 RGB-LCD with 5 keys
  • Adafruit 2327 16-Channel PWM/Servo HAT Hat
  • Adafruit 2348 DC and Stepper Motor Hat
  • ADS1015 Analog to Digital Converter
  • ADS1115 Analog to Digital Converter
  • ADXL345 Digital Accelerometer
  • BH1750 Digital Luminosity/Lux/Light Sensor
  • BlinkM LED
  • BME280 Barometric Pressure/Temperature/Altitude/Humidity Sensor
  • BMP180 Barometric Pressure/Temperature/Altitude Sensor
  • BMP280 Barometric Pressure/Temperature/Altitude Sensor
  • BMP388 Barometric Pressure/Temperature/Altitude Sensor
  • DRV2605L Haptic Controller
  • Generic driver for read and write values to/from register address
  • Grove Digital Accelerometer
  • GrovePi Expansion Board
  • Grove RGB LCD
  • HMC6352 Compass
  • HMC5883L 3-Axis Digital Compass
  • INA3221 Voltage Monitor
  • JHD1313M1 LCD Display w/RGB Backlight
  • L3GD20H 3-Axis Gyroscope
  • LIDAR-Lite
  • MCP23017 Port Expander
  • MMA7660 3-Axis Accelerometer
  • MPL115A2 Barometric Pressure/Temperature
  • MPU6050 Accelerometer/Gyroscope
  • PCA9501 8-bit I/O port with interrupt, 2-kbit EEPROM
  • PCA953x LED Dimmer for PCA9530 (2-bit), PCA9533 (4-bit), PCA9531 (8-bit), PCA9532 (16-bit)
  • PCA9685 16-channel 12-bit PWM/Servo Driver
  • PCF8583 clock and calendar or event counter, 240 x 8-bit RAM
  • PCF8591 8-bit 4xA/D & 1xD/A converter
  • SHT2x Temperature/Humidity
  • SHT3x-D Temperature/Humidity
  • SSD1306 OLED Display Controller
  • TSL2561 Digital Luminosity/Lux/Light Sensor
  • Wii Nunchuck Controller
  • YL-40 Brightness/Temperature sensor, Potentiometer, analog input, analog output Driver

More drivers are coming soon...

Using A Different Bus or Address

You can set a different I2C address or I2C bus than the default when initializing your I2C drivers by using optional parameters. Here is an example:

blinkm := i2c.NewBlinkMDriver(e, i2c.WithBus(0), i2c.WithAddress(0x09))

Documentation

Overview

Package i2c provides Gobot drivers for i2c devices.

Installing:

Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)

For further information refer to i2c README: https://github.com/hybridgroup/gobot/blob/master/drivers/i2c/README.md

Index

Constants

View Source
const (
	ADXL345Rate_100mHZ   ADXL345RateConfig = 0x00 // 0.10 Hz
	ADXL345Rate_200mHZ   ADXL345RateConfig = 0x01 // 0.20 Hz
	ADXL345Rate_390mHZ   ADXL345RateConfig = 0x02 // 0.39 Hz
	ADXL345Rate_780mHZ   ADXL345RateConfig = 0x03 // 0.78 Hz
	ADXL345Rate_1560mHZ  ADXL345RateConfig = 0x04 // 1.56 Hz
	ADXL345Rate_3130mHZ  ADXL345RateConfig = 0x05 // 3.13 Hz
	ADXL345Rate_6250mHZ  ADXL345RateConfig = 0x06 // 6.25 Hz
	ADXL345Rate_12500mHZ ADXL345RateConfig = 0x07 // 12.5 Hz
	ADXL345Rate_25HZ     ADXL345RateConfig = 0x08 // 25 Hz
	ADXL345Rate_50HZ     ADXL345RateConfig = 0x09 // 50 Hz
	ADXL345Rate_100HZ    ADXL345RateConfig = 0x0A // 100 Hz
	ADXL345Rate_200HZ    ADXL345RateConfig = 0x0B // 200 Hz
	ADXL345Rate_400HZ    ADXL345RateConfig = 0x0C // 400 Hz
	ADXL345Rate_800HZ    ADXL345RateConfig = 0x0D // 800 Hz
	ADXL345Rate_1600HZ   ADXL345RateConfig = 0x0E // 1600 Hz
	ADXL345Rate_3200HZ   ADXL345RateConfig = 0x0F // 3200 Hz

	ADXL345FsRange_2G  ADXL345FsRangeConfig = 0x00 // +-2 g
	ADXL345FsRange_4G  ADXL345FsRangeConfig = 0x01 // +-4 g
	ADXL345FsRange_8G  ADXL345FsRangeConfig = 0x02 // +-8 g
	ADXL345FsRange_16G ADXL345FsRangeConfig = 0x03 // +-16 g)
)
View Source
const (
	BH1750_POWER_DOWN                 = 0x00
	BH1750_POWER_ON                   = 0x01
	BH1750_RESET                      = 0x07
	BH1750_CONTINUOUS_HIGH_RES_MODE   = 0x10
	BH1750_CONTINUOUS_HIGH_RES_MODE_2 = 0x11
	BH1750_CONTINUOUS_LOW_RES_MODE    = 0x13
	BH1750_ONE_TIME_HIGH_RES_MODE     = 0x20
	BH1750_ONE_TIME_HIGH_RES_MODE_2   = 0x21
	BH1750_ONE_TIME_LOW_RES_MODE      = 0x23
)
View Source
const (

	// bits 2, 3, 4 of control register (will be shifted on write)
	BMP280CtrlPressNoMeasurement  BMP280PressureOversampling = 0x00 // no measurement (value will be 0x08 0x00 0x00)
	BMP280CtrlPressOversampling1  BMP280PressureOversampling = 0x01 // resolution 16 bit
	BMP280CtrlPressOversampling2  BMP280PressureOversampling = 0x02 // resolution 17 bit
	BMP280CtrlPressOversampling4  BMP280PressureOversampling = 0x03 // resolution 18 bit
	BMP280CtrlPressOversampling8  BMP280PressureOversampling = 0x04 // resolution 19 bit
	BMP280CtrlPressOversampling16 BMP280PressureOversampling = 0x05 // resolution 20 bit (same as 0x06, 0x07)

	// bits 5, 6, 7 of control register (will be shifted on write)
	BMP280CtrlTempNoMeasurement  BMP280TemperatureOversampling = 0x00 // no measurement (value will be 0x08 0x00 0x00)
	BMP280CtrlTempOversampling1  BMP280TemperatureOversampling = 0x01 // resolution 16 bit
	BMP280CtrlTempOversampling2  BMP280TemperatureOversampling = 0x02 // resolution 17 bit
	BMP280CtrlTempOversampling4  BMP280TemperatureOversampling = 0x03 // resolution 18 bit
	BMP280CtrlTempOversampling8  BMP280TemperatureOversampling = 0x04 // resolution 19 bit
	BMP280CtrlTempOversampling16 BMP280TemperatureOversampling = 0x05 // resolution 20 bit

	// bits 5, 6, 7 of config register
	BMP280ConfFilterOff BMP280IIRFilter = 0x00
	BMP280ConfFilter2   BMP280IIRFilter = 0x01
	BMP280ConfFilter4   BMP280IIRFilter = 0x02
	BMP280ConfFilter8   BMP280IIRFilter = 0x03
	BMP280ConfFilter16  BMP280IIRFilter = 0x04
)
View Source
const (
	// BusNotInitialized is the initial value for a bus
	BusNotInitialized = -1

	// AddressNotInitialized is the initial value for an address
	AddressNotInitialized = -1
)
View Source
const (
	REG_RED   = 0x04
	REG_GREEN = 0x03
	REG_BLUE  = 0x02

	LCD_CLEARDISPLAY        = 0x01
	LCD_RETURNHOME          = 0x02
	LCD_ENTRYMODESET        = 0x04
	LCD_DISPLAYCONTROL      = 0x08
	LCD_CURSORSHIFT         = 0x10
	LCD_FUNCTIONSET         = 0x20
	LCD_SETCGRAMADDR        = 0x40
	LCD_SETDDRAMADDR        = 0x80
	LCD_ENTRYRIGHT          = 0x00
	LCD_ENTRYLEFT           = 0x02
	LCD_ENTRYSHIFTINCREMENT = 0x01
	LCD_ENTRYSHIFTDECREMENT = 0x00
	LCD_DISPLAYON           = 0x04
	LCD_DISPLAYOFF          = 0x00
	LCD_CURSORON            = 0x02
	LCD_CURSOROFF           = 0x00
	LCD_BLINKON             = 0x01
	LCD_BLINKOFF            = 0x00
	LCD_DISPLAYMOVE         = 0x08
	LCD_CURSORMOVE          = 0x00
	LCD_MOVERIGHT           = 0x04
	LCD_MOVELEFT            = 0x00
	LCD_2LINE               = 0x08
	LCD_CMD                 = 0x80
	LCD_DATA                = 0x40

	LCD_2NDLINEOFFSET = 0x40
)
View Source
const (
	MMA7660_X              = 0x00
	MMA7660_Y              = 0x01
	MMA7660_Z              = 0x02
	MMA7660_TILT           = 0x03
	MMA7660_SRST           = 0x04
	MMA7660_SPCNT          = 0x05
	MMA7660_INTSU          = 0x06
	MMA7660_MODE           = 0x07
	MMA7660_STAND_BY       = 0x00
	MMA7660_ACTIVE         = 0x01
	MMA7660_SR             = 0x08
	MMA7660_AUTO_SLEEP_120 = 0x00
	MMA7660_AUTO_SLEEP_64  = 0x01
	MMA7660_AUTO_SLEEP_32  = 0x02
	MMA7660_AUTO_SLEEP_16  = 0x03
	MMA7660_AUTO_SLEEP_8   = 0x04
	MMA7660_AUTO_SLEEP_4   = 0x05
	MMA7660_AUTO_SLEEP_2   = 0x06
	MMA7660_AUTO_SLEEP_1   = 0x07
	MMA7660_PDET           = 0x09
	MMA7660_PD             = 0x0A
)
View Source
const (
	MPU6050General_Dlpf260Hz MPU6050DlpfConfig = 0x00
	MPU6050General_Dlpf184Hz MPU6050DlpfConfig = 0x01
	MPU6050General_Dlpf94Hz  MPU6050DlpfConfig = 0x02
	MPU6050General_Dlpf44Hz  MPU6050DlpfConfig = 0x03
	MPU6050General_Dlpf21Hz  MPU6050DlpfConfig = 0x04
	MPU6050General_Dlpf10Hz  MPU6050DlpfConfig = 0x05
	MPU6050General_Dlpf5Hz   MPU6050DlpfConfig = 0x06

	MPU6050General_FrameSyncDisabled MPU6050FrameSyncConfig = 0x00
	MPU6050General_FrameSyncTemp     MPU6050FrameSyncConfig = 0x01
	MPU6050General_FrameSyncGyroX    MPU6050FrameSyncConfig = 0x02
	MPU6050General_FrameSyncGyroY    MPU6050FrameSyncConfig = 0x03
	MPU6050General_FrameSyncGyroZ    MPU6050FrameSyncConfig = 0x04
	MPU6050General_FrameSyncAccelX   MPU6050FrameSyncConfig = 0x05
	MPU6050General_FrameSyncAccelY   MPU6050FrameSyncConfig = 0x06
	MPU6050General_FrameSyncAccelZ   MPU6050FrameSyncConfig = 0x07

	MPU6050Gyro_FsSel250dps  MPU6050GyroFsConfig = 0x00 // +/- 250 °/s
	MPU6050Gyro_FsSel500dps  MPU6050GyroFsConfig = 0x01 // +/- 500 °/s
	MPU6050Gyro_FsSel1000dps MPU6050GyroFsConfig = 0x02 // +/- 1000 °/s
	MPU6050Gyro_FsSel2000dps MPU6050GyroFsConfig = 0x03 // +/- 2000 °/s

	MPU6050Accel_AFsSel2g  MPU6050AccelFsConfig = 0x00 // +/- 2 g
	MPU6050Accel_AFsSel4g  MPU6050AccelFsConfig = 0x01 // +/- 4 g
	MPU6050Accel_AFsSel8g  MPU6050AccelFsConfig = 0x02 // +/- 8 g
	MPU6050Accel_AFsSel16g MPU6050AccelFsConfig = 0x03 // +/- 16 g

	MPU6050Pwr1_ClockIntern8G  MPU6050Pwr1ClockConfig = 0x00 // internal 8GHz
	MPU6050Pwr1_ClockPllXGyro  MPU6050Pwr1ClockConfig = 0x01 // PLL with X axis gyroscope reference
	MPU6050Pwr1_ClockPllYGyro  MPU6050Pwr1ClockConfig = 0x02 // PLL with Y axis gyroscope reference
	MPU6050Pwr1_ClockPllZGyro  MPU6050Pwr1ClockConfig = 0x03 // PLL with Z axis gyroscope reference
	MPU6050Pwr1_ClockPllExt32K MPU6050Pwr1ClockConfig = 0x04 // PLL with external 32.768kHz reference
	MPU6050Pwr1_ClockPllExt19M MPU6050Pwr1ClockConfig = 0x05 // PLL with external 19.2MHz reference
	MPU6050Pwr1_ClockStop      MPU6050Pwr1ClockConfig = 0x07 // Stops the clock and keeps the timing generator in reset

)
View Source
const (
	// SHT2xAccuracyLow is the faster, but lower accuracy sample setting
	//  0/1 = 8bit RH, 12bit Temp
	SHT2xAccuracyLow = byte(0x01)

	// SHT2xAccuracyMedium is the medium accuracy and speed sample setting
	//  1/0 = 10bit RH, 13bit Temp
	SHT2xAccuracyMedium = byte(0x80)

	// SHT2xAccuracyHigh is the high accuracy and slowest sample setting
	//  0/0 = 12bit RH, 14bit Temp
	//  Power on default is 0/0
	SHT2xAccuracyHigh = byte(0x00)

	// SHT2xTriggerTempMeasureHold is the command for measureing temperature in hold master mode
	SHT2xTriggerTempMeasureHold = 0xe3

	// SHT2xTriggerHumdMeasureHold is the command for measureing humidity in hold master mode
	SHT2xTriggerHumdMeasureHold = 0xe5

	// SHT2xTriggerTempMeasureNohold is the command for measureing humidity in no hold master mode
	SHT2xTriggerTempMeasureNohold = 0xf3

	// SHT2xTriggerHumdMeasureNohold is the command for measureing humidity in no hold master mode
	SHT2xTriggerHumdMeasureNohold = 0xf5

	// SHT2xWriteUserReg is the command for writing user register
	SHT2xWriteUserReg = 0xe6

	// SHT2xReadUserReg is the command for reading user register
	SHT2xReadUserReg = 0xe7

	// SHT2xReadUserReg is the command for reading user register
	SHT2xSoftReset = 0xfe
)
View Source
const (
	TH02HighAccuracy = 0 // High Accuracy (T: 14 bit, H: 12 bit), normal (35 ms)
	TH02LowAccuracy  = 1 // Lower Accuracy (T: 13 bit, H: 11 bit), fast (18 ms)
)

Accuracy constants for the TH02 devices (deprecated, use WithFastMode() instead)

View Source
const (
	// TSL2561AddressLow - the address of the device when address pin is low
	TSL2561AddressLow = 0x29
	// TSL2561AddressFloat - the address of the device when address pin is floating
	TSL2561AddressFloat = 0x39
	// TSL2561AddressHigh - the address of the device when address pin is high
	TSL2561AddressHigh = 0x49
)
View Source
const (
	// Joystick event when the Wiichuck joystick is moved
	Joystick = "joystick"

	// C event when the Wiichuck "C" button is pressed
	C = "c"

	// Z event when the Wiichuck "C" button is pressed
	Z = "z"
)
View Source
const (
	ADXL345AddressPullUp = 0x1D // can be used by WithAddress()

)

ADXL345 supports 2 addresses, which can be changed by the address pin, there is no internal pull-up/down resistor! pin to GND: 0x53, pin to VDD: 0x1D

View Source
const (
	// Error event
	Error = "error"
)
View Source
const SHT3xAccuracyHigh = 0x00

SHT3xAccuracyHigh is the high accuracy and slowest sample setting

View Source
const SHT3xAccuracyLow = 0x16

SHT3xAccuracyLow is the faster, but lower accuracy sample setting

View Source
const SHT3xAccuracyMedium = 0x0b

SHT3xAccuracyMedium is the medium accuracy and speed sample setting

View Source
const SHT3xAddressA = 0x44

SHT3xAddressA is the default address of device

View Source
const SHT3xAddressB = 0x45

SHT3xAddressB is the optional address of device

Variables

View Source
var (
	// ErrNotEnoughBytes is used when the count of read bytes was too small
	ErrNotEnoughBytes = fmt.Errorf("Not enough bytes read")
	// ErrNotReady is used when the device is not ready
	ErrNotReady = fmt.Errorf("Device is not ready")
)
View Source
var (
	ErrInvalidAccuracy = errors.New("Invalid accuracy")
	ErrInvalidCrc      = errors.New("Invalid crc")
	ErrInvalidTemp     = errors.New("Invalid temperature units")
)
View Source
var CustomLCDChars = map[string][8]byte{
	"é":       {130, 132, 142, 145, 159, 144, 142, 128},
	"è":       {136, 132, 142, 145, 159, 144, 142, 128},
	"ê":       {132, 138, 142, 145, 159, 144, 142, 128},
	"à":       {136, 134, 128, 142, 145, 147, 141, 128},
	"â":       {132, 138, 128, 142, 145, 147, 141, 128},
	"á":       {2, 4, 14, 1, 15, 17, 15, 0},
	"î":       {132, 138, 128, 140, 132, 132, 142, 128},
	"í":       {2, 4, 12, 4, 4, 4, 14, 0},
	"û":       {132, 138, 128, 145, 145, 147, 141, 128},
	"ù":       {136, 134, 128, 145, 145, 147, 141, 128},
	"ñ":       {14, 0, 22, 25, 17, 17, 17, 0},
	"ó":       {2, 4, 14, 17, 17, 17, 14, 0},
	"heart":   {0, 10, 31, 31, 31, 14, 4, 0},
	"smiley":  {0, 0, 10, 0, 0, 17, 14, 0},
	"frowney": {0, 0, 10, 0, 0, 0, 14, 17},
}

CustomLCDChars is a map of CGRAM characters that can be loaded into a LCD screen to display custom characters. Some LCD screens such as the Grove screen (jhd1313m1) isn't loaded with latin 1 characters. It's up to the developer to load the set up to 8 custom characters and update the input text so the character is swapped by a byte reflecting the position of the custom character to use. See SetCustomChar

Functions

func NewConnection

func NewConnection(bus gobot.I2cSystemDevicer, address int) *i2cConnection

NewConnection creates and returns a new connection to a specific i2c device on a bus and address.

func PCF8591ParseModeChan

func PCF8591ParseModeChan(description string) (*pcf8591ModeChan, error)

PCF8591ParseModeChan is used to get a working combination between mode (single, mixed, 2 differential, 3 differential) and the related channel to read from, parsed from the given description string.

func WithADS1x15BestGainForVoltage

func WithADS1x15BestGainForVoltage(voltage float64) func(Config)

WithADS1x15BestGainForVoltage option sets the ADS1x15Driver best gain for all channels.

func WithADS1x15ChannelBestGainForVoltage

func WithADS1x15ChannelBestGainForVoltage(channel int, voltage float64) func(Config)

WithADS1x15ChannelBestGainForVoltage option sets the ADS1x15Driver best gain for one channel.

func WithADS1x15ChannelDataRate

func WithADS1x15ChannelDataRate(channel int, val int) func(Config)

WithADS1x15ChannelDataRate option sets the ADS1x15Driver data rate for one channel. Valid gain settings are any of the DR values in SPS.

func WithADS1x15ChannelGain

func WithADS1x15ChannelGain(channel int, val int) func(Config)

WithADS1x15ChannelGain option sets the ADS1x15Driver gain for one channel. Valid gain settings are any of the PGA values (0..7).

func WithADS1x15DataRate

func WithADS1x15DataRate(val int) func(Config)

WithADS1x15DataRate option sets the ADS1x15Driver data rate for all channels. Valid gain settings are any of the DR values in SPS.

func WithADS1x15Gain

func WithADS1x15Gain(val int) func(Config)

WithADS1x15Gain option sets the ADS1x15Driver gain for all channels. Valid gain settings are any of the PGA values (0..7).

func WithADS1x15WaitSingleCycle

func WithADS1x15WaitSingleCycle() func(Config)

WithADS1x15WaitSingleCycle option sets the ADS1x15Driver to wait only a single cycle for conversion. According to the specification, chapter "Output Data Rate and Conversion Time", the device normally finishes the conversion within one cycle (after wake up). The cycle time depends on configured data rate and will be calculated. For unknown reasons some devices do not work with this setting. So the default behavior for single shot mode is to wait for a conversion is finished by reading the configuration register bit 15. Activating this option will switch off this behavior and will possibly create faster response. But, if multiple inputs are used and some inputs calculates the same result, most likely the device is not working with this option.

func WithADXL345DataOutputRate

func WithADXL345DataOutputRate(val ADXL345RateConfig) func(Config)

WithADXL345DataOutputRate option sets the data output rate. Valid settings are of type "ADXL345RateConfig"

func WithADXL345FullScaleRange

func WithADXL345FullScaleRange(val ADXL345FsRangeConfig) func(Config)

WithADXL345FullScaleRange option sets the full scale range. Valid settings are of type "ADXL345FsRangeConfig"

func WithADXL345LowPowerMode

func WithADXL345LowPowerMode(val bool) func(Config)

WithADXL345LowPowerMode option modifies the low power mode.

func WithAddress

func WithAddress(address int) func(Config)

WithAddress sets which address to use as a optional param.

func WithBME280HumidityOversampling

func WithBME280HumidityOversampling(val BME280HumidityOversampling) func(Config)

WithBME280HumidityOversampling option sets the oversampling for humidity. Valid settings are of type "BME280HumidityOversampling"

func WithBME280IIRFilter

func WithBME280IIRFilter(val BMP280IIRFilter) func(Config)

WithBME280IIRFilter option sets the count of IIR filter coefficients. Valid settings are of type "BMP280IIRFilter"

func WithBME280PressureOversampling

func WithBME280PressureOversampling(val BMP280PressureOversampling) func(Config)

WithBME280PressureOversampling option sets the oversampling for pressure. Valid settings are of type "BMP280PressureOversampling"

func WithBME280TemperatureOversampling

func WithBME280TemperatureOversampling(val BMP280TemperatureOversampling) func(Config)

WithBME280TemperatureOversampling option sets oversampling for temperature. Valid settings are of type "BMP280TemperatureOversampling"

func WithBMP180OversamplingMode

func WithBMP180OversamplingMode(val BMP180OversamplingMode) func(Config)

WithBMP180oversampling option sets oversampling mode. Valid settings are of type "BMP180OversamplingMode"

func WithBMP280IIRFilter

func WithBMP280IIRFilter(val BMP280IIRFilter) func(Config)

WithBMP280IIRFilter option sets the count of IIR filter coefficients. Valid settings are of type "BMP280IIRFilter"

func WithBMP280PressureOversampling

func WithBMP280PressureOversampling(val BMP280PressureOversampling) func(Config)

WithBMP280PressureOversampling option sets the oversampling for pressure. Valid settings are of type "BMP280PressureOversampling"

func WithBMP280TemperatureOversampling

func WithBMP280TemperatureOversampling(val BMP280TemperatureOversampling) func(Config)

WithBMP280TemperatureOversampling option sets oversampling for temperature. Valid settings are of type "BMP280TemperatureOversampling"

func WithBMP388IIRFilter

func WithBMP388IIRFilter(val BMP388IIRFilter) func(Config)

WithBMP388IIRFilter option sets count of IIR filter coefficients. Valid settings are of type "BMP388IIRFilter"

func WithBus

func WithBus(bus int) func(Config)

WithBus sets which bus to use as a optional param.

func WithCCS811MeasMode

func WithCCS811MeasMode(mode CCS811DriveMode) func(Config)

WithCCS811MeasMode sets the sampling rate of the device

func WithCCS811NTCResistance

func WithCCS811NTCResistance(val uint32) func(Config)

WithCCS811NTCResistance sets reistor value used in the temperature calculations. This resistor must be placed between pin 4 and pin 8 of the chip

func WithHMC5883LApplyBias

func WithHMC5883LApplyBias(val int) func(Config)

WithHMC5883LApplyBias option sets to apply a measurement bias. Valid settings are -1 (negative bias), 0 (normal), 1 (positive bias).

func WithHMC5883LDataOutputRate

func WithHMC5883LDataOutputRate(val int) func(Config)

WithHMC5883LDataOutputRate option sets the data output rate in mHz. Valid settings are 750, 1500, 3000, 7500, 15000, 30000, 75000.

func WithHMC5883LGain

func WithHMC5883LGain(val int) func(Config)

WithHMC5883LGain option sets the gain. Valid settings are 1370, 1090, 820, 660, 440, 390, 330 230 in 1/Gauss.

func WithHMC5883LSamplesAveraged

func WithHMC5883LSamplesAveraged(val int) func(Config)

WithHMC5883LSamplesAveraged option sets the number of samples averaged per measurement. Valid settings are 1, 2, 4, 8.

func WithL3GD20HFullScaleRange

func WithL3GD20HFullScaleRange(val L3GD20HScale) func(Config)

WithL3GD20HFullScaleRange option sets the full scale range for the gyroscope. Valid settings are of type "L3GD20HScale"

func WithMCP23017AutoIODirOff

func WithMCP23017AutoIODirOff(val uint8) func(Config)

WithMCP23017AutoIODirOff option modifies the MCP23017Driver autoIODirOff option Set IO direction at each read or write operation ensures the correct direction, which is the default setting. Most hardware is configured statically, so this can avoided by setting the direction using SetPinMode(), e.g. in the start up sequence. If this way is taken, the automatic set of direction at each call can be safely deactivated with this flag (set to true, 1). This will speedup each WriteGPIO by 50% and each ReadGPIO by 60%.

func WithMCP23017Bank

func WithMCP23017Bank(val uint8) func(Config)

WithMCP23017Bank option sets the MCP23017Driver bank option

func WithMCP23017Disslw

func WithMCP23017Disslw(val uint8) func(Config)

WithMCP23017Disslw option sets the MCP23017Driver disslw option

func WithMCP23017ForceRefresh

func WithMCP23017ForceRefresh(val uint8) func(Config)

WithMCP23017ForceRefresh option modifies the MCP23017Driver forceRefresh option Setting to true (1) will force refresh operation to register, although there is no change. Normally this is not needed, so default is off (0). When there is something flaky, there is a small chance to stabilize by setting this flag to true. However, setting this flag to true slows down each IO operation up to 100%.

func WithMCP23017Haen

func WithMCP23017Haen(val uint8) func(Config)

WithMCP23017Haen option sets the MCP23017Driver haen option This feature is only available for MCP23S17, because address pins are always enabled on the MCP23017.

func WithMCP23017Intpol

func WithMCP23017Intpol(val uint8) func(Config)

WithMCP23017Intpol option sets the MCP23017Driver intpol option

func WithMCP23017Mirror

func WithMCP23017Mirror(val uint8) func(Config)

WithMCP23017Mirror option sets the MCP23017Driver mirror option

func WithMCP23017Odr

func WithMCP23017Odr(val uint8) func(Config)

WithMCP23017Odr option sets the MCP23017Driver odr option

func WithMCP23017Seqop

func WithMCP23017Seqop(val uint8) func(Config)

WithMCP23017Seqop option sets the MCP23017Driver seqop option

func WithMPU6050AccelFullScaleRange

func WithMPU6050AccelFullScaleRange(val MPU6050AccelFsConfig) func(Config)

WithMPU6050AccelFullScaleRange option sets the full scale range for the accelerometer. Valid settings are of type "MPU6050AccelFsConfig"

func WithMPU6050ClockSource

func WithMPU6050ClockSource(val MPU6050Pwr1ClockConfig) func(Config)

WithMPU6050ClockSource option sets the clock source. Valid settings are of type "MPU6050Pwr1ClockConfig"

func WithMPU6050DigitalFilter

func WithMPU6050DigitalFilter(val MPU6050DlpfConfig) func(Config)

WithMPU6050DigitalFilter option sets the digital low pass filter bandwidth frequency. Valid settings are of type "MPU6050DlpfConfig"

func WithMPU6050FrameSync

func WithMPU6050FrameSync(val MPU6050FrameSyncConfig) func(Config)

WithMPU6050FrameSync option sets the external frame synchronization. Valid settings are of type "MPU6050FrameSyncConfig"

func WithMPU6050Gravity

func WithMPU6050Gravity(val float64) func(Config)

WithMPU6050Gravity option sets the gravity in [m/s²/g]. Useful settings are "1.0" (to use unit "g") or a value between 9.834 (pole) and 9.764 (equator)

func WithMPU6050GyroFullScaleRange

func WithMPU6050GyroFullScaleRange(val MPU6050GyroFsConfig) func(Config)

WithMPU6050GyroFullScaleRange option sets the full scale range for the gyroscope. Valid settings are of type "MPU6050GyroFsConfig"

func WithPCF8583Mode

func WithPCF8583Mode(mode PCF8583Control) func(Config)

WithPCF8583Mode is used to change the mode between 32.678kHz clock, 50Hz clock, event counter Valid settings are of type "PCF8583Control"

func WithPCF8591ForceRefresh

func WithPCF8591ForceRefresh(val uint8) func(Config)

WithPCF8591ForceWrite option modifies the PCF8591Driver forceRefresh option Setting to true (1) will force refresh operation to register, although there is no change. Normally this is not needed, so default is off (0). When there is something flaky, there is a small chance to stabilize by setting this flag to true. However, setting this flag to true slows down each IO operation up to 100%.

func WithPCF8591With400kbitStabilization

func WithPCF8591With400kbitStabilization(additionalReadWrite, additionalRead int) func(Config)

WithPCF8591With400kbitStabilisation option sets the PCF8591 additionalReadWrite and additionalRead value

func WithSSD1306DisplayHeight

func WithSSD1306DisplayHeight(val int) func(Config)

WithSSD1306DisplayHeight option sets the SSD1306Driver DisplayHeight option.

func WithSSD1306DisplayWidth

func WithSSD1306DisplayWidth(val int) func(Config)

WithSSD1306DisplayWidth option sets the SSD1306Driver DisplayWidth option.

func WithSSD1306ExternalVCC

func WithSSD1306ExternalVCC(val bool) func(Config)

WithSSD1306ExternalVCC option sets the SSD1306Driver ExternalVCC option.

func WithTH02FastMode

func WithTH02FastMode(val int) func(Config)

WithTH02FastMode option sets the fast mode (leads to lower accuracy). Valid settings are <=0 (off), >0 (on).

func WithTSL2561AutoGain

func WithTSL2561AutoGain(c Config)

WithTSL2561AutoGain option turns on TSL2561Driver auto gain

func WithTSL2561Gain16X

func WithTSL2561Gain16X(c Config)

WithTSL2561Gain16X option sets the TSL2561Driver gain to 16X

func WithTSL2561Gain1X

func WithTSL2561Gain1X(c Config)

WithTSL2561Gain1X option sets the TSL2561Driver gain to 1X

func WithTSL2561IntegrationTime101MS

func WithTSL2561IntegrationTime101MS(c Config)

WithTSL2561IntegrationTime101MS option sets the TSL2561Driver integration time to 101ms

func WithTSL2561IntegrationTime13MS

func WithTSL2561IntegrationTime13MS(c Config)

WithTSL2561IntegrationTime13MS option sets the TSL2561Driver integration time to 13ms

func WithTSL2561IntegrationTime402MS

func WithTSL2561IntegrationTime402MS(c Config)

WithTSL2561IntegrationTime402MS option sets the TSL2561Driver integration time to 402ms

func WithYL40InputScaler

func WithYL40InputScaler(pin YL40Pin, scaler func(input int) (value float64)) func(Config)

WithYL40InputScaler option sets the input scaler of given input pin in YL40 driver

func WithYL40Interval

func WithYL40Interval(pin YL40Pin, val time.Duration) func(Config)

WithYL40Interval option sets the interval for refresh of given pin in YL40 driver

func WithYL40OutputScaler

func WithYL40OutputScaler(scaler func(input float64) (value int)) func(Config)

WithYL40OutputScaler option sets the output scaler in YL40 driver

Types

type ADS1x15Driver

type ADS1x15Driver struct {
	*Driver
	// contains filtered or unexported fields
}

ADS1x15Driver is the Gobot driver for the ADS1015/ADS1115 ADC datasheet: https://www.ti.com/lit/gpn/ads1115

reference implementations: * https://github.com/adafruit/Adafruit_Python_ADS1x15 * https://github.com/Wh1teRabbitHU/ADS1115-Driver

func NewADS1015Driver

func NewADS1015Driver(a Connector, options ...func(Config)) *ADS1x15Driver

NewADS1015Driver creates a new driver for the ADS1015 (12-bit ADC)

func NewADS1115Driver

func NewADS1115Driver(a Connector, options ...func(Config)) *ADS1x15Driver

NewADS1115Driver creates a new driver for the ADS1115 (16-bit ADC)

func (*ADS1x15Driver) AnalogRead

func (d *ADS1x15Driver) AnalogRead(pin string) (int, error)

AnalogRead returns value from analog reading of specified pin using the default values.

func (*ADS1x15Driver) Read

func (d *ADS1x15Driver) Read(channel int, gain int, dataRate int) (float64, error)

Read reads the voltage at the specified channel (between 0 and 3). The result is in V.

func (*ADS1x15Driver) ReadDifference

func (d *ADS1x15Driver) ReadDifference(diff int, gain int, dataRate int) (float64, error)

ReadDifference reads the difference in V between 2 inputs. diff can be: * 0: Channel 0 - channel 1 * 1: Channel 0 - channel 3 * 2: Channel 1 - channel 3 * 3: Channel 2 - channel 3

func (*ADS1x15Driver) ReadDifferenceWithDefaults

func (d *ADS1x15Driver) ReadDifferenceWithDefaults(diff int) (float64, error)

ReadDifferenceWithDefaults reads the difference in V between 2 inputs. It uses the default gain and data rate diff can be: * 0: Channel 0 - channel 1 * 1: Channel 0 - channel 3 * 2: Channel 1 - channel 3 * 3: Channel 2 - channel 3

func (*ADS1x15Driver) ReadWithDefaults

func (d *ADS1x15Driver) ReadWithDefaults(channel int) (float64, error)

ReadWithDefaults reads the voltage at the specified channel (between 0 and 3). Default values are used for the gain and data rate. The result is in V.

type ADXL345Driver

type ADXL345Driver struct {
	*Driver
	// contains filtered or unexported fields
}

ADXL345Driver is the gobot driver for the digital accelerometer ADXL345

Datasheet EN: http://www.analog.com/media/en/technical-documentation/data-sheets/ADXL345.pdf Datasheet JP: http://www.analog.com/media/jp/technical-documentation/data-sheets/ADXL345_jp.pdf

Ported from the Arduino driver https://github.com/jakalada/Arduino-ADXL345

func NewADXL345Driver

func NewADXL345Driver(c Connector, options ...func(Config)) *ADXL345Driver

NewADXL345Driver creates a new driver with specified i2c interface Params:

c Connector - the Adaptor to use with this Driver

Optional params:

i2c.WithBus(int):	bus to use with this driver
i2c.WithAddress(int):	address to use with this driver

func (*ADXL345Driver) RawXYZ

func (d *ADXL345Driver) RawXYZ() (int16, int16, int16, error)

RawXYZ returns the raw x,y and z axis

func (*ADXL345Driver) SetRange

func (d *ADXL345Driver) SetRange(fullScaleRange ADXL345FsRangeConfig) error

SetRange change the current range of the sensor immediately

func (*ADXL345Driver) SetRate

func (d *ADXL345Driver) SetRate(rate ADXL345RateConfig) error

SetRate change the current rate of the sensor immediately

func (*ADXL345Driver) UseLowPower

func (d *ADXL345Driver) UseLowPower(lowPower bool) error

UseLowPower change the current rate of the sensor

func (*ADXL345Driver) XYZ

func (d *ADXL345Driver) XYZ() (float64, float64, float64, error)

XYZ returns the adjusted x, y and z axis, unit [g]

type ADXL345FsRangeConfig

type ADXL345FsRangeConfig uint8

type ADXL345RateConfig

type ADXL345RateConfig uint8

type Adafruit1109Driver

type Adafruit1109Driver struct {
	*MCP23017Driver

	*gpio.HD44780Driver
	// contains filtered or unexported fields
}

Adafruit1109Driver is a driver for the 2x16 LCD display with RGB backlit and 5 keys from adafruit, designed for Pi. The display is driven by the HD44780, and all is connected by i2c port expander MCP23017. https://www.adafruit.com/product/1109

Have to implement DigitalWriter, DigitalReader interface

func NewAdafruit1109Driver

func NewAdafruit1109Driver(a Connector, options ...func(Config)) *Adafruit1109Driver

NewAdafruit1109Driver creates is a new driver for the 2x16 LCD display with RGB backlit and 5 keys.

Because HD44780 and MCP23017 are already implemented in gobot, this is a wrapper for using existing implementation. So, for the documentation of the parameters, have a look at this drivers.

Tests are done with a Tinkerboard.

func (*Adafruit1109Driver) Connect

func (d *Adafruit1109Driver) Connect() error

Connect implements the adaptor.Connector interface. Haven't found any adaptor which implements this with more content.

func (*Adafruit1109Driver) Connection

func (d *Adafruit1109Driver) Connection() gobot.Connection

Connection implements the gobot.Device interface.

func (*Adafruit1109Driver) DigitalRead

func (d *Adafruit1109Driver) DigitalRead(id string) (int, error)

DigitalRead implements the DigitalReader interface This is called by HD44780 driver to read one gpio input. We redirect the call to the i2c driver MCP23017. The given id is the same as defined in dataPins and has the syntax "<port>_<pin>".

func (*Adafruit1109Driver) DigitalWrite

func (d *Adafruit1109Driver) DigitalWrite(id string, val byte) error

DigitalWrite implements the DigitalWriter interface This is called by HD44780 driver to set one gpio output. We redirect the call to the i2c driver MCP23017. The given id is the same as defined in dataPins and has the syntax "<port>_<pin>".

func (*Adafruit1109Driver) DownButton

func (d *Adafruit1109Driver) DownButton() (uint8, error)

DownButton reads the state of the "down" button (1=pressed).

func (*Adafruit1109Driver) Finalize

func (d *Adafruit1109Driver) Finalize() error

Finalize implements the adaptor.Connector interface. Haven't found any adaptor which implements this with more content.

func (*Adafruit1109Driver) Halt

func (d *Adafruit1109Driver) Halt() error

Halt implements the gobot.Device interface.

func (*Adafruit1109Driver) LeftButton

func (d *Adafruit1109Driver) LeftButton() (uint8, error)

LeftButton reads the state of the "left" button (1=pressed).

func (*Adafruit1109Driver) Name

func (d *Adafruit1109Driver) Name() string

Name implements the gobot.Device interface

func (*Adafruit1109Driver) RightButton

func (d *Adafruit1109Driver) RightButton() (uint8, error)

RightButton reads the state of the "right" button (1=pressed).

func (*Adafruit1109Driver) SelectButton

func (d *Adafruit1109Driver) SelectButton() (uint8, error)

SelectButton reads the state of the "select" button (1=pressed).

func (*Adafruit1109Driver) SetName

func (d *Adafruit1109Driver) SetName(n string)

SetName implements the gobot.Device interface.

func (*Adafruit1109Driver) SetRGB

func (d *Adafruit1109Driver) SetRGB(r, g, b bool) error

SetRGB sets the Red Green Blue value of backlit. The MCP23017 variant don't support PWM and have inverted logic

func (*Adafruit1109Driver) Start

func (d *Adafruit1109Driver) Start() error

Start implements the gobot.Device interface.

func (*Adafruit1109Driver) UpButton

func (d *Adafruit1109Driver) UpButton() (uint8, error)

UpButton reads the state of the "up" button (1=pressed).

type Adafruit2327Driver added in v2.2.0

type Adafruit2327Driver struct {
	*PCA9685Driver
}

Adafruit2327Driver is a driver for Adafruit 16-Channel PWM/Servo HAT & Bonnet - a Raspberry Pi add-on, based on PCA9685. This driver just wraps the PCA9685Driver. Stacking 62 of them is possible (addresses 0x40..0x7E), for controlling up to 992 servos. datasheet: https://cdn-learn.adafruit.com/downloads/pdf/adafruit-16-channel-pwm-servo-hat-for-raspberry-pi.pdf

func NewAdafruit2327Driver added in v2.2.0

func NewAdafruit2327Driver(c Connector, options ...func(Config)) *Adafruit2327Driver

NewAdafruit2327Driver initializes a new driver for PWM servos. Params:

c Connector - the Adaptor to use with this Driver

Optional params:

i2c.WithBus(int):	    bus to use with this driver
i2c.WithAddress(int):	address to use with this driver

func (*Adafruit2327Driver) SetServoMotorFreq added in v2.2.0

func (a *Adafruit2327Driver) SetServoMotorFreq(freq float64) error

SetServoMotorFreq sets the frequency for the currently addressed PWM Servo HAT.

func (*Adafruit2327Driver) SetServoMotorPulse added in v2.2.0

func (a *Adafruit2327Driver) SetServoMotorPulse(channel byte, on, off int32) error

SetServoMotorPulse is a convenience function to specify the 'tick' value, between 0-4095, when the signal will turn on, and when it will turn off.

type Adafruit2348Direction added in v2.2.0

type Adafruit2348Direction int

Adafruit2348Direction declares a type for specification of the motor direction

const (
	Adafruit2348Forward  Adafruit2348Direction = iota // 0
	Adafruit2348Backward                              // 1
	Adafruit2348Release                               // 2
)

constants for running the motor in different direction or release

type Adafruit2348Driver added in v2.2.0

type Adafruit2348Driver struct {
	*PCA9685Driver
	// contains filtered or unexported fields
}

Adafruit2348Driver is a driver for Adafruit DC and Stepper Motor HAT - a Raspberry Pi add-on, based on PCA9685. The HAT can drive up to 4 DC or 2 stepper motors with full PWM speed and direction control over I2C. This driver wraps the PCA9685Driver. Stacking 32 of them is possible (addresses 0x60..0x80), for controlling up to 64 stepper motors or 128 DC motors. datasheet: https://cdn-learn.adafruit.com/downloads/pdf/adafruit2348-dc-and-stepper-motor-hat-for-raspberry-pi.pdf

func NewAdafruit2348Driver added in v2.2.0

func NewAdafruit2348Driver(c Connector, options ...func(Config)) *Adafruit2348Driver

NewAdafruit2348Driver initializes a new driver for DC and stepper motors. Params:

c Connector - the Adaptor to use with this Driver

Optional params:

i2c.WithBus(int):	    bus to use with this driver
i2c.WithAddress(int):	address to use with this driver

func (*Adafruit2348Driver) RunDCMotor added in v2.2.0

func (a *Adafruit2348Driver) RunDCMotor(dcMotor int, dir Adafruit2348Direction) error

RunDCMotor will set the appropriate pins to run the specified DC motor for the given direction.

func (*Adafruit2348Driver) SetDCMotorSpeed added in v2.2.0

func (a *Adafruit2348Driver) SetDCMotorSpeed(dcMotor int, speed int32) error

SetDCMotorSpeed will set the appropriate pins to run the specified DC motor for the given speed.

func (*Adafruit2348Driver) SetStepperMotorSpeed added in v2.2.0

func (a *Adafruit2348Driver) SetStepperMotorSpeed(stepperMotor int, rpm int) error

SetStepperMotorSpeed sets the seconds-per-step for the given stepper motor. It is applied in the next cycle.

func (*Adafruit2348Driver) Step added in v2.2.0

func (a *Adafruit2348Driver) Step(motor, steps int, dir Adafruit2348Direction, style Adafruit2348StepStyle) error

Step will rotate the stepper motor the given number of steps, in the given direction and step style.

type Adafruit2348StepStyle added in v2.2.0

type Adafruit2348StepStyle int

Adafruit2348StepStyle declares a type for specification of the stepper motor rotation

const (
	Adafruit2348Single     Adafruit2348StepStyle = iota // 0
	Adafruit2348Double                                  // 1
	Adafruit2348Interleave                              // 2
	Adafruit2348Microstep                               // 3
)

constants for running the stepper motor in different modes

type BH1750Driver

type BH1750Driver struct {
	*Driver
	// contains filtered or unexported fields
}

BH1750Driver is a driver for the BH1750 digital Ambient Light Sensor IC for I²C bus interface.

func NewBH1750Driver

func NewBH1750Driver(c Connector, options ...func(Config)) *BH1750Driver

NewBH1750Driver creates a new driver with specified i2c interface Params:

c Connector - the Adaptor to use with this Driver

Optional params:

i2c.WithBus(int):	bus to use with this driver
i2c.WithAddress(int):	address to use with this driver

func (*BH1750Driver) Lux

func (h *BH1750Driver) Lux() (int, error)

Lux returns the adjusted value from the bh1750

func (*BH1750Driver) RawSensorData

func (h *BH1750Driver) RawSensorData() (int, error)

RawSensorData returns the raw value from the bh1750

type BME280Driver

type BME280Driver struct {
	*BMP280Driver
	// contains filtered or unexported fields
}

BME280Driver is a driver for the BME280 temperature/humidity sensor. It implements all of the same functions as the BMP280Driver, but also adds the Humidity() function by reading the BME280's humidity sensor. For details on the BMP280Driver please see:

https://godoc.org/gobot.io/x/gobot/v2/drivers/i2c#BMP280Driver

func NewBME280Driver

func NewBME280Driver(c Connector, options ...func(Config)) *BME280Driver

NewBME280Driver creates a new driver with specified i2c interface. Params:

conn Connector - the Adaptor to use with this Driver

Optional params:

i2c.WithBus(int):	bus to use with this driver
i2c.WithAddress(int):	address to use with this driver

func (*BME280Driver) Humidity

func (d *BME280Driver) Humidity() (float32, error)

Humidity returns the current humidity in percentage of relative humidity

type BME280HumidityOversampling

type BME280HumidityOversampling uint8
const (

	// bits 0, 1, 3 of control humidity register
	BME280CtrlHumidityNoMeasurement  BME280HumidityOversampling = 0x00 // no measurement (value will be 0x08 0x00 0x00)
	BME280CtrlHumidityOversampling1  BME280HumidityOversampling = 0x01
	BME280CtrlHumidityOversampling2  BME280HumidityOversampling = 0x02
	BME280CtrlHumidityOversampling4  BME280HumidityOversampling = 0x03
	BME280CtrlHumidityOversampling8  BME280HumidityOversampling = 0x04
	BME280CtrlHumidityOversampling16 BME280HumidityOversampling = 0x05 // same as 0x06, 0x07
)

type BMP180Driver

type BMP180Driver struct {
	*Driver
	// contains filtered or unexported fields
}

BMP180Driver is the gobot driver for the Bosch pressure and temperature sensor BMP180. Device datasheet: https://cdn-shop.adafruit.com/datasheets/BST-BMP180-DS000-09.pdf

func NewBMP180Driver

func NewBMP180Driver(c Connector, options ...func(Config)) *BMP180Driver

NewBMP180Driver creates a new driver with the i2c interface for the BMP180 device. Params:

conn Connector - the Adaptor to use with this Driver

Optional params:

i2c.WithBus(int):	bus to use with this driver
i2c.WithAddress(int):	address to use with this driver

func (*BMP180Driver) Pressure

func (d *BMP180Driver) Pressure() (float32, error)

Pressure returns the current pressure, in pascals.

func (*BMP180Driver) Temperature

func (d *BMP180Driver) Temperature() (float32, error)

Temperature returns the current temperature, in celsius degrees.

type BMP180OversamplingMode

type BMP180OversamplingMode uint

BMP180OversamplingMode is the oversampling ratio of the pressure measurement.

const (
	// BMP180UltraLowPower is the lowest oversampling mode of the pressure measurement.
	BMP180UltraLowPower BMP180OversamplingMode = iota
	// BMP180Standard is the standard oversampling mode of the pressure measurement.
	BMP180Standard
	// BMP180HighResolution is a high oversampling mode of the pressure measurement.
	BMP180HighResolution
	// BMP180UltraHighResolution is the highest oversampling mode of the pressure measurement.
	BMP180UltraHighResolution
)

type BMP280Driver

type BMP280Driver struct {
	*Driver
	// contains filtered or unexported fields
}

BMP280Driver is a driver for the BMP280 temperature/pressure sensor

func NewBMP280Driver

func NewBMP280Driver(c Connector, options ...func(Config)) *BMP280Driver

NewBMP280Driver creates a new driver with specified i2c interface. Params:

c Connector - the Adaptor to use with this Driver

Optional params:

i2c.WithBus(int):	bus to use with this driver
i2c.WithAddress(int):	address to use with this driver

func (*BMP280Driver) Altitude

func (d *BMP280Driver) Altitude() (float32, error)

Altitude returns the current altitude in meters based on the current barometric pressure and estimated pressure at sea level. Calculation is based on code from Adafruit BME280 library

https://github.com/adafruit/Adafruit_BME280_Library

func (*BMP280Driver) Pressure

func (d *BMP280Driver) Pressure() (float32, error)

Pressure returns the current barometric pressure, in Pa

func (*BMP280Driver) Temperature

func (d *BMP280Driver) Temperature() (float32, error)

Temperature returns the current temperature, in celsius degrees.

type BMP280IIRFilter

type BMP280IIRFilter uint8

type BMP280PressureOversampling

type BMP280PressureOversampling uint8

type BMP280TemperatureOversampling

type BMP280TemperatureOversampling uint8

type BMP388Accuracy

type BMP388Accuracy uint8

BMP388Accuracy accuracy type

const (

	// oversampling rate, a single value is used (could be different for pressure and temperature)
	BMP388AccuracyUltraLow  BMP388Accuracy = 0 // x1 sample
	BMP388AccuracyLow       BMP388Accuracy = 1 // x2 samples
	BMP388AccuracyStandard  BMP388Accuracy = 2 // x4 samples
	BMP388AccuracyHigh      BMP388Accuracy = 3 // x8 samples
	BMP388AccuracyUltraHigh BMP388Accuracy = 4 // x16 samples
	BMP388AccuracyHighest   BMP388Accuracy = 5 // x32 samples

)

type BMP388Driver

type BMP388Driver struct {
	*Driver
	// contains filtered or unexported fields
}

BMP388Driver is a driver for the BMP388 temperature/pressure sensor

func NewBMP388Driver

func NewBMP388Driver(c Connector, options ...func(Config)) *BMP388Driver

NewBMP388Driver creates a new driver with specified i2c interface. Params:

c Connector - the Adaptor to use with this Driver

Optional params:

i2c.WithBus(int):	bus to use with this driver
i2c.WithAddress(int):	address to use with this driver

func (*BMP388Driver) Altitude

func (d *BMP388Driver) Altitude(accuracy BMP388Accuracy) (float32, error)

Altitude returns the current altitude in meters based on the current barometric pressure and estimated pressure at sea level. https://www.weather.gov/media/epz/wxcalc/pressureAltitude.pdf

func (*BMP388Driver) Pressure

func (d *BMP388Driver) Pressure(accuracy BMP388Accuracy) (float32, error)

Pressure returns the current barometric pressure, in Pa

func (*BMP388Driver) Temperature

func (d *BMP388Driver) Temperature(accuracy BMP388Accuracy) (float32, error)

Temperature returns the current temperature, in celsius degrees.

type BMP388IIRFilter

type BMP388IIRFilter uint8

BMP388Accuracy accuracy type

type BlinkMDriver

type BlinkMDriver struct {
	*Driver
}

BlinkMDriver is a Gobot Driver for a BlinkM LED

func NewBlinkMDriver

func NewBlinkMDriver(c Connector, options ...func(Config)) *BlinkMDriver

NewBlinkMDriver creates a new BlinkMDriver.

Params:

c Connector - the Adaptor to use with this Driver

Optional params:

i2c.WithBus(int):	bus to use with this driver
i2c.WithAddress(int):	address to use with this driver

func (*BlinkMDriver) Color

func (b *BlinkMDriver) Color() ([]byte, error)

Color returns an array with current rgb color

func (*BlinkMDriver) Fade

func (b *BlinkMDriver) Fade(red byte, green byte, blue byte) error

Fade removes color using r,g,b params

func (*BlinkMDriver) FirmwareVersion

func (b *BlinkMDriver) FirmwareVersion() (string, error)

FirmwareVersion returns version with MAYOR.minor format

func (*BlinkMDriver) Rgb

func (b *BlinkMDriver) Rgb(red byte, green byte, blue byte) error

Rgb sets color using r,g,b params

type CCS811DriveMode

type CCS811DriveMode uint8

CCS811DriveMode type

const (
	CCS811DriveModeIdle  CCS811DriveMode = 0x00
	CCS811DriveMode1Sec  CCS811DriveMode = 0x01
	CCS811DriveMode10Sec CCS811DriveMode = 0x02
	CCS811DriveMode60Sec CCS811DriveMode = 0x03
	CCS811DriveMode250MS CCS811DriveMode = 0x04
)

Operating modes which dictate how often measurements are being made. If 0x00 is used as an operating mode, measurements will be disabled

type CCS811Driver

type CCS811Driver struct {
	*Driver
	// contains filtered or unexported fields
}

CCS811Driver is the Gobot driver for the CCS811 (air quality sensor) Adafruit breakout board

func NewCCS811Driver

func NewCCS811Driver(c Connector, options ...func(Config)) *CCS811Driver

NewCCS811Driver creates a new driver for the CCS811 (air quality sensor)

func (*CCS811Driver) DisableExternalInterrupt

func (d *CCS811Driver) DisableExternalInterrupt() error

DisableExternalInterrupt disables the external output hardware interrupt pin 3.

func (*CCS811Driver) EnableExternalInterrupt

func (d *CCS811Driver) EnableExternalInterrupt() error

EnableExternalInterrupt enables the external output hardware interrupt pin 3.

func (*CCS811Driver) GetFirmwareAppVersion

func (d *CCS811Driver) GetFirmwareAppVersion() (uint16, error)

GetFirmwareAppVersion returns the app code version

func (*CCS811Driver) GetFirmwareBootVersion

func (d *CCS811Driver) GetFirmwareBootVersion() (uint16, error)

GetFirmwareBootVersion returns the bootloader version

func (*CCS811Driver) GetGasData

func (d *CCS811Driver) GetGasData() (uint16, uint16, error)

GetGasData returns the data for the gas sensor. eco2 is returned in ppm and tvoc is returned in ppb

func (*CCS811Driver) GetHardwareVersion

func (d *CCS811Driver) GetHardwareVersion() (uint8, error)

GetHardwareVersion returns the hardware version of the device in the form of 0x1X

func (*CCS811Driver) GetStatus

func (d *CCS811Driver) GetStatus() (*CCS811Status, error)

GetStatus returns the current status of the device

func (*CCS811Driver) GetTemperature

func (d *CCS811Driver) GetTemperature() (float32, error)

GetTemperature returns the device temperature in celsius. If you do not have an NTC resistor installed, this function should not be called

func (*CCS811Driver) HasData

func (d *CCS811Driver) HasData() (bool, error)

HasData returns true if the device has not errored and temperature/gas data is available

type CCS811MeasMode

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

CCS811MeasMode represents the current measurement configuration. The following definitions were taken from the bit fields of the ccs811RegMeasMode defined in https://ams.com/documents/20143/36005/CCS811_DS000459_6-00.pdf/c7091525-c7e5-37ac-eedb-b6c6828b0dcf#page=16

func NewCCS811MeasMode

func NewCCS811MeasMode() *CCS811MeasMode

NewCCS811MeasMode returns a new instance of the measurement mode configuration. This represents the desired initial state of the measurement mode register.

func (*CCS811MeasMode) GetMeasMode

func (mm *CCS811MeasMode) GetMeasMode() byte

GetMeasMode returns the measurement mode

type CCS811Status

type CCS811Status struct {
	// There is some sort of error on the i2c bus or there is an error with the internal sensor
	HasError byte
	// A new data sample is ready in ccs811RegAlgResultData
	DataReady byte
	// Valid application firmware loaded
	AppValid byte
	// Firmware is in application mode. CCS811 is ready to take sensor measurements
	FwMode byte
}

CCS811Status represents the current status of the device defined by the ccs811RegStatus. The following definitions were taken from https://ams.com/documents/20143/36005/CCS811_DS000459_6-00.pdf/c7091525-c7e5-37ac-eedb-b6c6828b0dcf#page=15

func NewCCS811Status

func NewCCS811Status(data uint8) *CCS811Status

NewCCS811Status returns a new instance of the package ccs811 status definition

type Config

type Config interface {
	// SetBus sets which bus to use
	SetBus(bus int)

	// GetBusOrDefault gets which bus to use
	GetBusOrDefault(def int) int

	// SetAddress sets which address to use
	SetAddress(address int)

	// GetAddressOrDefault gets which address to use
	GetAddressOrDefault(def int) int
}

Config is the interface to set and get I2C device related parameters.

func NewConfig

func NewConfig() Config

NewConfig returns a new I2c Config.

type Connection

type Connection gobot.I2cOperations

Connection is a connection to an I2C device with a specified address on a specific bus. Used as an alternative to the I2c interface. Implements I2cOperations to talk to the device, wrapping the calls in SetAddress to always target the specified device. Provided by an Adaptor by implementing the I2cConnector interface.

type Connector

type Connector interface {
	// GetI2cConnection creates and returns a connection to device at the specified address
	// and bus. Bus numbering starts at index 0, the range of valid buses is
	// platform specific.
	GetI2cConnection(address int, busNr int) (device Connection, err error)

	// DefaultI2cBus returns the default I2C bus index
	DefaultI2cBus() int
}

Connector lets adaptors (platforms) provide the interface for Drivers to get access to the I2C buses on platforms that support I2C. The "I2C" specifier is part of the name to differentiate to SPI at platform level.

type DRV2605LDriver

type DRV2605LDriver struct {
	*Driver
}

DRV2605LDriver is the gobot driver for the TI/Adafruit DRV2605L Haptic Controller

Device datasheet: http://www.ti.com/lit/ds/symlink/drv2605l.pdf

Inspired by the Adafruit Python driver by Sean Mealin.

Basic use:

haptic := i2c.NewDRV2605Driver(adaptor)
haptic.SetSequence([]byte{1, 13})
haptic.Go()

func NewDRV2605LDriver

func NewDRV2605LDriver(c Connector, options ...func(Config)) *DRV2605LDriver

NewDRV2605LDriver creates a new driver for the DRV2605L device.

Params:

c Connector - the Adaptor to use with this Driver

Optional params:

i2c.WithBus(int):	bus to use with this driver
i2c.WithAddress(int):	address to use with this driver

func (*DRV2605LDriver) GetPauseWaveform

func (d *DRV2605LDriver) GetPauseWaveform(delayTime10MS uint8) uint8

GetPauseWaveform returns a special waveform ID used in SetSequence() to encode pauses between waveforms. Time is specified in tens of milliseconds ranging from 0ms (delayTime10MS = 0) to 1270ms (delayTime10MS = 127). Times out of range are clipped to fit.

func (*DRV2605LDriver) Go

func (d *DRV2605LDriver) Go() error

Go plays the current sequence of waveforms.

func (*DRV2605LDriver) SelectLibrary

func (d *DRV2605LDriver) SelectLibrary(library uint8) error

SelectLibrary selects which waveform library to play from, 1-7. See datasheet for more info.

func (*DRV2605LDriver) SetMode

func (d *DRV2605LDriver) SetMode(newMode DRV2605Mode) error

SetMode sets the device in one of the eight modes as described in the datasheet. Defaults to mode 0, internal trig.

func (*DRV2605LDriver) SetSequence

func (d *DRV2605LDriver) SetSequence(waveforms []uint8) error

SetSequence sets the sequence of waveforms to be played by the sequencer, specified by waveform id as described in the datasheet. The sequencer can play at most 8 waveforms in sequence, longer sequences will be truncated. A waveform id of zero marks the end of the sequence. Pauses can be encoded using GetPauseWaveform().

func (*DRV2605LDriver) SetStandbyMode

func (d *DRV2605LDriver) SetStandbyMode(standby bool) error

SetStandbyMode controls device low power mode

type DRV2605Mode

type DRV2605Mode uint8

DRV2605Mode - operating mode

const (
	DRV2605ModeIntTrig     DRV2605Mode = 0x00
	DRV2605ModeExtTrigEdge DRV2605Mode = 0x01
	DRV2605ModeExtTrigLvl  DRV2605Mode = 0x02
	DRV2605ModePWMAnalog   DRV2605Mode = 0x03
	DRV2605ModeAudioVibe   DRV2605Mode = 0x04
	DRV2605ModeRealtime    DRV2605Mode = 0x05
	DRV2605ModeDiagnose    DRV2605Mode = 0x06
	DRV2605ModeAutocal     DRV2605Mode = 0x07
)

Operating modes, for use in SetMode()

type DisplayBuffer

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

DisplayBuffer represents the display buffer intermediate memory.

func NewDisplayBuffer

func NewDisplayBuffer(width, height, pageSize int) *DisplayBuffer

NewDisplayBuffer creates a new DisplayBuffer.

func (*DisplayBuffer) Clear

func (d *DisplayBuffer) Clear()

Clear the contents of the display buffer.

func (*DisplayBuffer) Set

func (d *DisplayBuffer) Set(buf []byte)

Set sets the display buffer with the given buffer.

func (*DisplayBuffer) SetPixel

func (d *DisplayBuffer) SetPixel(x, y, c int)

SetPixel sets the x, y pixel with c color.

func (*DisplayBuffer) Size

func (d *DisplayBuffer) Size() int

Size returns the memory size of the display buffer.

type Driver

type Driver struct {
	Config
	gobot.Commander
	// contains filtered or unexported fields
}

Driver implements the interface gobot.Driver.

func NewDriver

func NewDriver(c Connector, name string, address int, options ...func(Config)) *Driver

NewDriver creates a new generic and basic i2c gobot driver.

func (*Driver) Connection

func (d *Driver) Connection() gobot.Connection

Connection returns the connection of the i2c device.

func (*Driver) Halt

func (d *Driver) Halt() error

Halt halts the i2c device.

func (*Driver) Name

func (d *Driver) Name() string

Name returns the name of the i2c device.

func (*Driver) Read

func (d *Driver) Read(pin string) (int, error)

Read implements a simple read mechanism from the given register of an i2c device.

func (*Driver) SetName

func (d *Driver) SetName(name string)

SetName sets the name of the i2c device.

func (*Driver) Start

func (d *Driver) Start() error

Start initializes the i2c device.

func (*Driver) Write

func (d *Driver) Write(pin string, val int) error

Write implements a simple write mechanism, starting from the given register of an i2c device.

type GenericDriver

type GenericDriver struct {
	*Driver
}

GenericDriver implements the interface gobot.Driver.

func NewGenericDriver

func NewGenericDriver(c Connector, name string, address int, options ...func(Config)) *GenericDriver

NewGenericDriver creates a new generic i2c gobot driver, which just forwards all connection functions.

func (*GenericDriver) Read

func (d *GenericDriver) Read(data []byte) error

Read fills the given buffer with reads of an i2c device.

func (*GenericDriver) ReadBlockData

func (d *GenericDriver) ReadBlockData(reg uint8, data []byte) error

ReadBlockData fills the given buffer with reads starting from the given register of an i2c device.

func (*GenericDriver) ReadByte

func (d *GenericDriver) ReadByte() (byte, error)

ReadByte reads a byte from the current register of an i2c device.

func (*GenericDriver) ReadByteData

func (d *GenericDriver) ReadByteData(reg uint8) (byte, error)

ReadByteData reads a byte from the given register of an i2c device.

func (*GenericDriver) ReadData

func (d *GenericDriver) ReadData(reg uint8, data []byte) error

ReadData fills the given buffer with reads from the given register of an i2c device. It uses plain read to prevent ReadBlockData(), which is sometimes not supported by adaptor.

func (*GenericDriver) ReadWordData

func (d *GenericDriver) ReadWordData(reg uint8) (uint16, error)

ReadWordData reads a 16 bit value starting from the given register of an i2c device.

func (*GenericDriver) Write

func (d *GenericDriver) Write(data []byte) error

Write writes the given buffer to the i2c device.

func (*GenericDriver) WriteBlockData

func (d *GenericDriver) WriteBlockData(reg uint8, data []byte) error

WriteBlockData writes the given buffer to the given register of an i2c device.

func (*GenericDriver) WriteByte

func (d *GenericDriver) WriteByte(val byte) error

WriteByte writes one byte to the i2c device.

func (*GenericDriver) WriteByteData

func (d *GenericDriver) WriteByteData(reg uint8, val byte) error

WriteByteData writes the given byte value to the given register of an i2c device.

func (*GenericDriver) WriteData

func (d *GenericDriver) WriteData(reg uint8, data []byte) error

WriteData writes the given buffer to the given register of an i2c device. It uses plain write to prevent WriteBlockData(), which is sometimes not supported by adaptor.

func (*GenericDriver) WriteWordData

func (d *GenericDriver) WriteWordData(reg uint8, val uint16) error

WriteWordData writes the given 16 bit value to the given register of an i2c device.

type GroveAccelerometerDriver

type GroveAccelerometerDriver struct {
	*MMA7660Driver
}

GroveAccelerometerDriver is a driver for the MMA7660 accelerometer

func NewGroveAccelerometerDriver

func NewGroveAccelerometerDriver(a Connector, options ...func(Config)) *GroveAccelerometerDriver

NewGroveAccelerometerDriver creates a new driver with specified i2c interface Params:

conn Connector - the Adaptor to use with this Driver

Optional params:

i2c.WithBus(int):	bus to use with this driver
i2c.WithAddress(int):	address to use with this driver

type GroveLcdDriver

type GroveLcdDriver struct {
	*JHD1313M1Driver
}

GroveLcdDriver is a driver for the Jhd1313m1 LCD display which has two i2c addreses, one belongs to a controller and the other controls solely the backlight. This module was tested with the Seed Grove LCD RGB Backlight v2.0 display which requires 5V to operate. http://www.seeedstudio.com/wiki/Grove_-_LCD_RGB_Backlight

func NewGroveLcdDriver

func NewGroveLcdDriver(a Connector, options ...func(Config)) *GroveLcdDriver

NewGroveLcdDriver creates a new driver with specified i2c interface. Params:

conn Connector - the Adaptor to use with this Driver

Optional params:

i2c.WithBus(int):	bus to use with this driver
i2c.WithAddress(int):	address to use with this driver

type GrovePiDriver

type GrovePiDriver struct {
	*Driver
	// contains filtered or unexported fields
}

GrovePiDriver is a driver for the GrovePi+ for I²C bus interface. https://www.dexterindustries.com/grovepi/

To use this driver with the GrovePi, it must be running the firmware >= 1.4.0 and the system version >=3. https://github.com/DexterInd/GrovePi/blob/master/README.md

func NewGrovePiDriver

func NewGrovePiDriver(c Connector, options ...func(Config)) *GrovePiDriver

NewGrovePiDriver creates a new driver with specified i2c interface Params:

conn Connector - the Adaptor to use with this Driver

Optional params:

i2c.WithBus(int):	bus to use with this driver
i2c.WithAddress(int):	address to use with this driver

func (*GrovePiDriver) AnalogRead

func (d *GrovePiDriver) AnalogRead(pin string) (int, error)

AnalogRead returns value from analog pin implementing the AnalogReader interface.

func (*GrovePiDriver) AnalogWrite

func (d *GrovePiDriver) AnalogWrite(pin string, val int) error

AnalogWrite writes PWM aka analog to the GrovePi analog pin implementing the AnalogWriter interface.

func (*GrovePiDriver) Connect

func (d *GrovePiDriver) Connect() error

Connect is here to implement the Adaptor interface.

func (*GrovePiDriver) DHTRead

func (d *GrovePiDriver) DHTRead(pin string, sensorType byte, duration int) (temp float32, hum float32, err error)

DHTRead performs a read temperature and humidity sensors with duration >=2 millisecond. DHT11 (blue): sensorType=0 DHT22 (white): sensorTyp=1

func (*GrovePiDriver) DigitalRead

func (d *GrovePiDriver) DigitalRead(pin string) (int, error)

DigitalRead performs a read on a digital pin.

func (*GrovePiDriver) DigitalWrite

func (d *GrovePiDriver) DigitalWrite(pin string, val byte) error

DigitalWrite writes a value to a specific digital pin implementing the DigitalWriter interface.

func (*GrovePiDriver) Finalize

func (d *GrovePiDriver) Finalize() error

Finalize is here to implement the Adaptor interface.

func (*GrovePiDriver) FirmwareVersionRead

func (d *GrovePiDriver) FirmwareVersionRead() (string, error)

FirmwareVersionRead returns the GrovePi firmware version.

func (*GrovePiDriver) SetPinMode

func (d *GrovePiDriver) SetPinMode(pin byte, mode string) error

SetPinMode sets the pin mode to input or output.

func (*GrovePiDriver) UltrasonicRead

func (d *GrovePiDriver) UltrasonicRead(pin string, duration int) (int, error)

UltrasonicRead performs a read on an ultrasonic pin with duration >=2 millisecond.

type HMC5883LDriver

type HMC5883LDriver struct {
	*Driver
	// contains filtered or unexported fields
}

HMC5883LDriver is a Gobot Driver for a HMC5883 I2C 3 axis digital compass.

This driver was tested with Tinkerboard & Digispark adaptor and a HMC5883L breakout board GY-273, available from various distributors.

datasheet: http://www.adafruit.com/datasheets/HMC5883L_3-Axis_Digital_Compass_IC.pdf

reference implementations: * https://github.com/gvalkov/micropython-esp8266-hmc5883l * https://github.com/adafruit/Adafruit_HMC5883_Unified

func NewHMC5883LDriver

func NewHMC5883LDriver(c Connector, options ...func(Config)) *HMC5883LDriver

NewHMC5883LDriver creates a new driver with specified i2c interface Params:

c Connector - the Adaptor to use with this Driver

Optional params:

		i2c.WithBus(int):	bus to use with this driver
		i2c.WithAddress(int):	address to use with this driver
   i2c.WithHMC5883LSamplesAveraged(int)
   i2c.WithHMC5883LDataOutputRate(int)
   i2c.WithHMC5883LMeasurementFlow(int)
   i2c.WithHMC5883LGain(int)

func (*HMC5883LDriver) Heading

func (h *HMC5883LDriver) Heading() (float64, error)

Heading returns the current heading in radians

func (*HMC5883LDriver) Read

func (h *HMC5883LDriver) Read() (x float64, y float64, z float64, err error)

Read reads the values X, Y, Z in Gauss

type HMC6352Driver

type HMC6352Driver struct {
	*Driver
}

HMC6352Driver is a Driver for a HMC6352 digital compass

func NewHMC6352Driver

func NewHMC6352Driver(c Connector, options ...func(Config)) *HMC6352Driver

NewHMC6352Driver creates a new driver with specified i2c interface Params:

c Connector - the Adaptor to use with this Driver

Optional params:

i2c.WithBus(int):	bus to use with this driver
i2c.WithAddress(int):	address to use with this driver

func (*HMC6352Driver) Heading

func (h *HMC6352Driver) Heading() (uint16, error)

Heading returns the current heading

type INA3221Channel

type INA3221Channel uint8

INA3221Channel type that defines which INA3221 channel to read from.

const (
	INA3221Channel1 INA3221Channel = 1
	INA3221Channel2 INA3221Channel = 2
	INA3221Channel3 INA3221Channel = 3
)

type INA3221Driver

type INA3221Driver struct {
	*Driver
}

INA3221Driver is a driver for the INA3221 three-channel current and bus voltage monitoring device.

func NewINA3221Driver

func NewINA3221Driver(c Connector, options ...func(Config)) *INA3221Driver

NewINA3221Driver creates a new driver with the specified i2c interface. Params:

c Connector - the Adaptor to use with this Driver

Optional params:

i2c.WithBus(int):		bus to use with this driver
i2c.WithAddress(int):		address to use with this driver

func (*INA3221Driver) GetBusVoltage

func (i *INA3221Driver) GetBusVoltage(channel INA3221Channel) (float64, error)

GetBusVoltage gets the bus voltage in Volts

func (*INA3221Driver) GetCurrent

func (i *INA3221Driver) GetCurrent(channel INA3221Channel) (float64, error)

GetCurrent gets the current value in mA, taking into account the config settings and current LSB

func (*INA3221Driver) GetLoadVoltage

func (i *INA3221Driver) GetLoadVoltage(channel INA3221Channel) (float64, error)

GetLoadVoltage gets the load voltage in mV

func (*INA3221Driver) GetShuntVoltage

func (i *INA3221Driver) GetShuntVoltage(channel INA3221Channel) (float64, error)

GetShuntVoltage Gets the shunt voltage in mV

type JHD1313M1Driver

type JHD1313M1Driver struct {
	Config
	gobot.Commander
	// contains filtered or unexported fields
}

JHD1313M1Driver is a driver for the Jhd1313m1 LCD display which has two i2c addreses, one belongs to a controller and the other controls solely the backlight. This module was tested with the Seed Grove LCD RGB Backlight v2.0 display which requires 5V to operate. http://www.seeedstudio.com/wiki/Grove_-_LCD_RGB_Backlight

func NewJHD1313M1Driver

func NewJHD1313M1Driver(a Connector, options ...func(Config)) *JHD1313M1Driver

NewJHD1313M1Driver creates a new driver with specified i2c interface. Params:

conn Connector - the Adaptor to use with this Driver

Optional params:

i2c.WithBus(int):	bus to use with this driver

func (*JHD1313M1Driver) Clear

func (d *JHD1313M1Driver) Clear() error

Clear clears the text on the lCD display.

func (*JHD1313M1Driver) Connection

func (d *JHD1313M1Driver) Connection() gobot.Connection

Connection returns the driver connection to the device.

func (*JHD1313M1Driver) Halt

func (d *JHD1313M1Driver) Halt() error

Halt is a noop function.

func (*JHD1313M1Driver) Home

func (d *JHD1313M1Driver) Home() error

Home sets the cursor to the origin position on the display.

func (*JHD1313M1Driver) Name

func (d *JHD1313M1Driver) Name() string

Name returns the name the JHD1313M1 Driver was given when created.

func (*JHD1313M1Driver) Scroll

func (d *JHD1313M1Driver) Scroll(lr bool) error

Scroll sets the scrolling direction for the display, either left to right, or right to left.

func (*JHD1313M1Driver) SetCustomChar

func (d *JHD1313M1Driver) SetCustomChar(pos int, charMap [8]byte) error

SetCustomChar sets one of the 8 CGRAM locations with a custom character. The custom character can be used by writing a byte of value 0 to 7. When you are using LCD as 5x8 dots in function set then you can define a total of 8 user defined patterns (1 Byte for each row and 8 rows for each pattern). Use http://www.8051projects.net/lcd-interfacing/lcd-custom-character.php to create your own characters. To use a custom character, write byte value of the custom character position as a string after having setup the custom character.

func (*JHD1313M1Driver) SetName

func (d *JHD1313M1Driver) SetName(n string)

SetName sets the name for the JHD1313M1 Driver.

func (*JHD1313M1Driver) SetPosition

func (d *JHD1313M1Driver) SetPosition(pos int) error

SetPosition sets the cursor and the data display to pos. 0..15 are the positions in the first display line. 16..32 are the positions in the second display line.

func (*JHD1313M1Driver) SetRGB

func (d *JHD1313M1Driver) SetRGB(r, g, b int) error

SetRGB sets the Red Green Blue value of backlit.

func (*JHD1313M1Driver) Start

func (d *JHD1313M1Driver) Start() error

Start starts the backlit and the screen and initializes the states.

func (*JHD1313M1Driver) Write

func (d *JHD1313M1Driver) Write(message string) error

Write displays the passed message on the screen.

type L3GD20HDriver

type L3GD20HDriver struct {
	*Driver
	// contains filtered or unexported fields
}

L3GD20HDriver is the gobot driver for the Adafruit Triple-Axis Gyroscope L3GD20H. Device datasheet: http://www.st.com/internet/com/TECHNICAL_RESOURCES/TECHNICAL_LITERATURE/DATASHEET/DM00036465.pdf

func NewL3GD20HDriver

func NewL3GD20HDriver(c Connector, options ...func(Config)) *L3GD20HDriver

NewL3GD20HDriver creates a new Gobot driver for the L3GD20H I2C Triple-Axis Gyroscope.

Params:

c Connector - the Adaptor to use with this Driver

Optional params:

i2c.WithBus(int):	bus to use with this driver
i2c.WithAddress(int):	address to use with this driver

func (*L3GD20HDriver) FullScaleRange

func (d *L3GD20HDriver) FullScaleRange() (uint8, error)

FullScaleRange returns the full scale range of the device.

func (*L3GD20HDriver) Scale

func (d *L3GD20HDriver) Scale() L3GD20HScale

Scale returns the full scale range (deprecated, use FullScaleRange() instead).

func (*L3GD20HDriver) SetScale

func (d *L3GD20HDriver) SetScale(s L3GD20HScale)

SetScale sets the full scale range of the device (deprecated, use WithL3GD20HFullScaleRange() instead).

func (*L3GD20HDriver) XYZ

func (d *L3GD20HDriver) XYZ() (x float32, y float32, z float32, err error)

XYZ returns the current change in degrees per second, for the 3 axis.

type L3GD20HScale

type L3GD20HScale byte

L3GD20HScale is for configurable full scale range.

const (
	// L3GD20HScale250dps is the +/-250 degrees-per-second full scale range (+/-245 from datasheet, but can hold around +/-286).
	L3GD20HScale250dps L3GD20HScale = 0x00
	// L3GD20HScale500dps is the +/-500 degrees-per-second full scale range.
	L3GD20HScale500dps L3GD20HScale = 0x10
	// L3GD20HScale2001dps is the +/-2000 degrees-per-second full scale range by using 0x20 setting.
	L3GD20HScale2001dps L3GD20HScale = 0x20
	// L3GD20HScale2000dps is the +/-2000 degrees-per-second full scale range.
	L3GD20HScale2000dps L3GD20HScale = 0x30
)

type LIDARLiteDriver

type LIDARLiteDriver struct {
	*Driver
}

LIDARLiteDriver is the Gobot driver for the LIDARLite I2C LIDAR device.

func NewLIDARLiteDriver

func NewLIDARLiteDriver(c Connector, options ...func(Config)) *LIDARLiteDriver

NewLIDARLiteDriver creates a new driver for the LIDARLite I2C LIDAR device.

Params:

c Connector - the Adaptor to use with this Driver

Optional params:

i2c.WithBus(int):	bus to use with this driver
i2c.WithAddress(int):	address to use with this driver

func (*LIDARLiteDriver) Distance

func (h *LIDARLiteDriver) Distance() (int, error)

Distance returns the current distance in cm

type MCP23017Driver

type MCP23017Driver struct {
	*Driver

	gobot.Eventer
	// contains filtered or unexported fields
}

MCP23017Driver contains the driver configuration parameters.

func NewMCP23017Driver

func NewMCP23017Driver(c Connector, options ...func(Config)) *MCP23017Driver

NewMCP23017Driver creates a new Gobot Driver to the MCP23017 i2c port expander. Params:

c Connector - the Adaptor to use with this Driver

Optional params:

i2c.WithBus(int):	bus to use with this driver
i2c.WithAddress(int):	address to use with this driver
i2c.WithMCP23017Bank(int):	MCP23017 bank to use with this driver
i2c.WithMCP23017Mirror(int):	MCP23017 mirror to use with this driver
i2c.WithMCP23017Seqop(int):	MCP23017 seqop to use with this driver
i2c.WithMCP23017Disslw(int):	MCP23017 disslw to use with this driver
i2c.WithMCP23017Haen(int):	MCP23017 haen to use with this driver
i2c.WithMCP23017Odr(int):	MCP23017 odr to use with this driver
i2c.WithMCP23017Intpol(int):	MCP23017 intpol to use with this driver

func (*MCP23017Driver) ReadGPIO

func (m *MCP23017Driver) ReadGPIO(pin uint8, portStr string) (uint8, error)

ReadGPIO reads a value from a given gpio pin (0-7) and a port (A or B).

func (*MCP23017Driver) SetGPIOPolarity

func (m *MCP23017Driver) SetGPIOPolarity(pin uint8, portStr string, val uint8) error

SetGPIOPolarity will change a given pin's polarity immediately, based on the value: val = 1 opposite logic state of the input pin. val = 0 same logic state of the input pin.

func (*MCP23017Driver) SetPinMode

func (m *MCP23017Driver) SetPinMode(pin uint8, portStr string, val uint8) error

SetPinMode set pin mode of a given pin immediately, based on the value: val = 0 output val = 1 input

func (*MCP23017Driver) SetPullUp

func (m *MCP23017Driver) SetPullUp(pin uint8, portStr string, val uint8) error

SetPullUp sets the pull up state of a given pin immediately, based on the value: val = 1 pull up enabled. val = 0 pull up disabled.

func (*MCP23017Driver) WriteGPIO

func (m *MCP23017Driver) WriteGPIO(pin uint8, portStr string, val uint8) error

WriteGPIO writes a value to a gpio pin (0-7) and a port (A or B).

type MFRC522Driver

type MFRC522Driver struct {
	*Driver
	*mfrc522.MFRC522Common
}

MFRC522Driver is a wrapper for i2c bus usage. Please refer to the mfrc522.MFRC522Common package for implementation details.

func NewMFRC522Driver

func NewMFRC522Driver(c Connector, options ...func(Config)) *MFRC522Driver

NewMFRC522Driver creates a new Gobot Driver for MFRC522 RFID with i2c connection

Params:

c Connector - the Adaptor to use with this Driver

Optional params:

i2c.WithBus(int):	bus to use with this driver
i2c.WithAddress(int):	address to use with this driver

type MMA7660Driver

type MMA7660Driver struct {
	*Driver
}

func NewMMA7660Driver

func NewMMA7660Driver(c Connector, options ...func(Config)) *MMA7660Driver

NewMMA7660Driver creates a new driver with specified i2c interface Params:

c Connector - the Adaptor to use with this Driver

Optional params:

i2c.WithBus(int):	bus to use with this driver
i2c.WithAddress(int):	address to use with this driver

func (*MMA7660Driver) Acceleration

func (d *MMA7660Driver) Acceleration(x, y, z float64) (ax, ay, az float64)

Acceleration returns the acceleration of the provided x, y, z

func (*MMA7660Driver) XYZ

func (d *MMA7660Driver) XYZ() (x float64, y float64, z float64, err error)

XYZ returns the raw x,y and z axis from the mma7660

type MPL115A2Driver

type MPL115A2Driver struct {
	*Driver
	gobot.Eventer
	// contains filtered or unexported fields
}

MPL115A2Driver is a Gobot Driver for the MPL115A2 I2C digital pressure/temperature sensor. datasheet: https://www.nxp.com/docs/en/data-sheet/MPL115A2.pdf

reference implementations: * https://github.com/adafruit/Adafruit_MPL115A2

func NewMPL115A2Driver

func NewMPL115A2Driver(c Connector, options ...func(Config)) *MPL115A2Driver

NewMPL115A2Driver creates a new Gobot Driver for an MPL115A2 I2C Pressure/Temperature sensor.

Params:

c Connector - the Adaptor to use with this Driver

Optional params:

i2c.WithBus(int):	bus to use with this driver
i2c.WithAddress(int):	address to use with this driver

func (*MPL115A2Driver) Pressure

func (d *MPL115A2Driver) Pressure() (float32, error)

Pressure fetches the latest data from the MPL115A2, and returns the pressure in kPa

func (*MPL115A2Driver) Temperature

func (d *MPL115A2Driver) Temperature() (float32, error)

Temperature fetches the latest data from the MPL115A2, and returns the temperature in °C

type MPU6050AccelFsConfig

type MPU6050AccelFsConfig uint8

type MPU6050DlpfConfig

type MPU6050DlpfConfig uint8

type MPU6050Driver

type MPU6050Driver struct {
	*Driver
	Accelerometer MPU6050ThreeDData
	Gyroscope     MPU6050ThreeDData
	Temperature   float64
	// contains filtered or unexported fields
}

MPU6050Driver is a Gobot Driver for an MPU6050 I2C Accelerometer/Gyroscope/Temperature sensor.

This driver was tested with Tinkerboard & Digispark adaptor and a MPU6050 breakout board GY-521, available from various distributors.

datasheet: https://product.tdk.com/system/files/dam/doc/product/sensor/mortion-inertial/imu/data_sheet/mpu-6000-datasheet1.pdf

reference implementations: * https://github.com/adafruit/Adafruit_CircuitPython_MPU6050 * https://github.com/ElectronicCats/mpu6050

func NewMPU6050Driver

func NewMPU6050Driver(a Connector, options ...func(Config)) *MPU6050Driver

NewMPU6050Driver creates a new Gobot Driver for an MPU6050 I2C Accelerometer/Gyroscope/Temperature sensor.

Params:

conn Connector - the Adaptor to use with this Driver

Optional params:

i2c.WithBus(int):	bus to use with this driver
i2c.WithAddress(int):	address to use with this driver

func (*MPU6050Driver) GetData

func (m *MPU6050Driver) GetData() error

GetData fetches the latest data from the MPU6050

type MPU6050FrameSyncConfig

type MPU6050FrameSyncConfig uint8

type MPU6050GyroFsConfig

type MPU6050GyroFsConfig uint8

type MPU6050Pwr1ClockConfig

type MPU6050Pwr1ClockConfig uint8

type MPU6050ThreeDData

type MPU6050ThreeDData struct {
	X float64
	Y float64
	Z float64
}

type PCA9501Driver

type PCA9501Driver struct {
	*Driver
	// contains filtered or unexported fields
}

PCA9501Driver is a Gobot Driver for the PCA9501 8-bit GPIO & 2-kbit EEPROM with 6 address program pins. 2-kbit EEPROM has 256 byte, means addresses between 0x00-0xFF

please refer to data sheet: https://www.nxp.com/docs/en/data-sheet/PCA9501.pdf

PCA9501 is the replacement for PCF8574, so this driver should also work for PCF8574 except EEPROM calls

func NewPCA9501Driver

func NewPCA9501Driver(a Connector, options ...func(Config)) *PCA9501Driver

NewPCA9501Driver creates a new driver with specified i2c interface Params:

a Connector - the Adaptor to use with this Driver

Optional params:

i2c.WithBus(int):	bus to use with this driver
i2c.WithAddress(int):	address to use with this driver

func (*PCA9501Driver) ReadEEPROM

func (p *PCA9501Driver) ReadEEPROM(address uint8) (uint8, error)

ReadEEPROM reads a value from a given address (0x00-0xFF) Note: only this sequence for memory read is supported: "STARTW-DATA1-STARTR-DATA2-STOP" DATA1: EEPROM address, DATA2: read value

func (*PCA9501Driver) ReadGPIO

func (p *PCA9501Driver) ReadGPIO(pin uint8) (uint8, error)

ReadGPIO reads a value from a given gpio pin (0-7)

func (*PCA9501Driver) WriteEEPROM

func (p *PCA9501Driver) WriteEEPROM(address uint8, val uint8) error

WriteEEPROM writes a value to a given address in memory (0x00-0xFF)

func (*PCA9501Driver) WriteGPIO

func (p *PCA9501Driver) WriteGPIO(pin uint8, val uint8) error

WriteGPIO writes a value to a gpio pin (0-7)

type PCA953xDriver

type PCA953xDriver struct {
	*Driver
}

PCA953xDriver is a Gobot Driver for LED Dimmer PCA9530 (2-bit), PCA9533 (4-bit), PCA9531 (8-bit), PCA9532 (16-bit) Although this is designed for LED's it can be used as a GPIO (read, write, pwm). The names of the public functions reflect this.

please refer to data sheet: https://www.nxp.com/docs/en/data-sheet/PCA9533.pdf

Address range: * PCA9530 0x60-0x61 (96-97 dec) * PCA9531 0x60-0x67 (96-103 dec) * PCA9532 0x60-0x67 (96-103 dec) * PCA9533/1 0x62 (98 dec) * PCA9533/2 0x63 (99 dec)

each new command must start by setting the register and the AI flag 0 0 0 AI | 0 R2 R1 R0 AI=1 means auto incrementing for R0-R2, which enable reading/writing all registers sequentially when AI=1 and reading, then R!=0 this means: do not start with reading input register, writing input register is recognized but has no effect => when AI=1 in general start with R>0

func NewPCA953xDriver

func NewPCA953xDriver(c Connector, options ...func(Config)) *PCA953xDriver

NewPCA953xDriver creates a new driver with specified i2c interface Params:

conn Connector - the Adaptor to use with this Driver

Optional params:

i2c.WithBus(int):	bus to use with this driver
i2c.WithAddress(int):	address to use with this driver

func (*PCA953xDriver) ReadDutyCyclePercent

func (d *PCA953xDriver) ReadDutyCyclePercent(idx uint8) (float32, error)

ReadDutyCyclePercent get the PWM duty cycle in percent of the given index (0,1)

func (*PCA953xDriver) ReadFrequency

func (d *PCA953xDriver) ReadFrequency(idx uint8) (float32, error)

ReadFrequency read the frequency prescaler in Hz of the given index (0,1)

func (*PCA953xDriver) ReadGPIO

func (d *PCA953xDriver) ReadGPIO(idx uint8) (uint8, error)

ReadGPIO reads a gpio input (index 0-7) to a value

func (*PCA953xDriver) ReadPeriod

func (d *PCA953xDriver) ReadPeriod(idx uint8) (float32, error)

ReadPeriod reads the frequency prescaler in seconds of the given index (0,1)

func (*PCA953xDriver) SetLED

func (d *PCA953xDriver) SetLED(idx uint8, mode PCA953xGPIOMode) error

SetLED sets the mode (LED off, on, PWM0, PWM1) for the LED output (index 0-7)

func (*PCA953xDriver) WriteDutyCyclePercent

func (d *PCA953xDriver) WriteDutyCyclePercent(idx uint8, valPercent float32) error

WriteDutyCyclePercent set the PWM duty cycle of the given index (0,1) with the given value in percent

func (*PCA953xDriver) WriteFrequency

func (d *PCA953xDriver) WriteFrequency(idx uint8, valHz float32) error

WriteFrequency set the content of the frequency prescaler of the given index (0,1) with the given value in Hz

func (*PCA953xDriver) WriteGPIO

func (d *PCA953xDriver) WriteGPIO(idx uint8, val uint8) error

WriteGPIO writes a value to a gpio output (index 0-7)

func (*PCA953xDriver) WritePeriod

func (d *PCA953xDriver) WritePeriod(idx uint8, valSec float32) error

WritePeriod set the content of the frequency prescaler of the given index (0,1) with the given value in seconds

type PCA953xGPIOMode

type PCA953xGPIOMode uint8

PCA953xGPIOMode is used to set the mode while write GPIO

const (

	// PCA953xModeHighImpedance set the GPIO to high (LED off)
	PCA953xModeHighImpedance PCA953xGPIOMode = 0x00
	// PCA953xModeLowImpedance set the GPIO to low (LED on)
	PCA953xModeLowImpedance PCA953xGPIOMode = 0x01
	// PCA953xModePwm0 set the GPIO to PWM (PWM0 & PSC0)
	PCA953xModePwm0 PCA953xGPIOMode = 0x02
	// PCA953xModePwm1 set the GPIO to PWM (PWM1 & PSC1)
	PCA953xModePwm1 PCA953xGPIOMode = 0x03
)

type PCA9685Driver

type PCA9685Driver struct {
	*Driver
}

PCA9685Driver is a Gobot Driver for the PCA9685 16-channel 12-bit PWM/Servo controller.

For example, here is the Adafruit board that uses this chip: https://www.adafruit.com/product/815

func NewPCA9685Driver

func NewPCA9685Driver(c Connector, options ...func(Config)) *PCA9685Driver

NewPCA9685Driver creates a new driver with specified i2c interface Params:

c Connector - the Adaptor to use with this Driver

Optional params:

i2c.WithBus(int):	bus to use with this driver
i2c.WithAddress(int):	address to use with this driver

func (*PCA9685Driver) PwmWrite

func (p *PCA9685Driver) PwmWrite(pin string, val byte) error

PwmWrite writes a PWM signal to the specified channel aka "pin". Value values are from 0-255, to conform to the PwmWriter interface. If you need finer control, please look at SetPWM().

func (*PCA9685Driver) ServoWrite

func (p *PCA9685Driver) ServoWrite(pin string, val byte) error

ServoWrite writes a servo signal to the specified channel aka "pin". Valid values are from 0-180, to conform to the ServoWriter interface. If you need finer control, please look at SetPWM().

func (*PCA9685Driver) SetAllPWM

func (p *PCA9685Driver) SetAllPWM(on uint16, off uint16) error

SetAllPWM sets all channels to a pwm value from 0-4095. Params:

on uint16 - the time to start the pulse
off uint16 - the time to stop the pulse

Most typically you set "on" to a zero value, and then set "off" to your desired duty.

func (*PCA9685Driver) SetPWM

func (p *PCA9685Driver) SetPWM(channel int, on uint16, off uint16) error

SetPWM sets a specific channel to a pwm value from 0-4095. Params:

channel int - the channel to send the pulse
on uint16 - the time to start the pulse
off uint16 - the time to stop the pulse

Most typically you set "on" to a zero value, and then set "off" to your desired duty.

func (*PCA9685Driver) SetPWMFreq

func (p *PCA9685Driver) SetPWMFreq(freq float32) error

SetPWMFreq sets the PWM frequency in Hz between 24Hz and 1526Hz, the default is 200Hz.

type PCF8583Control

type PCF8583Control uint8

PCF8583Control is used to specify control and status register content

const (
	PCF8583CtrlModeClock50 PCF8583Control = 0x10 // clock mode with 50 Hz
	PCF8583CtrlModeCounter PCF8583Control = 0x20 // event counter mode
	PCF8583CtrlModeTest    PCF8583Control = 0x30 // test mode

)

type PCF8583Driver

type PCF8583Driver struct {
	*Driver
	// contains filtered or unexported fields
}

PCF8583Driver is a driver for the PCF8583 clock and calendar chip & 240 x 8-bit bit RAM with 1 address program pin. please refer to data sheet: https://www.nxp.com/docs/en/data-sheet/PCF8583.pdf

0 1 0 1 0 0 0 A0|rd Lowest bit (rd) is mapped to switch between write(0)/read(1), it is not part of the "real" address.

PCF8583 is mainly compatible to PCF8593, so this driver should also work for PCF8593 except RAM calls

This driver was tested with Tinkerboard.

func NewPCF8583Driver

func NewPCF8583Driver(c Connector, options ...func(Config)) *PCF8583Driver

NewPCF8583Driver creates a new driver with specified i2c interface Params:

c Connector - the Adaptor to use with this Driver

Optional params:

i2c.WithBus(int):	bus to use with this driver
i2c.WithAddress(int):	address to use with this driver
i2c.WithPCF8583Mode(PCF8583Control): mode of this driver

func (*PCF8583Driver) ReadCounter

func (d *PCF8583Driver) ReadCounter() (int32, error)

ReadCounter reads the counter registers

func (*PCF8583Driver) ReadRAM

func (d *PCF8583Driver) ReadRAM(address uint8) (uint8, error)

ReadRAM reads a value from a given address (0x00-0xFF)

func (*PCF8583Driver) ReadTime

func (d *PCF8583Driver) ReadTime() (time.Time, error)

ReadTime reads the clock and returns the value

func (*PCF8583Driver) WriteCounter

func (d *PCF8583Driver) WriteCounter(val int32) error

WriteCounter writes the counter registers

func (*PCF8583Driver) WriteRAM

func (d *PCF8583Driver) WriteRAM(address uint8, val uint8) error

WriteRAM writes a value to a given address in memory (0x00-0xFF)

func (*PCF8583Driver) WriteTime

func (d *PCF8583Driver) WriteTime(val time.Time) error

WriteTime setup the clock registers with the given time

type PCF8591Channel

type PCF8591Channel uint8

type PCF8591Driver

type PCF8591Driver struct {
	*Driver

	LastRead [][]byte // for debugging purposes
	// contains filtered or unexported fields
}

PCF8591Driver is a Gobot Driver for the PCF8591 8-bit 4xA/D & 1xD/A converter with i2c (100 kHz) and 3 address pins. The analog inputs can be used as differential inputs in different ways.

All values are linear scaled to 3.3V by default. This can be changed, see example "tinkerboard_pcf8591.go".

Address specification: 1 0 0 1 A2 A1 A0|rd Lowest bit (rd) is mapped to switch between write(0)/read(1), it is not part of the "real" address.

Example: A1,A2=1, others are 0 Address mask => 1001110|1 => real 7-bit address mask 0100 1110 = 0x4E

For example, here is the Adafruit board that uses this chip: https://www.adafruit.com/product/4648

This driver was tested with Tinkerboard and the YL-40 driver.

func NewPCF8591Driver

func NewPCF8591Driver(c Connector, options ...func(Config)) *PCF8591Driver

NewPCF8591Driver creates a new driver with specified i2c interface Params:

c Connector - the Adaptor to use with this Driver

Optional params:

i2c.WithBus(int): bus to use with this driver
i2c.WithAddress(int): address to use with this driver
i2c.WithPCF8591With400kbitStabilization(uint8, uint8): stabilize read in 400 kbit mode

func (*PCF8591Driver) AnalogOutputState

func (p *PCF8591Driver) AnalogOutputState(state bool) error

AnalogOutputState enables or disables the analog output Please note that in case of using the internal oscillator and the auto increment mode the output should not switched off. Otherwise conversion errors could occur.

func (*PCF8591Driver) AnalogRead

func (p *PCF8591Driver) AnalogRead(description string) (int, error)

AnalogRead returns value from analog reading of given input description

Vlsb = (Vref-Vagnd)/256, value = (Van+ - Van-)/Vlsb, Van-=Vagnd for single mode

The first read contains the last converted value (usually the last read). After the channel was switched this means the value of the previous read channel. After power on, the first byte read will be 80h, because the read is one cycle behind.

Important note for 440 kbit mode: With a bus speed of 100 kBit/sec, the ADC conversion has ~80 us + ACK (time to transfer the previous value). This time is the limit for A-D conversion (datasheet 90 us). An i2c bus extender (LTC4311) don't fix it (it seems rather the opposite).

This leads to following behavior:

  • the control byte is not written correctly
  • the transition process takes an additional cycle, very often
  • some circuits takes one cycle longer transition time in addition
  • reading more than one byte by Read([]byte), e.g. to calculate an average, is not sufficient, because some missing integration steps in each conversion (each byte value is a little bit lower than expected)

So, for default, we drop the first three bytes to get the right value.

func (*PCF8591Driver) AnalogWrite

func (p *PCF8591Driver) AnalogWrite(pin string, value int) error

AnalogWrite writes the given value to the analog output (DAC) Vlsb = (Vref-Vagnd)/256, Vaout = Vagnd+Vlsb*value implements the aio.AnalogWriter interface, pin is unused here

type SHT2xDriver

type SHT2xDriver struct {
	*Driver
	Units string
	// contains filtered or unexported fields
}

SHT2xDriver is a Driver for a SHT2x humidity and temperature sensor

func NewSHT2xDriver

func NewSHT2xDriver(c Connector, options ...func(Config)) *SHT2xDriver

NewSHT2xDriver creates a new driver with specified i2c interface Params:

c Connector - the Adaptor to use with this Driver

Optional params:

i2c.WithBus(int):	bus to use with this driver
i2c.WithAddress(int):	address to use with this driver

func (*SHT2xDriver) Accuracy

func (d *SHT2xDriver) Accuracy() byte

func (*SHT2xDriver) Humidity

func (d *SHT2xDriver) Humidity() (float32, error)

Humidity returns the current humidity in percentage of relative humidity

func (*SHT2xDriver) Reset

func (d *SHT2xDriver) Reset() error

Reset does a software reset of the device

func (*SHT2xDriver) SetAccuracy

func (d *SHT2xDriver) SetAccuracy(acc byte) error

SetAccuracy sets the accuracy of the sampling

func (*SHT2xDriver) Temperature

func (d *SHT2xDriver) Temperature() (float32, error)

Temperature returns the current temperature, in celsius degrees.

type SHT3xDriver

type SHT3xDriver struct {
	*Driver
	Units string
	// contains filtered or unexported fields
}

SHT3xDriver is a Driver for a SHT3x humidity and temperature sensor

func NewSHT3xDriver

func NewSHT3xDriver(c Connector, options ...func(Config)) *SHT3xDriver

NewSHT3xDriver creates a new driver with specified i2c interface Params:

c Connector - the Adaptor to use with this Driver

Optional params:

i2c.WithBus(int):	bus to use with this driver
i2c.WithAddress(int):	address to use with this driver

func (*SHT3xDriver) Accuracy

func (s *SHT3xDriver) Accuracy() byte

Accuracy returns the accuracy of the sampling

func (*SHT3xDriver) Heater

func (s *SHT3xDriver) Heater() (bool, error)

Heater returns true if the heater is enabled

func (*SHT3xDriver) Sample

func (s *SHT3xDriver) Sample() (temp float32, rh float32, err error)

Sample returns the temperature in celsius and relative humidity for one sample

func (*SHT3xDriver) SerialNumber

func (s *SHT3xDriver) SerialNumber() (uint32, error)

SerialNumber returns the serial number of the chip

func (*SHT3xDriver) SetAccuracy

func (s *SHT3xDriver) SetAccuracy(a byte) error

SetAccuracy sets the accuracy of the sampling

func (*SHT3xDriver) SetHeater

func (s *SHT3xDriver) SetHeater(enabled bool) error

SetHeater enables or disables the heater on the device

type SSD1306Driver

type SSD1306Driver struct {
	*Driver
	// contains filtered or unexported fields
}

SSD1306Driver is a Gobot Driver for a SSD1306 Display.

func NewSSD1306Driver

func NewSSD1306Driver(c Connector, options ...func(Config)) *SSD1306Driver

NewSSD1306Driver creates a new SSD1306Driver.

Params:

c Connector - the Adaptor to use with this Driver

Optional params:

WithBus(int):    			bus to use with this driver
WithAddress(int):    		address to use with this driver
WithSSD1306DisplayWidth(int): 	width of display (defaults to 128)
WithSSD1306DisplayHeight(int): 	height of display (defaults to 64)
WithSSD1306ExternalVCC:          set true when using an external OLED supply (defaults to false)

func (*SSD1306Driver) Clear

func (s *SSD1306Driver) Clear()

Clear clears the display buffer.

func (*SSD1306Driver) Display

func (s *SSD1306Driver) Display() error

Display sends the memory buffer to the display.

func (*SSD1306Driver) Init

func (s *SSD1306Driver) Init() error

Init initializes the ssd1306 display.

func (*SSD1306Driver) Off

func (s *SSD1306Driver) Off() error

Off turns off the display.

func (*SSD1306Driver) On

func (s *SSD1306Driver) On() error

On turns on the display.

func (*SSD1306Driver) Reset

func (s *SSD1306Driver) Reset() error

Reset clears display.

func (*SSD1306Driver) Set

func (s *SSD1306Driver) Set(x, y, c int)

Set sets a pixel in the buffer.

func (*SSD1306Driver) SetContrast

func (s *SSD1306Driver) SetContrast(contrast byte) error

SetContrast sets the display contrast.

func (*SSD1306Driver) ShowImage

func (s *SSD1306Driver) ShowImage(img image.Image) error

ShowImage takes a standard Go image and displays it in monochrome.

type SSD1306Init

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

SSD1306Init contains the initialization settings for the ssd1306 display.

func (*SSD1306Init) GetSequence

func (i *SSD1306Init) GetSequence() []byte

GetSequence returns the initialization sequence for the ssd1306 display.

type TH02Driver

type TH02Driver struct {
	*Driver
	Units string
	// contains filtered or unexported fields
}

TH02Driver is a Driver for a TH02 humidity and temperature sensor

func NewTH02Driver

func NewTH02Driver(a Connector, options ...func(Config)) *TH02Driver

NewTH02Driver creates a new driver with specified i2c interface. Defaults to:

  • Using high accuracy (lower speed) measurements cycles.
  • Emitting values in "C". If you want F, set Units to "F"

Params:

conn Connector - the Adaptor to use with this Driver

Optional params:

i2c.WithBus(int):	bus to use with this driver
i2c.WithAddress(int):	address to use with this driver

func (*TH02Driver) Accuracy

func (s *TH02Driver) Accuracy() byte

Accuracy returns the accuracy of the sampling (deprecated, use FastMode() instead)

func (*TH02Driver) FastMode

func (s *TH02Driver) FastMode() (bool, error)

FastMode returns true if the fast mode is enabled in the device

func (*TH02Driver) Heater

func (s *TH02Driver) Heater() (bool, error)

Heater returns true if the heater is enabled in the device

func (*TH02Driver) Sample

func (s *TH02Driver) Sample() (temperature float32, relhumidity float32, _ error)

Sample returns the temperature in celsius and relative humidity for one sample

func (*TH02Driver) SerialNumber

func (s *TH02Driver) SerialNumber() (uint8, error)

SerialNumber returns the serial number of the chip

func (*TH02Driver) SetAccuracy

func (s *TH02Driver) SetAccuracy(a byte)

SetAccuracy sets the accuracy of the sampling. (deprecated, use WithFastMode() instead) It will only be used on the next measurement request. Invalid value will use the default of High

func (*TH02Driver) SetHeater

func (s *TH02Driver) SetHeater(state bool) error

SetHeater sets the heater of the device to the given state.

type TSL2561Driver

type TSL2561Driver struct {
	*Driver
	// contains filtered or unexported fields
}

TSL2561Driver is the gobot driver for the Adafruit Digital Luminosity/Lux/Light Sensor

Datasheet: http://www.adafruit.com/datasheets/TSL2561.pdf

Ported from the Adafruit driver at https://github.com/adafruit/Adafruit_TSL2561 by K. Townsend

func NewTSL2561Driver

func NewTSL2561Driver(c Connector, options ...func(Config)) *TSL2561Driver

NewTSL2561Driver creates a new driver for the TSL2561 device.

Params:

c Connector - the Adaptor to use with this Driver

Optional params:

i2c.WithBus(int):		bus to use with this driver
i2c.WithAddress(int):		address to use with this driver
i2c.WithTSL2561Gain1X:		sets the gain to 1X
i2c.WithTSL2561Gain16X:		sets the gain to 16X
i2c.WithTSL2561AutoGain:	turns on auto gain
i2c.WithTSL2561IntegrationTime13MS:	sets integration time to 13ms
i2c.WithTSL2561IntegrationTime101MS: 	sets integration time to 101ms
i2c.WithTSL2561IntegrationTime402MS: 	sets integration time to 402ms

func (*TSL2561Driver) CalculateLux

func (d *TSL2561Driver) CalculateLux(broadband uint16, ir uint16) uint32

CalculateLux converts raw sensor values to the standard SI Lux equivalent. Returns 65536 if the sensor is saturated.

func (*TSL2561Driver) GetLuminocity

func (d *TSL2561Driver) GetLuminocity() (uint16, uint16, error)

GetLuminocity gets the broadband and IR only values from the TSL2561, adjusting gain if auto-gain is enabled

func (*TSL2561Driver) SetGain

func (d *TSL2561Driver) SetGain(gain TSL2561Gain) error

SetGain adjusts the TSL2561 gain (sensitivity to light)

func (*TSL2561Driver) SetIntegrationTime

func (d *TSL2561Driver) SetIntegrationTime(time TSL2561IntegrationTime) error

SetIntegrationTime sets integrations time for the TSL2561

type TSL2561Gain

type TSL2561Gain int

TSL2561Gain is the type of all valid gain settings

const (
	// TSL2561Gain1X gain == 1x
	TSL2561Gain1X TSL2561Gain = 0x00 // No gain
	// TSL2561Gain16X gain == 16x
	TSL2561Gain16X = 0x10 // 16x gain
)

type TSL2561IntegrationTime

type TSL2561IntegrationTime int

TSL2561IntegrationTime is the type of all valid integration time settings

const (
	// TSL2561IntegrationTime13MS integration time 13ms
	TSL2561IntegrationTime13MS TSL2561IntegrationTime = iota // 13.7ms
	// TSL2561IntegrationTime101MS integration time 101ms
	TSL2561IntegrationTime101MS // 101ms
	// TSL2561IntegrationTime402MS integration time 402ms
	TSL2561IntegrationTime402MS // 402ms
)

type WiichuckDriver

type WiichuckDriver struct {
	*Driver

	gobot.Eventer
	// contains filtered or unexported fields
}

WiichuckDriver contains the attributes for the i2c driver

func NewWiichuckDriver

func NewWiichuckDriver(c Connector, options ...func(Config)) *WiichuckDriver

NewWiichuckDriver creates a WiichuckDriver with specified i2c interface.

Params:

c Connector - the Adaptor to use with this Driver

Optional params:

i2c.WithBus(int):	bus to use with this driver
i2c.WithAddress(int):	address to use with this driver

func (*WiichuckDriver) Joystick

func (w *WiichuckDriver) Joystick() map[string]float64

Joystick returns the current value for the joystick

type YL40Driver

type YL40Driver struct {
	*PCF8591Driver
	// contains filtered or unexported fields
}

YL40Driver is a Gobot i2c bus driver for the YL-40 module with light dependent resistor (LDR), thermistor (NTC) and an potentiometer, one additional analog input and one analog output with an connected LED. The module is based on PCF8591 with 4xADC, 1xDAC. For detailed documentation refer to PCF8591Driver.

All values are linear scaled to 3.3V by default. This can be changed, see example "tinkerboard_yl40.go".

This driver was tested with Tinkerboard and this board with temperature & brightness sensor: https://www.makershop.de/download/YL_40_yl40.pdf

func NewYL40Driver

func NewYL40Driver(a Connector, options ...func(Config)) *YL40Driver

NewYL40Driver creates a new driver with specified i2c interface Params:

conn Connector - the Adaptor to use with this Driver

Optional parameters:

 refer to PCF8591Driver for i2c specific options
	refer to TemperatureSensorDriver for temperature sensor specific options
	refer to AnalogSensorDriver for analog input specific options
 refer to AnalogActuatorDriver for analog output specific options

func (*YL40Driver) AIN2

func (y *YL40Driver) AIN2() (float64, error)

AIN2 returns the last read analog input value of the driver

func (*YL40Driver) AOUT

func (y *YL40Driver) AOUT() (float64, error)

AOUT returns the last written value of the driver

func (*YL40Driver) Brightness

func (y *YL40Driver) Brightness() (float64, error)

Brightness returns the last read brightness of the driver

func (*YL40Driver) Halt

func (y *YL40Driver) Halt() error

Halt stops the driver

func (*YL40Driver) Potentiometer

func (y *YL40Driver) Potentiometer() (float64, error)

Potentiometer returns the last read potentiometer value of the driver

func (*YL40Driver) Read

func (y *YL40Driver) Read(pin YL40Pin) (float64, error)

Read returns the current reading from the given pin of the driver For the analog output pin the last written value is returned

func (*YL40Driver) ReadAIN2

func (y *YL40Driver) ReadAIN2() (float64, error)

ReadAIN2 returns the current reading from analog input pin 2 pin of the driver

func (*YL40Driver) ReadBrightness

func (y *YL40Driver) ReadBrightness() (float64, error)

ReadBrightness returns the current reading from brightness pin of the driver

func (*YL40Driver) ReadPotentiometer

func (y *YL40Driver) ReadPotentiometer() (float64, error)

ReadPotentiometer returns the current reading from potentiometer pin of the driver

func (*YL40Driver) ReadTemperature

func (y *YL40Driver) ReadTemperature() (float64, error)

ReadTemperature returns the current reading from temperature pin of the driver

func (*YL40Driver) Start

func (y *YL40Driver) Start() error

Start initializes the driver

func (*YL40Driver) Temperature

func (y *YL40Driver) Temperature() (float64, error)

Temperature returns the last read temperature of the driver

func (*YL40Driver) Value

func (y *YL40Driver) Value(pin YL40Pin) (float64, error)

Value returns the last read or written value from the given pin of the driver

func (*YL40Driver) Write

func (y *YL40Driver) Write(val float64) error

Write writes the given value to the analog output

type YL40Pin

type YL40Pin string

YL40Pin wraps the underlying string type for type safety

const (
	// YL40Bri for brightness sensor, high brightness - low raw value, scaled to 0..1000 (high brightness - high value)
	YL40Bri YL40Pin = "brightness"
	// YL40Temp for temperature sensor, high temperature - low raw value, scaled to °C
	YL40Temp YL40Pin = "temperature"
	// YL40AIN2 is wired to AOUT, scaled to voltage 3.3V
	YL40AIN2 YL40Pin = "analog input AIN2"
	// YL40Poti is adjustable resistor, turn clockwise will lower the raw value, scaled to -100..+100% (clockwise)
	YL40Poti YL40Pin = "potentiometer"
	// YL40AOUT is the analog output
	YL40AOUT YL40Pin = "analog output"
)

Jump to

Keyboard shortcuts

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