func NewAQM0802(busNumber, addr byte) (lcd *AQM0802, err error) { lcd = new(AQM0802) lcd.bus, err = i2c.Bus(busNumber) if err != nil { return } lcd.addr = addr return }
func (l *SSD1306) Init(busNumber byte, addr byte, height int, width int) error { var err error l.bus, err = i2c.Bus(busNumber) l.bmap = &bitmap{} l.bmap.Init(width, height) l.addr = addr l.height = height l.width = width l.pages = height / 8 return err }
func (dev *Device) Init(addr, busNum byte, mode Mode) (err error) { if dev.bus, err = i2c.Bus(busNum); err != nil { return } dev.Addr = addr dev.BusNum = busNum dev.Mode = mode dev.readCalibrationData() return }
// New creates a new MCP4725 driver on a i2c bus of the Edison func New(bus byte, address byte) (*MCP4725, error) { switch bus { case 6: gpio.EnableI2C(i2c6SCL) gpio.EnableI2C(i2c6SDA) gpio.EnableFastI2C(6) default: log.Panic("Unknown i2c bus") } i2c, err := i2c.Bus(bus) if err != nil { return nil, err } return &MCP4725{bus: bus, address: address, i2c: i2c}, nil }
func NewPiglow() (piglow *Piglow, err error) { piglow = new(Piglow) piglow.values = [18]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} i2cbus, err = i2c.Bus(i2c_bus_num) if err != nil { return nil, err } write_err := i2cbus.WriteByte(i2c_addr, CMD_ENABLE_OUTPUT, 0x01) if write_err != nil { return nil, write_err } enable_err := i2cbus.WriteByteBlock(i2c_addr, CMD_ENABLE_LEDS, []byte{0xFF, 0xFF, 0xFF}) if enable_err != nil { return nil, enable_err } return }