i2c

package
v0.0.0-...-21b411a Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2014 License: Apache-2.0, Apache-2.0 Imports: 6 Imported by: 0

README

I2C

This package provides drivers for i2cdevices . It is normally not used directly, but instead is registered by an adaptor such as firmata that supports the needed interfaces for i2c devices.

Getting Started

Installing

go get github.com/hybridgroup/gobot && go install github.com/hybridgroup/gobot/platforms/i2c

Hardware Support

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

  • BlinkM
  • HMC6352 Digital Compass
  • MPL115A2 Barometer/Temperature Sensor
  • MPU6050 Accelerometer/Gyroscope
  • Wii Nunchuck Controller

More drivers are coming soon...

Documentation

Overview

Package i2c provides Gobot drivers for i2c devices.

Installing:

go get github.com/hybridgroup/gobot/platforms/i2c

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

Index

Constants

View Source
const (
	Error    = "error"
	Joystick = "joystick"
	C        = "c"
	Z        = "z"
)
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_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")
)

Functions

This section is empty.

Types

type BlinkMDriver

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

func NewBlinkMDriver

func NewBlinkMDriver(a I2c, name string) *BlinkMDriver

NewBlinkMDriver creates a new BlinkMDriver with specified name.

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

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() (errs []error)

Halt returns true if device is halted successfully

func (*BlinkMDriver) Name

func (b *BlinkMDriver) Name() string

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) Start

func (b *BlinkMDriver) Start() (errs []error)

Start writes start bytes

type HMC6352Driver

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

func NewHMC6352Driver

func NewHMC6352Driver(a I2c, name string) *HMC6352Driver

NewHMC6352Driver creates a new driver with specified name and i2c interface

func (*HMC6352Driver) Connection

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

func (*HMC6352Driver) Halt

func (h *HMC6352Driver) Halt() (errs []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

func (*HMC6352Driver) Start

func (h *HMC6352Driver) Start() (errs []error)

Start initialized the hmc6352

type I2c

type I2c interface {
	gobot.Adaptor
	I2cStart(address byte) (err error)
	I2cRead(len uint) (data []byte, err error)
	I2cWrite(buf []byte) (err error)
}

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, name string, v ...time.Duration) *MPL115A2Driver

NewMPL115A2Driver creates a new driver with specified name and 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) Start

func (h *MPL115A2Driver) Start() (errs []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, name string, v ...time.Duration) *MPU6050Driver

NewMPU6050Driver creates a new driver with specified name and i2c interface

func (*MPU6050Driver) Connection

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

func (*MPU6050Driver) Halt

func (h *MPU6050Driver) Halt() (errs []error)

Halt returns true if devices is halted successfully

func (*MPU6050Driver) Name

func (h *MPU6050Driver) Name() string

func (*MPU6050Driver) Start

func (h *MPU6050Driver) Start() (errs []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, name string, v ...time.Duration) *WiichuckDriver

NewWiichuckDriver creates a WiichuckDriver with specified i2c interface and name.

It adds the following events:

"z"- Get's triggered every interval amount of time if the z button is pressed
"c" - Get's triggered every interval amount of time if the c button is pressed
"joystick" - Get's triggered every "interval" amount of time if a joystick event occured, you can access values x, y

func (*WiichuckDriver) Connection

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

func (*WiichuckDriver) Halt

func (w *WiichuckDriver) Halt() (errs []error)

Halt returns true if driver is halted successfully

func (*WiichuckDriver) Name

func (w *WiichuckDriver) Name() 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