npxl

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2025 License: Unlicense Imports: 3 Imported by: 0

README

TinyGoNeoPixel

Wrapper for adding functionality onto NeoPixel LEDs controlled via TinyGo

Documentation

Overview

This package manages the NeoPixel LEDs (and maintains a local data representation) via ws2812

Index

Constants

This section is empty.

Variables

View Source
var (
	Red    = color.RGBA{R: 0xFF}
	Orange = color.RGBA{R: 0xFF, G: 0xA5}
	Yellow = color.RGBA{R: 0xFF, G: 0xFF}
	Green  = color.RGBA{G: 0xFF}
	Blue   = color.RGBA{B: 0xFF}
	Navy   = color.RGBA{B: 0xA5}
	Purple = color.RGBA{R: 0xFF, B: 0xFF}
)

Functions

This section is empty.

Types

type ErrOutOfRange

type ErrOutOfRange struct{}

func (ErrOutOfRange) Error

func (ErrOutOfRange) Error() string

type NeoPixels

type NeoPixels struct {
	AutoWrite bool // Write changes directly to the LEDs. If false, you must call .Flush()
	// contains filtered or unexported fields
}

func New

func New(pin machine.Pin, count uint) *NeoPixels

Returns a new NeoPixel struct set to read off the given pin. LED indices are zero-indexed, obviously. Initializes all LEDs to OFF.

func (*NeoPixels) Flush added in v1.1.0

func (np *NeoPixels) Flush() error

Apply the current state of the LEDs to the board itself. This is called automatically if .AutoWrite is set. Use .Flush() if you want to ensure multiple LED changes occur simultaneously, rather than incrementally.

func (*NeoPixels) Off

func (np *NeoPixels) Off()

Sets all LEDs to off.

func (*NeoPixels) SetAllLEDs

func (np *NeoPixels) SetAllLEDs(colors []led)

Sets all LEDs to the colors associated with their index. Only updates to the lower of the two lengths (LED count and len(colors)).

func (*NeoPixels) SetLED

func (np *NeoPixels) SetLED(index uint, color led) error

Set the color of a single LED

func (*NeoPixels) StaticRainbow added in v1.1.1

func (np *NeoPixels) StaticRainbow()

Jump to

Keyboard shortcuts

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