From 30df5dc11e51175e0b8155d16b5fbb2d2ea9c2cc Mon Sep 17 00:00:00 2001 From: deadprogram Date: Sat, 15 Apr 2017 18:40:41 +0200 Subject: [PATCH] aio: only need to support AnalogReader interface Signed-off-by: deadprogram --- drivers/aio/aio.go | 4 +--- platforms/microbit/io_pin_driver.go | 13 ++----------- platforms/microbit/io_pin_driver_test.go | 5 ----- 3 files changed, 3 insertions(+), 19 deletions(-) diff --git a/drivers/aio/aio.go b/drivers/aio/aio.go index 7d340ccc..12fc03a9 100644 --- a/drivers/aio/aio.go +++ b/drivers/aio/aio.go @@ -2,8 +2,6 @@ package aio import ( "errors" - - "gobot.io/x/gobot" ) var ( @@ -23,6 +21,6 @@ const ( // AnalogReader interface represents an Adaptor which has Analog capabilities type AnalogReader interface { - gobot.Adaptor + //gobot.Adaptor AnalogRead(string) (val int, err error) } diff --git a/platforms/microbit/io_pin_driver.go b/platforms/microbit/io_pin_driver.go index a1f4404f..354d71e8 100644 --- a/platforms/microbit/io_pin_driver.go +++ b/platforms/microbit/io_pin_driver.go @@ -63,6 +63,8 @@ func (b *IOPinDriver) adaptor() ble.BLEConnector { // Start tells driver to get ready to do work func (b *IOPinDriver) Start() (err error) { + b.ReadPinADConfig() + b.ReadPinIOConfig() return } @@ -143,16 +145,6 @@ func (b *IOPinDriver) WritePinIOConfig(config int) (err error) { return } -// Connect here to allow Driver to also act as an Adaptor -func (b *IOPinDriver) Connect() (err error) { - return nil -} - -// Finalize here to allow Driver to also act as an Adaptor -func (b *IOPinDriver) Finalize() (err error) { - return nil -} - // DigitalRead reads from a pin func (b *IOPinDriver) DigitalRead(pin string) (val int, err error) { p, err := validatedPin(pin) @@ -232,7 +224,6 @@ func validatedPin(pin string) (int, error) { } // via http://stackoverflow.com/questions/23192262/how-would-you-set-and-clear-a-single-bit-in-go - // Sets the bit at pos in the integer n. func setBit(n int, pos int) int { n |= (1 << uint(pos)) diff --git a/platforms/microbit/io_pin_driver_test.go b/platforms/microbit/io_pin_driver_test.go index 1eb7454a..c4e5418b 100644 --- a/platforms/microbit/io_pin_driver_test.go +++ b/platforms/microbit/io_pin_driver_test.go @@ -14,9 +14,6 @@ import ( // the IOPinDriver is a Driver var _ gobot.Driver = (*IOPinDriver)(nil) -// and is also an Adaptor -var _ gobot.Adaptor = (*IOPinDriver)(nil) - // that supports the DigitalReader, DigitalWriter, & AnalogReader interfaces var _ gpio.DigitalReader = (*IOPinDriver)(nil) var _ gpio.DigitalWriter = (*IOPinDriver)(nil) @@ -37,9 +34,7 @@ func TestIOPinDriver(t *testing.T) { func TestIOPinDriverStartAndHalt(t *testing.T) { d := initTestIOPinDriver() gobottest.Assert(t, d.Start(), nil) - gobottest.Assert(t, d.Connect(), nil) - gobottest.Assert(t, d.Finalize(), nil) gobottest.Assert(t, d.Halt(), nil) }