From 149760e392fa3500309263085802b0cc67befddf Mon Sep 17 00:00:00 2001 From: Adrian Zankich Date: Sat, 22 Nov 2014 18:59:27 -0800 Subject: [PATCH] Refactor beaglebone to use new adaptor interface --- platforms/beaglebone/beaglebone_adaptor.go | 11 +++++------ platforms/beaglebone/pwm_pin.go | 3 ++- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/platforms/beaglebone/beaglebone_adaptor.go b/platforms/beaglebone/beaglebone_adaptor.go index b28e2b9b..41cf9682 100644 --- a/platforms/beaglebone/beaglebone_adaptor.go +++ b/platforms/beaglebone/beaglebone_adaptor.go @@ -14,7 +14,8 @@ import ( "github.com/hybridgroup/gobot/sysfs" ) -var _ gobot.AdaptorInterface = (*BeagleboneAdaptor)(nil) +var _ gobot.Adaptor = (*BeagleboneAdaptor)(nil) + var slots = "/sys/devices/bone_capemgr.*" var ocp = "/sys/devices/ocp.*" var usrLed = "/sys/devices/ocp.3/gpio-leds.8/leds/beaglebone:green:" @@ -114,7 +115,7 @@ var analogPins = map[string]string{ } type BeagleboneAdaptor struct { - gobot.Adaptor + name string digitalPins []sysfs.DigitalPin pwmPins map[string]*pwmPin i2cDevice io.ReadWriteCloser @@ -126,10 +127,7 @@ type BeagleboneAdaptor struct { // NewBeagleboneAdaptor returns a new beaglebone adaptor with specified name func NewBeagleboneAdaptor(name string) *BeagleboneAdaptor { b := &BeagleboneAdaptor{ - Adaptor: *gobot.NewAdaptor( - name, - "BeagleboneAdaptor", - ), + name: name, digitalPins: make([]sysfs.DigitalPin, 120), pwmPins: make(map[string]*pwmPin), } @@ -141,6 +139,7 @@ func NewBeagleboneAdaptor(name string) *BeagleboneAdaptor { return b } +func (b *BeagleboneAdaptor) Name() string { return b.name } // Connect returns true on a succesful connection to beaglebone board. // It initializes digital, pwm and analog pins diff --git a/platforms/beaglebone/pwm_pin.go b/platforms/beaglebone/pwm_pin.go index 4997fa75..cdb99a06 100644 --- a/platforms/beaglebone/pwm_pin.go +++ b/platforms/beaglebone/pwm_pin.go @@ -2,9 +2,10 @@ package beaglebone import ( "fmt" - "github.com/hybridgroup/gobot/sysfs" "os" "strings" + + "github.com/hybridgroup/gobot/sysfs" ) type pwmPin struct {