rpioapa102

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2022 License: MIT Imports: 5 Imported by: 0

README

rpio-apa102

Golang module for the APA102 LED on the Raspberry Pi using the go-rpio library

Usage

See examples in examples

Documentation

Index

Constants

View Source
const MaxBrightness = 31

MaxBrightness is the highest brightness value supported by the LEDs

Variables

This section is empty.

Functions

This section is empty.

Types

type FadeUp

type FadeUp struct {
	// contains filtered or unexported fields
}

FadeUp will give values for a series of LEDs depending on a pos 0-100 in the animation phase. The animation itself will go from dim first row to gradually brightening the rows of LEDs to the specified LED RGB value

func NewFadeUp

func NewFadeUp(rows uint, cols uint, colour colorful.Color, direction bool) (*FadeUp, error)

NewFadeUp validates parameters for FadeUp

func (*FadeUp) CurrentLEDs

func (f *FadeUp) CurrentLEDs(pos float64) []LED

CurrentLEDs returns the slice of LED values depending on the pos 0-1 which represents the position in the animation where 0 is unlit and 1 is fully lit. Any value between is gradually getting brighter row by row.

type LED

type LED struct {
	//Colour for the LED
	Colour colorful.Color

	// Brightness 0-31 value for the LED. It is recommended NOT to use this due to do poor quality
	Brightness byte
}

LED is a representation of an RGB LED

func LEDFromIntRGB

func LEDFromIntRGB(r uint, g uint, b uint) LED

LEDFromIntRGB returns LED objects whom color is based off RGB values 0-255, with max brightness

func LEDFromIntRGBB

func LEDFromIntRGBB(r uint, g uint, b uint, brightness byte) LED

LEDFromIntRGBB returns LED objects whom color is based off RGB values 0-255

func ParseColour

func ParseColour(colourStr string) (*LED, error)

ParseColour attempts to parse string hexadecimal representations of colours. eg. "#fff" or "#FEFEFE"

func (LED) AsFrame

func (l LED) AsFrame() []byte

AsFrame returns the LED as a data frame to send to the APA102 via SPI

func (LED) AsHTML

func (l LED) AsHTML() string

AsHTML returns the HTML hex code value for the colour of the LED

type LEDController

type LEDController struct {
	// contains filtered or unexported fields
}

LEDController retains state and methods to control the APA102 on open SPI

func NewLEDController

func NewLEDController(pin rpio.SpiDev) LEDController

NewLEDController will return controller for the LEDs

func (*LEDController) Finish

func (c *LEDController) Finish()

Finish should be called to close the SPI

func (*LEDController) Write

func (c *LEDController) Write(ledSlice []LED)

Write takes a slice of LEDs in the order they are connected.

type SpinnerState

type SpinnerState struct {

	// LEDCount is the number of LEDs in the ring
	LEDCount uint

	// Spread is the number of LEDs that there will be a linear fall-off in brightness
	Spread byte

	// BaseLED give the colour at the brightest point in the ring
	BaseLED LED
	// contains filtered or unexported fields
}

SpinnerState includes the position of the currently lid LED in the ring and parameters

func NewSpinner

func NewSpinner(ledCount uint, spread uint8, baseLED LED) SpinnerState

NewSpinner creates a SpinnerState with sensible parameters

func (*SpinnerState) CurrentState

func (s *SpinnerState) CurrentState() []LED

CurrentState returns the slice of LED values for the current position in the sequence

func (*SpinnerState) Next

func (s *SpinnerState) Next()

Next transitions the spinner to the next state

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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