gobot.io/x/gobot@v1.16.0/drivers/i2c/grove_drivers.go (about)

     1  package i2c
     2  
     3  // GroveLcdDriver is a driver for the Jhd1313m1 LCD display which has two i2c addreses,
     4  // one belongs to a controller and the other controls solely the backlight.
     5  // This module was tested with the Seed Grove LCD RGB Backlight v2.0 display which requires 5V to operate.
     6  // http://www.seeedstudio.com/wiki/Grove_-_LCD_RGB_Backlight
     7  type GroveLcdDriver struct {
     8  	*JHD1313M1Driver
     9  }
    10  
    11  // GroveAccelerometerDriver is a driver for the MMA7660 accelerometer
    12  type GroveAccelerometerDriver struct {
    13  	*MMA7660Driver
    14  }
    15  
    16  // NewGroveLcdDriver creates a new driver with specified i2c interface.
    17  // Params:
    18  //		conn Connector - the Adaptor to use with this Driver
    19  //
    20  // Optional params:
    21  //		i2c.WithBus(int):	bus to use with this driver
    22  //		i2c.WithAddress(int):	address to use with this driver
    23  //
    24  func NewGroveLcdDriver(a Connector, options ...func(Config)) *GroveLcdDriver {
    25  	lcd := &GroveLcdDriver{
    26  		JHD1313M1Driver: NewJHD1313M1Driver(a),
    27  	}
    28  
    29  	for _, option := range options {
    30  		option(lcd)
    31  	}
    32  
    33  	return lcd
    34  }
    35  
    36  // NewGroveAccelerometerDriver creates a new driver with specified i2c interface
    37  // Params:
    38  //		conn Connector - the Adaptor to use with this Driver
    39  //
    40  // Optional params:
    41  //		i2c.WithBus(int):	bus to use with this driver
    42  //		i2c.WithAddress(int):	address to use with this driver
    43  //
    44  func NewGroveAccelerometerDriver(a Connector, options ...func(Config)) *GroveAccelerometerDriver {
    45  	mma := &GroveAccelerometerDriver{
    46  		MMA7660Driver: NewMMA7660Driver(a),
    47  	}
    48  
    49  	for _, option := range options {
    50  		option(mma)
    51  	}
    52  
    53  	return mma
    54  }