Skip to content

Commit

Permalink
go lint and documentation tweaks for the digispark package
Browse files Browse the repository at this point in the history
  • Loading branch information
zankich committed Jan 2, 2015
1 parent 39d3989 commit d073a1c
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions platforms/digispark/digispark_adaptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ var _ gpio.DigitalWriter = (*DigisparkAdaptor)(nil)
var _ gpio.PwmWriter = (*DigisparkAdaptor)(nil)
var _ gpio.ServoWriter = (*DigisparkAdaptor)(nil)

// ErrConnection is the error resulting of a connection error with the digispark
var ErrConnection = errors.New("connection error")

// DigisparkAdaptor is the Gobot Adaptor for the Digispark
type DigisparkAdaptor struct {
name string
littleWire lw
Expand All @@ -24,7 +26,7 @@ type DigisparkAdaptor struct {
connect func(*DigisparkAdaptor) (err error)
}

// NewDigisparkAdaptor create a Digispark adaptor with specified name
// NewDigisparkAdaptor returns a new DigisparkAdaptor with specified name
func NewDigisparkAdaptor(name string) *DigisparkAdaptor {
return &DigisparkAdaptor{
name: name,
Expand All @@ -38,20 +40,21 @@ func NewDigisparkAdaptor(name string) *DigisparkAdaptor {
}
}

// Name returns the DigisparkAdaptors name
func (d *DigisparkAdaptor) Name() string { return d.name }

// Connect starts connection to digispark, returns true if successful
// Connect starts a connection to the digispark
func (d *DigisparkAdaptor) Connect() (errs []error) {
if err := d.connect(d); err != nil {
return []error{err}
}
return
}

// Finalize returns true if finalization is successful
// Finalize implements the Adaptor interface
func (d *DigisparkAdaptor) Finalize() (errs []error) { return }

// DigitalWrite writes level to specified pin using littlewire
// DigitalWrite writes a value to the pin. Acceptable values are 1 or 0.
func (d *DigisparkAdaptor) DigitalWrite(pin string, level byte) (err error) {
p, err := strconv.Atoi(pin)

Expand All @@ -66,7 +69,7 @@ func (d *DigisparkAdaptor) DigitalWrite(pin string, level byte) (err error) {
return d.littleWire.digitalWrite(uint8(p), level)
}

// PwmWrite updates pwm pin with sent value
// PwmWrite writes the 0-254 value to the specified pin
func (d *DigisparkAdaptor) PwmWrite(pin string, value byte) (err error) {
if d.pwm == false {
if err = d.littleWire.pwmInit(); err != nil {
Expand All @@ -82,7 +85,7 @@ func (d *DigisparkAdaptor) PwmWrite(pin string, value byte) (err error) {
return d.littleWire.pwmUpdateCompare(value, value)
}

// ServoWrite updates servo location with specified angle
// ServoWrite writes the 0-180 degree val to the specified pin.
func (d *DigisparkAdaptor) ServoWrite(pin string, angle uint8) (err error) {
if d.servo == false {
if err = d.littleWire.servoInit(); err != nil {
Expand Down

0 comments on commit d073a1c

Please sign in to comment.