From f14be69810c25907473c0eebdf026b88ec6af8d8 Mon Sep 17 00:00:00 2001 From: M-A Date: Sun, 26 Mar 2017 16:06:50 -0400 Subject: [PATCH] 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. --- devices/bme280/bme280_test.go | 2 +- devices/ds248x/ds248x_test.go | 4 ++-- devices/ssd1306/ssd1306_test.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/devices/bme280/bme280_test.go b/devices/bme280/bme280_test.go index ebc86bb..a4a3419 100644 --- a/devices/bme280/bme280_test.go +++ b/devices/bme280/bme280_test.go @@ -140,7 +140,7 @@ func TestCalibrationInt(t *testing.T) { // func Example() { - bus, err := i2c.New(-1) + bus, err := i2c.OpenByName("") if err != nil { log.Fatalf("failed to open I²C: %v", err) } diff --git a/devices/ds248x/ds248x_test.go b/devices/ds248x/ds248x_test.go index 961c2a3..9c30040 100644 --- a/devices/ds248x/ds248x_test.go +++ b/devices/ds248x/ds248x_test.go @@ -32,7 +32,7 @@ func TestInit(t *testing.T) { func Example() { // Open the I²C bus to which the DS248x is connected. - i2cBus, err := i2c.New(-1) + i2cBus, err := i2c.OpenByName("") if err != nil { fmt.Println(err) return @@ -72,7 +72,7 @@ func TestRecordInit(t *testing.T) { } host.Init() - i2cReal, err := i2c.New(-1) + i2cReal, err := i2c.OpenByName("") if err != nil { t.Fatal(err) } diff --git a/devices/ssd1306/ssd1306_test.go b/devices/ssd1306/ssd1306_test.go index 1100863..5a11f14 100644 --- a/devices/ssd1306/ssd1306_test.go +++ b/devices/ssd1306/ssd1306_test.go @@ -77,7 +77,7 @@ func TestDraw1D(t *testing.T) { // func Example() { - bus, err := i2c.New(-1) + bus, err := i2c.OpenByName("") if err != nil { log.Fatalf("failed to open I²C: %v", err) }