pca9957

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

README

Periph.io compatible SPI driver for PCA9957 led controller

NXP PCA9957 device driver to work with periph.io

PkgGoDev

Driver summary

The PCA9957 is a 24-channel SPI bus constant current programmable LED driver.

This device supports daisy chaining of multiple drivers to build composed led stripes. Driver will expose the daisy chained stripes as a row of pixels as done in existing nrzled driver.

Limitations

  • Driver is currently only compatible with RGB strips (max 8 pixels, asigning 3 channels per pixel)
  • Driver asumes pixels in BGR configuration (in each pixel, lower channel for blue, higher channel for red and mid for green)
    • ie, for the first pixel of the stripe, channel zero would be blue, channel one would green and channel two would be red
  • Driver models led stripe as one line of pixels (containing a maximun of eight color pixels)

Datasheet

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrOutOfBounds      = errors.New("data is out of operation range")
	ErrUninitialized    = errors.New("device is not configured")
	ErrModeNotSupported = errors.New("operation mode not supported")
)
View Source
var DefaultOpts = Opts{
	NumPixels:  8,
	Channels:   3,
	NumStripes: 1,
	Gain:       0xff,
	Freq:       physic.MegaHertz,
}

Functions

func LedDriverCfg

func LedDriverCfg(a, b, c, d DrvMode) uint8

Types

type Dev

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

func NewSPI

func NewSPI(p spi.Port, opts *Opts) (*Dev, error)

func (*Dev) All

func (d *Dev) All(pwm ...uint8) (err error)
func (d *Dev) Blink(freq physic.Frequency, pwm uint8) (err error)

Blink configures operation mode to group PWM control and sets all leds drivers to blink at spcified frequency and PWM as ON/OFF ratio dutycycle = PWM/256

func (*Dev) Bounds

func (d *Dev) Bounds() image.Rectangle

func (*Dev) ColorModel

func (d *Dev) ColorModel() color.Model

func (*Dev) Draw

func (d *Dev) Draw(r image.Rectangle, src image.Image, sp image.Point) error

Draw implements display.Drawer.

Using something else than image.NRGBA is 10x slower and is not recommended. When using image.NRGBA, the alpha channel is ignored

A back buffer is kept so that partial updates are supported, albeit the full LED strip is updated synchronously.

func (*Dev) Halt

func (d *Dev) Halt() (err error)

Halt will set the device on the default rest position and will also server as an init() function

func (d *Dev) NoBlink() (err error)

NoBlink disables leds drivers blink mode

func (*Dev) One

func (d *Dev) One(stripe, pixel int, value color.Color) error

One will configure only one pixel of a stripe

func (*Dev) String

func (d *Dev) String() string

type DrvMode

type DrvMode uint8

LED driver modes

const (
	OFF DrvMode = iota
	NO_CTL
	PWM_ONLY
	GROUP_CTL
)

type Opts

type Opts struct {
	// Number of pixels per stripe
	NumPixels int
	// Number of chained stripes
	NumStripes int
	// Channels per pixel
	// TODO: support non rgb stripes
	Channels int
	// Frequency of operation
	Freq physic.Frequency
	// Led driver current gain setting
	Gain uint8
}

type PCA9957Reg

type PCA9957Reg uint8

PCA9957 register values

const (
	MODE1 PCA9957Reg = iota
	MODE2
	EFLAG0
	EFLAG1
	EFLAG2
	EFLAG3
	EFLAG4
	EFLAG5
	LEDOUT0
	LEDOUT1
	LEDOUT2
	LEDOUT3
	LEDOUT4
	LEDOUT5
	GRPPWM
	GRPFREQ
	PWM0
	PWM1
	PWM2
	PWM3
	PWM4
	PWM5
	PWM6
	PWM7
	PWM8
	PWM9
	PWM10
	PWM11
	PWM12
	PWM13
	PWM14
	PWM15
	PWM16
	PWM17
	PWM18
	PWM19
	PWM20
	PWM21
	PWM22
	PWM23
	IREF0
	IREF1
	IREF2
	IREF3
	IREF4
	IREF5
	IREF6
	IREF7
	IREF8
	IREF9
	IREF10
	IREF11
	IREF12
	IREF13
	IREF14
	IREF15
	IREF16
	IREF17
	IREF18
	IREF19
	IREF20
	IREF21
	IREF22
	IREF23
	RAMP_RATE_GRP0
	STEP_TIME_GRP0
	HOLD_CNTL_GRP0
	IREF_GRP0
	RAMP_RATE_GRP1
	STEP_TIME_GRP1
	HOLD_CNTL_GRP1
	IREF_GRP1
	RAMP_RATE_GRP2
	STEP_TIME_GRP2
	HOLD_CNTL_GRP2
	IREF_GRP2
	RAMP_RATE_GRP3
	STEP_TIME_GRP3
	HOLD_CNTL_GRP3
	IREF_GRP3
	RAMP_RATE_GRP4
	STEP_TIME_GRP4
	HOLD_CNTL_GRP4
	IREF_GRP4
	RAMP_RATE_GRP5
	STEP_TIME_GRP5
	HOLD_CNTL_GRP5
	IREF_GRP5
	GRAD_MODE_SEL0
	GRAD_MODE_SEL1
	GRAD_MODE_SEL2
	GRAD_GRP_SEL0
	GRAD_GRP_SEL1
	GRAD_GRP_SEL2
	GRAD_GRP_SEL3
	GRAD_GRP_SEL4
	GRAD_GRP_SEL5
	GRAD_GRP_SEL6
	GRAD_GRP_SEL7
	GRAD_GRP_SEL8
	GRAD_GRP_SEL9
	GRAD_GRP_SEL10
	GRAD_GRP_SEL11
	GRAD_CNTL0
	GRAD_CNTL1
	OFFSET
	PWMALL
	IREFALL
)

Device registers enumeration

Jump to

Keyboard shortcuts

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