ledstrip

package module
v0.0.0-...-89f47e7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 11, 2024 License: MIT Imports: 7 Imported by: 0

README

ledstrips

WS281* library to control LEDs fully written in Go. Tested on Raspberry Pi 3b and 4.

Build for ARM

Set following path variables:

$Env:GOOS="linux"
$Env:GOARCH="arm"
$Env:GOARM=7

Troubleshooting

See readme of jgarff's repository. Thanks at this point.

SPI driver issue

Some issues occure within the SPI driver using DMA

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetColorData

func GetColorData(pixel RGBPixel, fixSPI bool) [9]uint8

one color-value has 3 bits

high = 1 1 0 low = 1 0 0

0 24bit Green 1 24bit Red 2 24bit Blue => 9 byte

Set all to 0

  G7      G6      G5      G4      G3      G2      G1      G0      /      R7      R6      R5   ...
[1 0 0] [1 0 0] [1 0 0] [1 0 0] [1 0 0] [1 0 0] [1 0 0] [1 0 0]       [1 0 0] [1 0 0] [1 0 0] ...
   0       0       0       0       0       0       0       0             0       0       0    ...

Set all to 1

	G7      G6      G5      G4      G3      G2      G1      G0      /      R7      R6      R5   ...
[1 1 0] [1 1 0] [1 1 0] [1 1 0] [1 1 0] [1 1 0] [1 1 0] [1 1 0]       [1 1 0] [1 1 0] [1 1 0] ...
	1       1       1       1       1       1       1       1             1       1       1    ...
   128     64       32      16      8       4       2       1             128     64      32   ...

SPI issue

	G7      G6     G5          G4      G3          G2      G1      G0        /      R7      R6      R5   ...
[1 1 0] [1 1 0] [1 1 XX 0 ]  [1 1 0] [1 1 0] [1  XX 1 0] [1 1 0] [1 1 0] XX      [1 1 0] [1 1 0] [1 1 0] ...
   1       1       1 XX         1       1        XX 1       1       1    XX         1       1       1    ...
  128      64     32 XX         16      8        XX 4       2       1    XX         128     64      32   ...

Set Red

  G7      G6      G5      G4      G3      G2      G1      G0      /      R7      R6      R5   ...
[1 0 0] [1 0 0] [1 0 0] [1 0 0] [1 0 0] [1 0 0] [1 0 0] [1 0 0]       [1 0 0] [1 1 0] [1 0 0] ...
   0       0       0       0       0       0       0       0             0       1       0    ...

100 100 100 100 100 100 100 100       100 110 100 100 100 100 100 100 100  100 100 100 100 100 100 100
100 100 100 100 100 100 100 100       100 100 100 100 100 100 100 100 100  100 100 100 100 100 100 100
100 100 100 100 100 100 100 110       100 100 100 100 100 100 100 100 100  100 100 100 100 100 100 100

10010010 01001001 00100100  11011011 01101101 10110110  10010010 01001001 00100100
10010010 01001001 00100100  11011011 01101101 10110110  10010010 01001001 00100100

func HasBit

func HasBit(n uint8, pos uint8) bool

func Pmod

func Pmod(a, b int) int

func SetBit

func SetBit(n uint8, pos uint8) uint8

Types

type ColorData

type ColorData struct {
	ColorData [9]uint8
	FixSPI    bool
	// contains filtered or unexported fields
}

type ConnectionSPI

type ConnectionSPI struct {
	NrOfLeds int
	FixSPI   bool
	// contains filtered or unexported fields
}

ConnectionSPIs

func New

func New(devicePath string, nrOfLEDs int, spiMode spi.Mode, fixSPI bool) (ConnectionSPI, error)

func NewSPI

func NewSPI(devicePath string, nrOfLEDs int, fixSPI bool) (ConnectionSPI, error)

func (*ConnectionSPI) Clear

func (c *ConnectionSPI) Clear()

func (*ConnectionSPI) Close

func (c *ConnectionSPI) Close() error

Close closes SPIConnection

func (*ConnectionSPI) Exit

func (c *ConnectionSPI) Exit()

Exit turns off LEDs and closes SPIConnection

func (*ConnectionSPI) Render

func (c *ConnectionSPI) Render(pixels []RGBPixel)

Render translates RGBPixels into SPI message and transfers the message

type FaderRunner

type FaderRunner struct {
	Conn *ConnectionSPI
}

func (*FaderRunner) RunLEDS

func (f *FaderRunner) RunLEDS(leds []RGBPixel, speedFactor float32)

func (*FaderRunner) RunLEDSSplit

func (f *FaderRunner) RunLEDSSplit(leds []RGBPixel, speedFactor float32, invert bool)

type RGBPixel

type RGBPixel struct {
	Red   uint8
	Green uint8
	Blue  uint8
}

RGBPixel has one byte each color.

func Inverse

func Inverse(leds []RGBPixel) []RGBPixel

func PlaceAtBack

func PlaceAtBack(leds []RGBPixel, led RGBPixel) []RGBPixel

func PlaceInFront

func PlaceInFront(leds []RGBPixel, led RGBPixel) []RGBPixel

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL