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 GroveAccelerometerDriver
- type GroveLcdDriver
- type HMC6352Driver
- type I2c
- type I2cReader
- type I2cStarter
- type I2cWriter
- type JHD1313M1Driver
- func (h *JHD1313M1Driver) Clear() (err error)
- func (h *JHD1313M1Driver) Connection() gobot.Connection
- func (h *JHD1313M1Driver) Halt() (errs []error)
- func (h *JHD1313M1Driver) Home() (err error)
- func (h *JHD1313M1Driver) Name() string
- func (h *JHD1313M1Driver) SetRGB(r, g, b int) (err error)
- func (h *JHD1313M1Driver) Start() (errs []error)
- func (h *JHD1313M1Driver) Write(message string) (err error)
- type LIDARLiteDriver
- type MMA7660Driver
- func (h *MMA7660Driver) Acceleration(x, y, z float64) (ax, ay, az float64)
- func (h *MMA7660Driver) Connection() gobot.Connection
- func (h *MMA7660Driver) Halt() (errs []error)
- func (h *MMA7660Driver) Name() string
- func (h *MMA7660Driver) Start() (errs []error)
- func (h *MMA7660Driver) XYZ() (x float64, y float64, z float64, err error)
- type MPL115A2Driver
- type MPU6050Driver
- type ThreeDData
- type WiichuckDriver
Constants ¶
const ( Error = "error" Joystick = "joystick" C = "c" Z = "z" )
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 )
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 )
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 ¶
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 GroveAccelerometerDriver ¶
type GroveAccelerometerDriver struct {
*MMA7660Driver
}
func NewGroveAccelerometerDriver ¶
func NewGroveAccelerometerDriver(a I2c, name string) *GroveAccelerometerDriver
type GroveLcdDriver ¶
type GroveLcdDriver struct {
*JHD1313M1Driver
}
func NewGroveLcdDriver ¶
func NewGroveLcdDriver(a I2c, name string) *GroveLcdDriver
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 I2cStarter ¶
type JHD1313M1Driver ¶
type JHD1313M1Driver struct {
// contains filtered or unexported fields
}
func NewJHD1313M1Driver ¶
func NewJHD1313M1Driver(a I2c, name string) *JHD1313M1Driver
NewJHD1313M1Driver creates a new driver with specified name and i2c interface
func (*JHD1313M1Driver) Clear ¶
func (h *JHD1313M1Driver) Clear() (err error)
func (*JHD1313M1Driver) Connection ¶
func (h *JHD1313M1Driver) Connection() gobot.Connection
func (*JHD1313M1Driver) Halt ¶
func (h *JHD1313M1Driver) Halt() (errs []error)
func (*JHD1313M1Driver) Home ¶
func (h *JHD1313M1Driver) Home() (err error)
func (*JHD1313M1Driver) Name ¶
func (h *JHD1313M1Driver) Name() string
func (*JHD1313M1Driver) SetRGB ¶
func (h *JHD1313M1Driver) SetRGB(r, g, b int) (err error)
func (*JHD1313M1Driver) Start ¶
func (h *JHD1313M1Driver) Start() (errs []error)
func (*JHD1313M1Driver) Write ¶
func (h *JHD1313M1Driver) Write(message string) (err error)
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 MMA7660Driver ¶
type MMA7660Driver struct {
// contains filtered or unexported fields
}
func NewMMA7660Driver ¶
func NewMMA7660Driver(a I2c, name string) *MMA7660Driver
NewMMA7660Driver creates a new driver with specified name and 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() (errs []error)
Halt returns true if devices is halted successfully
func (*MMA7660Driver) Name ¶
func (h *MMA7660Driver) Name() string
func (*MMA7660Driver) Start ¶
func (h *MMA7660Driver) Start() (errs []error)
Start initialized 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, 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