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
- Variables
- type BlinkMDriver
- func (b *BlinkMDriver) Color() (color []byte, err error)
- func (b *BlinkMDriver) Connection() gobot.Connection
- func (b *BlinkMDriver) Fade(red byte, green byte, blue byte) (err error)
- func (b *BlinkMDriver) FirmwareVersion() (version string, err error)
- func (b *BlinkMDriver) Halt() (errs []error)
- func (b *BlinkMDriver) Name() string
- func (b *BlinkMDriver) Rgb(red byte, green byte, blue byte) (err error)
- func (b *BlinkMDriver) Start() (errs []error)
- type HMC6352Driver
- type I2c
- type LIDARLiteDriver
- type MPL115A2Driver
- type MPU6050Driver
- type ThreeDData
- type WiichuckDriver
Constants ¶
const ( Error = "error" Joystick = "joystick" C = "c" Z = "z" )
const MPL115A2_REGISTER_A0_COEFF_LSB = 0x05
const MPL115A2_REGISTER_A0_COEFF_MSB = 0x04
const MPL115A2_REGISTER_B1_COEFF_LSB = 0x07
const MPL115A2_REGISTER_B1_COEFF_MSB = 0x06
const MPL115A2_REGISTER_B2_COEFF_LSB = 0x09
const MPL115A2_REGISTER_B2_COEFF_MSB = 0x08
const MPL115A2_REGISTER_C12_COEFF_LSB = 0x0B
const MPL115A2_REGISTER_C12_COEFF_MSB = 0x0A
const MPL115A2_REGISTER_PRESSURE_LSB = 0x01
const MPL115A2_REGISTER_PRESSURE_MSB = 0x00
const MPL115A2_REGISTER_STARTCONVERSION = 0x12
const MPL115A2_REGISTER_TEMP_LSB = 0x03
const MPL115A2_REGISTER_TEMP_MSB = 0x02
const MPU6050_ACCEL_FS_2 = 0x00
const MPU6050_ACONFIG_AFS_SEL_BIT = 4
const MPU6050_ACONFIG_AFS_SEL_LENGTH = 2
const MPU6050_CLOCK_PLL_XGYRO = 0x01
const MPU6050_GCONFIG_FS_SEL_BIT = 4
const MPU6050_GCONFIG_FS_SEL_LENGTH = 2
const MPU6050_GYRO_FS_250 = 0x00
const MPU6050_PWR1_CLKSEL_BIT = 2
const MPU6050_PWR1_CLKSEL_LENGTH = 3
const MPU6050_PWR1_SLEEP_BIT = 6
const MPU6050_RA_ACCEL_CONFIG = 0x1C
const MPU6050_RA_ACCEL_XOUT_H = 0x3B
const MPU6050_RA_GYRO_CONFIG = 0x1B
const MPU6050_RA_PWR_MGMT_1 = 0x6B
Variables ¶
var ( ErrEncryptedBytes = errors.New("Encrypted bytes") ErrNotEnoughBytes = errors.New("Not enough bytes read") )
Functions ¶
This section is empty.
Types ¶
type BlinkMDriver ¶
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
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 LIDARLiteDriver ¶
type LIDARLiteDriver struct {
// contains filtered or unexported fields
}
func NewLIDARLiteDriver ¶
func NewLIDARLiteDriver(a I2c, name string) *LIDARLiteDriver
NewLIDARLiteDriver creates a new driver with specified name and 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
func (*LIDARLiteDriver) Halt ¶
func (h *LIDARLiteDriver) Halt() (errs []error)
Halt returns true if devices is halted successfully
func (*LIDARLiteDriver) Name ¶
func (h *LIDARLiteDriver) Name() string
func (*LIDARLiteDriver) Start ¶
func (h *LIDARLiteDriver) Start() (errs []error)
Start initialized the LIDAR
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 WiichuckDriver ¶
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