docs: Add missing godocs for Sphero platform

Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
deadprogram 2016-12-01 16:08:56 +01:00
parent e4f0ef72c8
commit 5e56638018
2 changed files with 25 additions and 12 deletions

View File

@ -6,7 +6,7 @@ import (
"github.com/tarm/serial"
)
// Represents a Connection to a Sphero
// Adaptor represents a Connection to a Sphero
type Adaptor struct {
name string
port string
@ -26,19 +26,27 @@ func NewAdaptor(port string) *Adaptor {
}
}
// Name returns the Adaptor's name
func (a *Adaptor) Name() string { return a.name }
// SetName sets the Adaptor's name
func (a *Adaptor) SetName(n string) { a.name = n }
// Port returns the Adaptor's port
func (a *Adaptor) Port() string { return a.port }
// SetPort sets the Adaptor's port
func (a *Adaptor) SetPort(p string) { a.port = p }
// Connect initiates a connection to the Sphero. Returns true on successful connection.
func (a *Adaptor) Connect() (err error) {
if sp, e := a.connect(a.Port()); e != nil {
sp, e := a.connect(a.Port())
if e != nil {
return e
} else {
}
a.sp = sp
a.connected = true
}
return
}

View File

@ -26,7 +26,7 @@ type packet struct {
checksum uint8
}
// Represents a Sphero 2.0
// SpheroDriver Represents a Sphero 2.0
type SpheroDriver struct {
name string
connection gobot.Connection
@ -142,8 +142,13 @@ func NewSpheroDriver(a *Adaptor) *SpheroDriver {
return s
}
// Name returns the Driver Name
func (s *SpheroDriver) Name() string { return s.name }
// SetName sets the Driver Name
func (s *SpheroDriver) SetName(n string) { s.name = n }
// Connection returns the Driver's Connection
func (s *SpheroDriver) Connection() gobot.Connection { return s.connection }
func (s *SpheroDriver) adaptor() *Adaptor {
@ -283,7 +288,7 @@ func (s *SpheroDriver) Roll(speed uint8, heading uint16) {
s.packetChannel <- s.craftPacket([]uint8{speed, uint8(heading >> 8), uint8(heading & 0xFF), 0x01}, 0x02, 0x30)
}
// Configures and enables the Locator
// ConfigureLocator configures and enables the Locator
func (s *SpheroDriver) ConfigureLocator(d LocatorConfig) {
buf := new(bytes.Buffer)
binary.Write(buf, binary.BigEndian, d)
@ -291,7 +296,7 @@ func (s *SpheroDriver) ConfigureLocator(d LocatorConfig) {
s.packetChannel <- s.craftPacket(buf.Bytes(), 0x02, 0x13)
}
// Enables sensor data streaming
// SetDataStreaming enables sensor data streaming
func (s *SpheroDriver) SetDataStreaming(d DataStreamingConfig) {
buf := new(bytes.Buffer)
binary.Write(buf, binary.BigEndian, d)