apply @gen2thomas suggestions

This commit is contained in:
Patricio Whittingslow
2025-09-16 09:26:00 -03:00
parent 3cd6afb84c
commit 8d3cac8322
13 changed files with 77 additions and 67 deletions
+1 -1
View File
@@ -38,7 +38,7 @@ func New(b drivers.SPI) *Device {
// NewSoftwareSPI returns a new APA102 driver that will use a software based
// implementation of the SPI protocol.
func NewSoftwareSPI(sckPin, sdoPin legacy.PinOutput, delay uint32) *Device {
return New(&bbSPI{SCK: sckPin.Set, SDO: sdoPin.Set, Delay: delay, config: func() {
return New(&bbSPI{SCK: sckPin.Set, SDO: sdoPin.Set, Delay: delay, configurePins: func() {
legacy.ConfigurePinOut(sckPin)
legacy.ConfigurePinOut(sdoPin)
}})
+6 -6
View File
@@ -11,18 +11,18 @@ import (
// most purposes other than the APA102 package. It might be desirable to make
// this more generic and include it in the TinyGo "machine" package instead.
type bbSPI struct {
SCK drivers.PinOutput
SDO drivers.PinOutput
Delay uint32
config func()
SCK drivers.PinOutput
SDO drivers.PinOutput
Delay uint32
configurePins func()
}
// Configure sets up the SCK and SDO pins as outputs and sets them low
func (s *bbSPI) Configure() {
if s.config == nil {
if s.configurePins == nil {
panic(legacy.ErrConfigBeforeInstantiated)
}
s.config()
s.configurePins()
s.SCK(false)
s.SDO(false)
if s.Delay == 0 {