mirror of
https://github.com/hybridgroup/gobot.git
synced 2025-04-27 13:48:56 +08:00
aio: only need to support AnalogReader interface
Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
parent
1ed421a2af
commit
30df5dc11e
@ -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)
|
||||
}
|
||||
|
@ -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))
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user