apa102

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2020 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package apa102 implements a driver for the APA102 SPI LED.

Datasheet: https://cdn-shop.adafruit.com/product-files/2343/APA102C.pdf

Index

Constants

View Source
const (
	// BGR aka "Blue Green Red" is the current APA102 LED color order.
	BGR = iota

	// BRG aka "Blue Red Green" is the typical APA102 color order from 2015-2017.
	BRG

	// GRB aka "Green Red Blue" is the typical APA102 color order from pre-2015.
	GRB
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

type Device struct {
	Order int
	// contains filtered or unexported fields
}

Device wraps APA102 SPI LEDs.

func New

func New(b SPI) Device

New returns a new APA102 driver. Pass in a fully configured SPI bus.

func NewSoftwareSPI added in v0.6.0

func NewSoftwareSPI(sckPin, mosiPin machine.Pin, delay uint32) Device

NewSoftwareSPI returns a new APA102 driver that will use a software based implementation of the SPI protocol.

func (Device) Write

func (d Device) Write(buf []byte) (n int, err error)

Write the raw bytes using the APA102 protocol.

func (Device) WriteColors

func (d Device) WriteColors(cs []color.RGBA) (n int, err error)

WriteColors writes the given RGBA color slice out using the APA102 protocol. The A value (Alpha channel) is used for brightness, set to 0xff (255) for maximum.

type SPI added in v0.6.0

type SPI interface {
	Tx(w, r []byte) error
}

The SPI interface specifies the minimum functionality that a bus implementation needs to provide for use by the APA102 driver. Hardware SPI from the TinyGo "machine" package implements this already.

Jump to

Keyboard shortcuts

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