docs: Add missing godocs for Sphero platform
Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
parent
e4f0ef72c8
commit
5e56638018
|
@ -6,7 +6,7 @@ import (
|
||||||
"github.com/tarm/serial"
|
"github.com/tarm/serial"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Represents a Connection to a Sphero
|
// Adaptor represents a Connection to a Sphero
|
||||||
type Adaptor struct {
|
type Adaptor struct {
|
||||||
name string
|
name string
|
||||||
port string
|
port string
|
||||||
|
@ -26,19 +26,27 @@ func NewAdaptor(port string) *Adaptor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Adaptor) Name() string { return a.name }
|
// 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 }
|
func (a *Adaptor) SetName(n string) { a.name = n }
|
||||||
func (a *Adaptor) Port() string { return a.port }
|
|
||||||
|
// 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 }
|
func (a *Adaptor) SetPort(p string) { a.port = p }
|
||||||
|
|
||||||
// Connect initiates a connection to the Sphero. Returns true on successful connection.
|
// Connect initiates a connection to the Sphero. Returns true on successful connection.
|
||||||
func (a *Adaptor) Connect() (err error) {
|
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
|
return e
|
||||||
} else {
|
|
||||||
a.sp = sp
|
|
||||||
a.connected = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
a.sp = sp
|
||||||
|
a.connected = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ type packet struct {
|
||||||
checksum uint8
|
checksum uint8
|
||||||
}
|
}
|
||||||
|
|
||||||
// Represents a Sphero 2.0
|
// SpheroDriver Represents a Sphero 2.0
|
||||||
type SpheroDriver struct {
|
type SpheroDriver struct {
|
||||||
name string
|
name string
|
||||||
connection gobot.Connection
|
connection gobot.Connection
|
||||||
|
@ -142,8 +142,13 @@ func NewSpheroDriver(a *Adaptor) *SpheroDriver {
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SpheroDriver) Name() string { return s.name }
|
// Name returns the Driver Name
|
||||||
func (s *SpheroDriver) SetName(n string) { s.name = n }
|
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) Connection() gobot.Connection { return s.connection }
|
||||||
|
|
||||||
func (s *SpheroDriver) adaptor() *Adaptor {
|
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)
|
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) {
|
func (s *SpheroDriver) ConfigureLocator(d LocatorConfig) {
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
binary.Write(buf, binary.BigEndian, d)
|
binary.Write(buf, binary.BigEndian, d)
|
||||||
|
@ -291,7 +296,7 @@ func (s *SpheroDriver) ConfigureLocator(d LocatorConfig) {
|
||||||
s.packetChannel <- s.craftPacket(buf.Bytes(), 0x02, 0x13)
|
s.packetChannel <- s.craftPacket(buf.Bytes(), 0x02, 0x13)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enables sensor data streaming
|
// SetDataStreaming enables sensor data streaming
|
||||||
func (s *SpheroDriver) SetDataStreaming(d DataStreamingConfig) {
|
func (s *SpheroDriver) SetDataStreaming(d DataStreamingConfig) {
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
binary.Write(buf, binary.BigEndian, d)
|
binary.Write(buf, binary.BigEndian, d)
|
||||||
|
|
Loading…
Reference in New Issue