i2c

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2016 License: Apache-2.0, Apache-2.0 Imports: 9 Imported by: 0

README

I2C

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

Getting Started

Installing

go get -d -u gobot.io/x/gobot/... && go install gobot.io/x/gobot/platforms/i2c

Hardware Support

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

  • BlinkM
  • Grove Digital Accelerometer
  • Grove RGB LCD
  • HMC6352 Compass
  • JHD1313M1 RGB LCD Display
  • LIDAR-Lite
  • MCP23017 Port Expander
  • MMA7660 3-Axis Accelerometer
  • MPL115A2 Barometer
  • MPU6050 Accelerometer/Gyroscope
  • Wii Nunchuck Controller

More drivers are coming soon...

Documentation

Overview

Package i2c provides Gobot drivers for i2c devices.

Installing:

go get gobot.io/x/gobot/platforms/i2c

For further information refer to i2c README: https://gobot.io/x/gobot/blob/master/drivers/i2c/README.md

Index

Constants

View Source
const (
	Error    = "error"
	Joystick = "joystick"
	C        = "c"
	Z        = "z"
)
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 MPL115A2_REGISTER_A0_COEFF_LSB = 0x05
View Source
const MPL115A2_REGISTER_A0_COEFF_MSB = 0x04
View Source
const MPL115A2_REGISTER_B1_COEFF_LSB = 0x07
View Source
const MPL115A2_REGISTER_B1_COEFF_MSB = 0x06
View Source
const MPL115A2_REGISTER_B2_COEFF_LSB = 0x09
View Source
const MPL115A2_REGISTER_B2_COEFF_MSB = 0x08
View Source
const MPL115A2_REGISTER_C12_COEFF_LSB = 0x0B
View Source
const MPL115A2_REGISTER_C12_COEFF_MSB = 0x0A
View Source
const MPL115A2_REGISTER_PRESSURE_LSB = 0x01
View Source
const MPL115A2_REGISTER_PRESSURE_MSB = 0x00
View Source
const MPL115A2_REGISTER_STARTCONVERSION = 0x12
View Source
const MPL115A2_REGISTER_TEMP_LSB = 0x03
View Source
const MPL115A2_REGISTER_TEMP_MSB = 0x02
View Source
const MPU6050_ACCEL_FS_2 = 0x00
View Source
const MPU6050_ACONFIG_AFS_SEL_BIT = 4
View Source
const MPU6050_ACONFIG_AFS_SEL_LENGTH = 2
View Source
const MPU6050_CLOCK_PLL_XGYRO = 0x01
View Source
const MPU6050_GCONFIG_FS_SEL_BIT = 4
View Source
const MPU6050_GCONFIG_FS_SEL_LENGTH = 2
View Source
const MPU6050_GYRO_FS_250 = 0x00
View Source
const MPU6050_PWR1_CLKSEL_BIT = 2
View Source
const MPU6050_PWR1_CLKSEL_LENGTH = 3
View Source
const MPU6050_PWR1_ENABLE_BIT = 0
View Source
const MPU6050_PWR1_SLEEP_BIT = 6
View Source
const MPU6050_RA_ACCEL_CONFIG = 0x1C
View Source
const MPU6050_RA_ACCEL_XOUT_H = 0x3B
View Source
const MPU6050_RA_GYRO_CONFIG = 0x1B
View Source
const MPU6050_RA_PWR_MGMT_1 = 0x6B

Variables

View Source
var (
	ErrEncryptedBytes  = errors.New("Encrypted bytes")
	ErrNotEnoughBytes  = errors.New("Not enough bytes read")
	ErrNotReady        = errors.New("Device is not ready")
	ErrInvalidPosition = errors.New("Invalid position value")
)
View Source
var CustomLCDChars = map[string][8]byte{
	"é":       [8]byte{130, 132, 142, 145, 159, 144, 142, 128},
	"è":       [8]byte{136, 132, 142, 145, 159, 144, 142, 128},
	"ê":       [8]byte{132, 138, 142, 145, 159, 144, 142, 128},
	"à":       [8]byte{136, 134, 128, 142, 145, 147, 141, 128},
	"â":       [8]byte{132, 138, 128, 142, 145, 147, 141, 128},
	"á":       [8]byte{2, 4, 14, 1, 15, 17, 15, 0},
	"î":       [8]byte{132, 138, 128, 140, 132, 132, 142, 128},
	"í":       [8]byte{2, 4, 12, 4, 4, 4, 14, 0},
	"û":       [8]byte{132, 138, 128, 145, 145, 147, 141, 128},
	"ù":       [8]byte{136, 134, 128, 145, 145, 147, 141, 128},
	"ñ":       [8]byte{14, 0, 22, 25, 17, 17, 17, 0},
	"ó":       [8]byte{2, 4, 14, 17, 17, 17, 14, 0},
	"heart":   [8]byte{0, 10, 31, 31, 31, 14, 4, 0},
	"smiley":  [8]byte{0, 0, 10, 0, 0, 17, 14, 0},
	"frowney": [8]byte{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

This section is empty.

Types

type AdafruitDirection

type AdafruitDirection int

AdafruitDirection declares a type for specification of the motor direction

const (
	AdafruitForward  AdafruitDirection = iota // 0
	AdafruitBackward                          // 1
	AdafruitRelease                           // 2
)

type AdafruitMotorHatDriver

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

AdafruitMotorHatDriver is a driver for the DC+Stepper Motor HAT from Adafruit. The HAT is a Raspberry Pi add-on that can drive up to 4 DC or 2 Stepper motors with full PWM speed control. It has a dedicated PWM driver chip onboard to control both motor direction and speed over I2C.

func NewAdafruitMotorHatDriver

func NewAdafruitMotorHatDriver(a I2c) *AdafruitMotorHatDriver

NewAdafruitMotorHatDriver initializes the internal DCMotor and StepperMotor types. Again the Adafruit Motor Hat supports up to four DC motors and up to two stepper motors.

func (*AdafruitMotorHatDriver) Connection

func (a *AdafruitMotorHatDriver) Connection() gobot.Connection

Connection identifies the particular adapter object

func (*AdafruitMotorHatDriver) Halt

func (a *AdafruitMotorHatDriver) Halt() (err error)

Halt returns true if devices is halted successfully

func (*AdafruitMotorHatDriver) Name

func (a *AdafruitMotorHatDriver) Name() string

Name identifies this driver object

func (*AdafruitMotorHatDriver) RunDCMotor

func (a *AdafruitMotorHatDriver) RunDCMotor(dcMotor int, dir AdafruitDirection) (err error)

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

func (*AdafruitMotorHatDriver) SetDCMotorSpeed

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

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

func (*AdafruitMotorHatDriver) SetMotorHatAddress

func (a *AdafruitMotorHatDriver) SetMotorHatAddress(addr int) (err error)

SetMotorHatAddress sets the I2C address for the DC and Stepper Motor HAT. This addressing flexibility empowers "stacking" the HATs.

func (*AdafruitMotorHatDriver) SetName

func (a *AdafruitMotorHatDriver) SetName(n string)

SetName sets nae for driver

func (*AdafruitMotorHatDriver) SetServoHatAddress

func (a *AdafruitMotorHatDriver) SetServoHatAddress(addr int) (err error)

SetServoHatAddress sets the I2C address for the PWM-Servo Motor HAT. This addressing flexibility empowers "stacking" the HATs.

func (*AdafruitMotorHatDriver) SetServoMotorFreq

func (a *AdafruitMotorHatDriver) SetServoMotorFreq(freq float64) (err error)

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

func (*AdafruitMotorHatDriver) SetServoMotorPulse

func (a *AdafruitMotorHatDriver) SetServoMotorPulse(channel byte, on, off int32) (err 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.

func (*AdafruitMotorHatDriver) SetStepperMotorSpeed

func (a *AdafruitMotorHatDriver) SetStepperMotorSpeed(stepperMotor int, rpm int) (err error)

SetStepperMotorSpeed sets the seconds-per-step for the given Stepper Motor.

func (*AdafruitMotorHatDriver) Start

func (a *AdafruitMotorHatDriver) Start() (err error)

Start initializes both I2C-addressable Adafruit Motor HAT drivers

func (*AdafruitMotorHatDriver) Step

func (a *AdafruitMotorHatDriver) Step(motor, steps int, dir AdafruitDirection, style AdafruitStepStyle) (err error)

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

type AdafruitStepStyle

type AdafruitStepStyle int

AdafruitStepStyle declares a type for specification of the stepper motor rotation

const (
	AdafruitSingle     AdafruitStepStyle = iota // 0
	AdafruitDouble                              // 1
	AdafruitInterleave                          // 2
	AdafruitMicrostep                           // 3
)

type BlinkMDriver

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

BlinkMDriver is a Gobot Driver for a BlinkM LED

func NewBlinkMDriver

func NewBlinkMDriver(a I2c) *BlinkMDriver

NewBlinkMDriver creates a new BlinkMDriver.

Adds the following API commands:

Rgb - sets RGB color
Fade - fades the RGB color
FirmwareVersion - returns the version of the current Frimware
Color - returns the color of the LED.

func (*BlinkMDriver) Color

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

Color returns an array with current rgb color

func (*BlinkMDriver) Connection

func (b *BlinkMDriver) Connection() gobot.Connection

Connection returns the connection for the Driver

func (*BlinkMDriver) Fade

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

Fade removes color using r,g,b params

func (*BlinkMDriver) FirmwareVersion

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

FirmwareVersion returns version with MAYOR.minor format

func (*BlinkMDriver) Halt

func (b *BlinkMDriver) Halt() (err error)

Halt returns true if device is halted successfully

func (*BlinkMDriver) Name

func (b *BlinkMDriver) Name() string

Name returns the Name for the Driver

func (*BlinkMDriver) Rgb

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

Rgb sets color using r,g,b params

func (*BlinkMDriver) SetName

func (b *BlinkMDriver) SetName(n string)

SetName sets the Name for the Driver

func (*BlinkMDriver) Start

func (b *BlinkMDriver) Start() (err error)

Start starts the Driver up, and writes start command

type GroveAccelerometerDriver

type GroveAccelerometerDriver struct {
	*MMA7660Driver
}

func NewGroveAccelerometerDriver

func NewGroveAccelerometerDriver(a I2c) *GroveAccelerometerDriver

NewGroveAccelerometerDriver creates a new driver with specified i2c interface

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 I2c) *GroveLcdDriver

NewGroveLcdDriver creates a new driver with specified i2c interface.

type HMC6352Driver

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

HMC6352Driver is a Driver for a HMC6352 digital compass

func NewHMC6352Driver

func NewHMC6352Driver(a I2c) *HMC6352Driver

NewHMC6352Driver creates a new driver with specified i2c interface

func (*HMC6352Driver) Connection

func (h *HMC6352Driver) Connection() gobot.Connection

Connection returns the connection for this Driver

func (*HMC6352Driver) Halt

func (h *HMC6352Driver) Halt() (err error)

Halt returns true if devices is halted successfully

func (*HMC6352Driver) Heading

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

Heading returns the current heading

func (*HMC6352Driver) Name

func (h *HMC6352Driver) Name() string

Name returns the name for this Driver

func (*HMC6352Driver) SetName

func (h *HMC6352Driver) SetName(n string)

SetName sets the name for this Driver

func (*HMC6352Driver) Start

func (h *HMC6352Driver) Start() (err error)

Start initializes the hmc6352

type I2c

type I2c interface {
	gobot.Adaptor
	I2cStarter
	I2cReader
	I2cWriter
}

type I2cReader

type I2cReader interface {
	I2cRead(address int, len int) (data []byte, err error)
}

type I2cStarter

type I2cStarter interface {
	I2cStart(address int) (err error)
}

type I2cWriter

type I2cWriter interface {
	I2cWrite(address int, buf []byte) (err error)
}

type JHD1313M1Driver

type JHD1313M1Driver struct {
	// 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 I2c) *JHD1313M1Driver

NewJHD1313M1Driver creates a new driver with specified i2c interface.

func (*JHD1313M1Driver) Clear

func (h *JHD1313M1Driver) Clear() error

Clear clears the text on the lCD display.

func (*JHD1313M1Driver) Connection

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

Connection returns the driver connection to the device.

func (*JHD1313M1Driver) Halt

func (h *JHD1313M1Driver) Halt() error

Halt is a noop function.

func (*JHD1313M1Driver) Home

func (h *JHD1313M1Driver) Home() error

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

func (*JHD1313M1Driver) Name

func (h *JHD1313M1Driver) Name() string

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

func (*JHD1313M1Driver) Scroll

func (h *JHD1313M1Driver) Scroll(leftToRight bool) error

func (*JHD1313M1Driver) SetCustomChar

func (h *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 (h *JHD1313M1Driver) SetName(n string)

SetName sets the name for the JHD1313M1 Driver.

func (*JHD1313M1Driver) SetPosition

func (h *JHD1313M1Driver) SetPosition(pos int) (err 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 (h *JHD1313M1Driver) SetRGB(r, g, b int) error

SetRGB sets the Red Green Blue value of backlit.

func (*JHD1313M1Driver) Start

func (h *JHD1313M1Driver) Start() error

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

func (*JHD1313M1Driver) Write

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

Write displays the passed message on the screen.

type LIDARLiteDriver

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

func NewLIDARLiteDriver

func NewLIDARLiteDriver(a I2c) *LIDARLiteDriver

NewLIDARLiteDriver creates a new driver with specified i2c interface

func (*LIDARLiteDriver) Connection

func (h *LIDARLiteDriver) Connection() gobot.Connection

func (*LIDARLiteDriver) Distance

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

Distance returns the current distance in cm

func (*LIDARLiteDriver) Halt

func (h *LIDARLiteDriver) Halt() (err error)

Halt returns true if devices is halted successfully

func (*LIDARLiteDriver) Name

func (h *LIDARLiteDriver) Name() string

func (*LIDARLiteDriver) SetName

func (h *LIDARLiteDriver) SetName(n string)

func (*LIDARLiteDriver) Start

func (h *LIDARLiteDriver) Start() (err error)

Start initialized the LIDAR

type MCP23017Config

type MCP23017Config struct {
	Bank   uint8
	Mirror uint8
	Seqop  uint8
	Disslw uint8
	Haen   uint8
	Odr    uint8
	Intpol uint8
}

MCP23017Config contains the device configuration for the IOCON register. These fields should only be set with values 0 or 1.

func (*MCP23017Config) GetUint8Value

func (mc *MCP23017Config) GetUint8Value() uint8

GetUint8Value returns the configuration data as a packed value.

type MCP23017Driver

type MCP23017Driver struct {
	gobot.Commander
	gobot.Eventer
	// contains filtered or unexported fields
}

MCP23017Driver contains the driver configuration parameters.

func NewMCP23017Driver

func NewMCP23017Driver(a I2c, conf MCP23017Config, deviceAddress int, v ...time.Duration) *MCP23017Driver

NewMCP23017Driver creates a new driver with specified i2c interface.

func (*MCP23017Driver) Connection

func (m *MCP23017Driver) Connection() gobot.Connection

Connection returns the I2c connection.

func (*MCP23017Driver) Halt

func (m *MCP23017Driver) Halt() (err error)

Halt stops the driver.

func (*MCP23017Driver) Name

func (m *MCP23017Driver) Name() string

Name return the driver name.

func (*MCP23017Driver) PinMode

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

PinMode set pin mode val (0 output 1 input) port (A or B).

func (*MCP23017Driver) ReadGPIO

func (m *MCP23017Driver) ReadGPIO(pin uint8, portStr string) (val uint8, err 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, val uint8, portStr string) (err error)

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

func (*MCP23017Driver) SetName

func (m *MCP23017Driver) SetName(n string)

SetName set the driver name.

func (*MCP23017Driver) SetPullUp

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

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

func (*MCP23017Driver) Start

func (m *MCP23017Driver) Start() (errs error)

Start writes the device configuration.

func (*MCP23017Driver) WriteGPIO

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

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

type MMA7660Driver

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

func NewMMA7660Driver

func NewMMA7660Driver(a I2c) *MMA7660Driver

NewMMA7660Driver creates a new driver with specified i2c interface

func (*MMA7660Driver) Acceleration

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

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

func (*MMA7660Driver) Connection

func (h *MMA7660Driver) Connection() gobot.Connection

func (*MMA7660Driver) Halt

func (h *MMA7660Driver) Halt() (err error)

Halt returns true if devices is halted successfully

func (*MMA7660Driver) Name

func (h *MMA7660Driver) Name() string

func (*MMA7660Driver) SetName

func (h *MMA7660Driver) SetName(n string)

func (*MMA7660Driver) Start

func (h *MMA7660Driver) Start() (err error)

Start initialized the mma7660

func (*MMA7660Driver) XYZ

func (h *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 {
	gobot.Eventer
	A0          float32
	B1          float32
	B2          float32
	C12         float32
	Pressure    float32
	Temperature float32
	// contains filtered or unexported fields
}

func NewMPL115A2Driver

func NewMPL115A2Driver(a I2c, v ...time.Duration) *MPL115A2Driver

NewMPL115A2Driver creates a new driver with specified i2c interface

func (*MPL115A2Driver) Connection

func (h *MPL115A2Driver) Connection() gobot.Connection

func (*MPL115A2Driver) Halt

func (h *MPL115A2Driver) Halt() (err error)

Halt returns true if devices is halted successfully

func (*MPL115A2Driver) Name

func (h *MPL115A2Driver) Name() string

func (*MPL115A2Driver) SetName

func (h *MPL115A2Driver) SetName(n string)

func (*MPL115A2Driver) Start

func (h *MPL115A2Driver) Start() (err error)

Start writes initialization bytes and reads from adaptor using specified interval to accelerometer andtemperature data

type MPU6050Driver

type MPU6050Driver struct {
	Accelerometer ThreeDData
	Gyroscope     ThreeDData
	Temperature   int16
	gobot.Eventer
	// contains filtered or unexported fields
}

func NewMPU6050Driver

func NewMPU6050Driver(a I2c, v ...time.Duration) *MPU6050Driver

NewMPU6050Driver creates a new driver with specified i2c interface

func (*MPU6050Driver) Connection

func (h *MPU6050Driver) Connection() gobot.Connection

func (*MPU6050Driver) Halt

func (h *MPU6050Driver) Halt() (err error)

Halt returns true if devices is halted successfully

func (*MPU6050Driver) Name

func (h *MPU6050Driver) Name() string

func (*MPU6050Driver) SetName

func (h *MPU6050Driver) SetName(n string)

func (*MPU6050Driver) Start

func (h *MPU6050Driver) Start() (err error)

Start writes initialization bytes and reads from adaptor using specified interval to accelerometer andtemperature data

type ThreeDData

type ThreeDData struct {
	X int16
	Y int16
	Z int16
}

type WiichuckDriver

type WiichuckDriver struct {
	gobot.Eventer
	// contains filtered or unexported fields
}

func NewWiichuckDriver

func NewWiichuckDriver(a I2c, v ...time.Duration) *WiichuckDriver

NewWiichuckDriver creates a WiichuckDriver with specified i2c interface.

It adds the following events:

"z"- Gets triggered every interval amount of time if the z button is pressed
"c" - Gets triggered every interval amount of time if the c button is pressed
"joystick" - Gets triggered every "interval" amount of time if a joystick event occurred, you can access values x, y
"error" - Gets triggered whenever the WiichuckDriver encounters an error

func (*WiichuckDriver) Connection

func (w *WiichuckDriver) Connection() gobot.Connection

func (*WiichuckDriver) Halt

func (w *WiichuckDriver) Halt() (err error)

Halt returns true if driver is halted successfully

func (*WiichuckDriver) Name

func (w *WiichuckDriver) Name() string

func (*WiichuckDriver) SetName

func (w *WiichuckDriver) SetName(n string)

func (*WiichuckDriver) Start

func (w *WiichuckDriver) Start() (errs error)

Start initilizes i2c and reads from adaptor using specified interval to update with new value

Jump to

Keyboard shortcuts

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