Skip to content

Commit

Permalink
Add a method for returning the LED strip's RPi instance
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon-Bright committed Feb 21, 2021
1 parent 7a607ef commit 3416225
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pixarray/ledstrip.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package pixarray

import (
rpi "github.com/Jon-Bright/ledctl/rpi"
)

type LEDStrip interface {
RPi() *rpi.RPi
MaxPerChannel() int
GetPixel(i int) Pixel
SetPixel(i int, p Pixel)
Expand Down
4 changes: 4 additions & 0 deletions pixarray/lpd8806.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ func NewLPD8806(dev dev, numPixels int, numColors int, spiSpeed uint32, order in
return &la, nil
}

func (la *LPD8806) RPi() *rpi.RPi {
return la.rp
}

func (la *LPD8806) MaxPerChannel() int {
return 127
}
Expand Down
5 changes: 5 additions & 0 deletions pixarray/pixarray.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package pixarray

import (
"fmt"
rpi "github.com/Jon-Bright/ledctl/rpi"
)

const (
Expand Down Expand Up @@ -76,6 +77,10 @@ func (pa *PixArray) NumColors() int {
return pa.numColors
}

func (pa *PixArray) RPi() *rpi.RPi {
return pa.leds.RPi()
}

func (pa *PixArray) MaxPerChannel() int {
return pa.leds.MaxPerChannel()
}
Expand Down
4 changes: 4 additions & 0 deletions pixarray/ws281x.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ func (ws *WS281x) pwmByteCount(freq uint) uint {
return bytes
}

func (ws *WS281x) RPi() *rpi.RPi {
return ws.rp
}

func (ws *WS281x) MaxPerChannel() int {
return 255
}
Expand Down

0 comments on commit 3416225

Please sign in to comment.