Skip to content

Commit

Permalink
Refactor firmata to use new adaptor interface
Browse files Browse the repository at this point in the history
  • Loading branch information
zankich committed Nov 22, 2014
1 parent 4cb20e1 commit d38b95f
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions platforms/firmata/firmata_adaptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ import (
"github.com/tarm/goserial"
)

var _ gobot.AdaptorInterface = (*FirmataAdaptor)(nil)
var _ gobot.Adaptor = (*FirmataAdaptor)(nil)

type FirmataAdaptor struct {
gobot.Adaptor
name string
port string
board *board
i2cAddress byte
connect func(*FirmataAdaptor) (err error)
Expand Down Expand Up @@ -43,11 +44,8 @@ func NewFirmataAdaptor(name string, args ...interface{}) *FirmataAdaptor {
}

return &FirmataAdaptor{
Adaptor: *gobot.NewAdaptor(
name,
"FirmataAdaptor",
port,
),
name: name,
port: port,
connect: func(f *FirmataAdaptor) (err error) {
if conn == nil {
conn, err = serial.OpenPort(&serial.Config{Name: f.Port(), Baud: 57600})
Expand All @@ -67,7 +65,6 @@ func (f *FirmataAdaptor) Connect() (errs []error) {
return []error{err}
}
f.board.connect()
f.SetConnected(true)
return
}

Expand All @@ -88,6 +85,9 @@ func (f *FirmataAdaptor) Finalize() (errs []error) {
return
}

func (f *FirmataAdaptor) Port() string { return f.port }
func (f *FirmataAdaptor) Name() string { return f.name }

// InitServo (not yet implemented)
func (f *FirmataAdaptor) InitServo() (err error) {
return errors.New("InitServo is not yet implemented")
Expand Down

0 comments on commit d38b95f

Please sign in to comment.