indicator

package
v1.0.0-beta Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	Off    = 0x0
	White  = 0xFFFFFF
	Red    = 0xff0000
	Green  = 0x00ff00
	Blue   = 0x000ff
	Yellow = 0xeeff00
	Orange = 0xff7b00
)

color constants

View Source
const (
	TypeWS281x = "WS281x"
)

Supported types

Variables

View Source
var (
	ErrInvalidIndex        = errors.New("invalid index")
	ErrInvalidPin          = errors.New("invalid data pin #")
	ErrInvalidNumberOfLeds = errors.New("number of leds must be greater than zero")
)

Functions

This section is empty.

Types

type Indicator

type Indicator interface {
	DisplayColor(index int, colorHex uint32) error
	Blink(index int, times int, colorHex uint32) error
	Cleanup()
}

Indicator is an abstraction layer for connector status indication, usually an RGB LED strip.

func NewIndicator

func NewIndicator(stripLength int) Indicator

NewIndicator constructs the Indicator based on the type provided by the settings file.

type WS281x

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

func NewWS281xStrip

func NewWS281xStrip(numberOfLEDs int, dataPin int) (*WS281x, error)

NewWS281xStrip create a new LED strip object with the specified number of LEDs and the data pin. When created, it will also be initialized.

func (ws *WS281x) Blink(index int, times int, colorHex uint32) error

Blink the LED at index a certain number of times with the specified color. If the number of times the LED is supposed to blink is even, it will stay turned off after the blinking, otherwise it will stay on after the blinking.

func (*WS281x) Cleanup

func (ws *WS281x) Cleanup()

Cleanup turn the LEDs off and terminate the data connection.

func (*WS281x) DisplayColor

func (ws *WS281x) DisplayColor(index int, colorHex uint32) error

DisplayColor change the color of the LED at specified index to the specified color. The index must be greater than 0 and less than the length of the LED strip.

Jump to

Keyboard shortcuts

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