2015-07-10 23:56:39 +08:00
|
|
|
package i2c
|
|
|
|
|
2015-10-23 08:37:31 +08:00
|
|
|
// 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
|
2015-07-10 23:56:39 +08:00
|
|
|
type GroveLcdDriver struct {
|
|
|
|
*JHD1313M1Driver
|
|
|
|
}
|
|
|
|
|
2017-02-10 18:44:36 +08:00
|
|
|
// GroveAccelerometerDriver is a driver for the MMA7660 accelerometer
|
|
|
|
type GroveAccelerometerDriver struct {
|
|
|
|
*MMA7660Driver
|
|
|
|
}
|
|
|
|
|
2016-09-25 20:08:18 +08:00
|
|
|
// NewGroveLcdDriver creates a new driver with specified i2c interface.
|
2017-02-09 23:47:11 +08:00
|
|
|
// Params:
|
2017-02-10 18:08:32 +08:00
|
|
|
// conn Connector - the Adaptor to use with this Driver
|
2017-02-09 23:47:11 +08:00
|
|
|
//
|
|
|
|
// Optional params:
|
2017-02-10 18:08:32 +08:00
|
|
|
// i2c.WithBus(int): bus to use with this driver
|
|
|
|
// i2c.WithAddress(int): address to use with this driver
|
2017-02-09 23:47:11 +08:00
|
|
|
//
|
2017-02-10 18:08:32 +08:00
|
|
|
func NewGroveLcdDriver(a Connector, options ...func(Config)) *GroveLcdDriver {
|
2017-02-09 18:23:36 +08:00
|
|
|
lcd := &GroveLcdDriver{
|
2016-09-25 20:08:18 +08:00
|
|
|
JHD1313M1Driver: NewJHD1313M1Driver(a),
|
2015-07-10 23:56:39 +08:00
|
|
|
}
|
2017-02-09 18:23:36 +08:00
|
|
|
|
|
|
|
for _, option := range options {
|
|
|
|
option(lcd)
|
|
|
|
}
|
|
|
|
|
|
|
|
return lcd
|
2015-07-10 23:56:39 +08:00
|
|
|
}
|
|
|
|
|
2016-09-25 20:08:18 +08:00
|
|
|
// NewGroveAccelerometerDriver creates a new driver with specified i2c interface
|
2017-02-10 18:08:32 +08:00
|
|
|
// Params:
|
|
|
|
// conn Connector - the Adaptor to use with this Driver
|
|
|
|
//
|
|
|
|
// Optional params:
|
|
|
|
// i2c.WithBus(int): bus to use with this driver
|
|
|
|
// i2c.WithAddress(int): address to use with this driver
|
|
|
|
//
|
|
|
|
func NewGroveAccelerometerDriver(a Connector, options ...func(Config)) *GroveAccelerometerDriver {
|
2017-02-09 18:23:36 +08:00
|
|
|
mma := &GroveAccelerometerDriver{
|
2016-09-25 20:08:18 +08:00
|
|
|
MMA7660Driver: NewMMA7660Driver(a),
|
2015-07-10 23:56:39 +08:00
|
|
|
}
|
2017-02-09 18:23:36 +08:00
|
|
|
|
|
|
|
for _, option := range options {
|
|
|
|
option(mma)
|
|
|
|
}
|
|
|
|
|
|
|
|
return mma
|
2015-07-10 23:56:39 +08:00
|
|
|
}
|