Documentation
¶
Overview ¶
Package i2cmux provides a API for using a I²C(i2c) multiplexer such as a NXP PCA9548A.
Example ¶
package main import ( "fmt" "log" "github.com/NeuralSpaz/i2cmux" "periph.io/x/periph/conn/physic" "periph.io/x/periph/devices/bmxx80" "periph.io/x/periph/host" ) func main() { // Make sure periph is initialized. if _, err := host.Init(); err != nil { log.Fatal(err) } mux, err := i2cmux.New("/dev/i2c-1", i2cmux.Address(0x40)) if err != nil { log.Fatalln(err) } // register the channel with the mux ch, err := mux.RegisterChannel(0) if err != nil { log.Fatalln(err) } // use the mux channel like any other i2c.Bus example here taken from the // bmp180/280 example d, err := bmxx80.NewI2C(ch, 0x76, &bmxx80.DefaultOpts) if err != nil { log.Fatalf("failed to initialize bme280: %v", err) } e := physic.Env{} if err := d.Sense(&e); err != nil { log.Fatal(err) } fmt.Printf("%8s %10s %9s\n", e.Temperature, e.Pressure, e.Humidity) }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Channel ¶
type Channel struct {
// contains filtered or unexported fields
}
Channel implements the i2c.Bus interface through the Mux
Click to show internal directories.
Click to hide internal directories.