i2c

package
v0.0.0-...-df99c63 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2014 License: Apache-2.0, Apache-2.0 Imports: 5 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
  • 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 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

This section is empty.

Functions

This section is empty.

Types

type BlinkMDriver

type BlinkMDriver struct {
	gobot.Driver
}

func NewBlinkMDriver

func NewBlinkMDriver(a I2cInterface, 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() []byte

Color returns an array with current rgb color

func (*BlinkMDriver) Fade

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

Fade removes color using r,g,b params

func (*BlinkMDriver) FirmwareVersion

func (b *BlinkMDriver) FirmwareVersion() string

FirmwareVersion returns version with MAYOR.minor format

func (*BlinkMDriver) Halt

func (b *BlinkMDriver) Halt() bool

Halt returns true if device is halted successfully

func (*BlinkMDriver) Init

func (b *BlinkMDriver) Init() bool

Init returns true if device is initialized correctly

func (*BlinkMDriver) Rgb

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

Rgb sets color using r,g,b params

func (*BlinkMDriver) Start

func (b *BlinkMDriver) Start() bool

Start writes start bytes and resets color

type HMC6352Driver

type HMC6352Driver struct {
	gobot.Driver
	Heading uint16
}

func NewHMC6352Driver

func NewHMC6352Driver(a I2cInterface, name string) *HMC6352Driver

NewHMC6352Driver creates a new driver with specified name and i2c interface

func (*HMC6352Driver) Halt

func (h *HMC6352Driver) Halt() bool

Halt returns true if devices is halted successfully

func (*HMC6352Driver) Init

func (h *HMC6352Driver) Init() bool

Init returns true if device is initialized correctly

func (*HMC6352Driver) Start

func (h *HMC6352Driver) Start() bool

Start writes initialization bytes and reads from adaptor using specified interval to update Heading

type I2cInterface

type I2cInterface interface {
	I2cStart(byte)
	I2cRead(uint) []byte
	I2cWrite([]byte)
}

type MPL115A2Driver

type MPL115A2Driver struct {
	gobot.Driver
	A0          float32
	B1          float32
	B2          float32
	C12         float32
	Pressure    float32
	Temperature float32
}

func NewMPL115A2Driver

func NewMPL115A2Driver(a I2cInterface, name string) *MPL115A2Driver

NewMPL115A2Driver creates a new driver with specified name and i2c interface

func (*MPL115A2Driver) Halt

func (h *MPL115A2Driver) Halt() bool

Halt returns true if devices is halted successfully

func (*MPL115A2Driver) Init

func (h *MPL115A2Driver) Init() bool

Init returns true if device is initialized correctly

func (*MPL115A2Driver) Start

func (h *MPL115A2Driver) Start() bool

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

type MPU6050Driver

type MPU6050Driver struct {
	gobot.Driver
	Accelerometer ThreeDData
	Gyroscope     ThreeDData
	Temperature   int16
}

func NewMPU6050Driver

func NewMPU6050Driver(a I2cInterface, name string) *MPU6050Driver

NewMPU6050Driver creates a new driver with specified name and i2c interface

func (*MPU6050Driver) Halt

func (h *MPU6050Driver) Halt() bool

Halt returns true if devices is halted successfully

func (*MPU6050Driver) Init

func (h *MPU6050Driver) Init() bool

Init returns true if device is initialized correctly

func (*MPU6050Driver) Start

func (h *MPU6050Driver) Start() bool

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.Driver
	// contains filtered or unexported fields
}

func NewWiichuckDriver

func NewWiichuckDriver(a I2cInterface, name string) *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) Halt

func (w *WiichuckDriver) Halt() bool

Halt returns true if driver is halted successfully

func (*WiichuckDriver) Init

func (w *WiichuckDriver) Init() bool

Init returns true if driver is initialized correctly

func (*WiichuckDriver) Start

func (w *WiichuckDriver) Start() bool

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