README ¶
Periph.io compatible SPI driver for PCA9957 led controller
NXP PCA9957 device driver to work with periph.io
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 ¶
- Variables
- func LedDriverCfg(a, b, c, d DrvMode) uint8
- type Dev
- func (d *Dev) All(pwm ...uint8) (err error)
- func (d *Dev) Blink(freq physic.Frequency, pwm uint8) (err error)
- func (d *Dev) Bounds() image.Rectangle
- func (d *Dev) ColorModel() color.Model
- func (d *Dev) Draw(r image.Rectangle, src image.Image, sp image.Point) error
- func (d *Dev) Halt() (err error)
- func (d *Dev) NoBlink() (err error)
- func (d *Dev) One(stripe, pixel int, value color.Color) error
- func (d *Dev) String() string
- type DrvMode
- type Opts
- type PCA9957Reg
Constants ¶
This section is empty.
Variables ¶
var ( ErrOutOfBounds = errors.New("data is out of operation range") ErrUninitialized = errors.New("device is not configured") ErrModeNotSupported = errors.New("operation mode not supported") )
var DefaultOpts = Opts{ NumPixels: 8, Channels: 3, NumStripes: 1, Gain: 0xff, Freq: physic.MegaHertz, }
Functions ¶
func LedDriverCfg ¶
Types ¶
type Dev ¶
type Dev struct {
// contains filtered or unexported fields
}
func (*Dev) Blink ¶
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) ColorModel ¶
func (*Dev) Draw ¶
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 ¶
Halt will set the device on the default rest position and will also server as an init() function
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