i2c: convert from "number only" to named buses plus aliases (#119)

This is a breaking change.

This is closer to how gpio behaves yet different in practice because of the
different challenges.

spi will be updated later to behave the same. Add support for aliases, which is
very useful, and it permits the CLI tools to accept a free form string to
specify the bus name.

- Increase test coverage of i2c and i2ctest to 100%.
- Add i2c.Pins implementation to i2ctest.Playback.
pull/1/head
M-A 9 years ago committed by GitHub
parent d7c75db11b
commit f14be69810

@ -140,7 +140,7 @@ func TestCalibrationInt(t *testing.T) {
// //
func Example() { func Example() {
bus, err := i2c.New(-1) bus, err := i2c.OpenByName("")
if err != nil { if err != nil {
log.Fatalf("failed to open I²C: %v", err) log.Fatalf("failed to open I²C: %v", err)
} }

@ -32,7 +32,7 @@ func TestInit(t *testing.T) {
func Example() { func Example() {
// Open the I²C bus to which the DS248x is connected. // Open the I²C bus to which the DS248x is connected.
i2cBus, err := i2c.New(-1) i2cBus, err := i2c.OpenByName("")
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
return return
@ -72,7 +72,7 @@ func TestRecordInit(t *testing.T) {
} }
host.Init() host.Init()
i2cReal, err := i2c.New(-1) i2cReal, err := i2c.OpenByName("")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }

@ -77,7 +77,7 @@ func TestDraw1D(t *testing.T) {
// //
func Example() { func Example() {
bus, err := i2c.New(-1) bus, err := i2c.OpenByName("")
if err != nil { if err != nil {
log.Fatalf("failed to open I²C: %v", err) log.Fatalf("failed to open I²C: %v", err)
} }

Loading…
Cancel
Save