Routines to drive a chain of APA102 Leds.

Dependents:   blink_led_threading

Embed: (wiki syntax)

« Back to documentation index

APA102 Class Reference

APA102 Class Reference

Create an APA102 Object. More...

#include <APA102.h>

Public Member Functions

 APA102 (PinName mosi, PinName miso, PinName sclk, int rate)
 Create an APA102 object connected to the specified mosi,miso,sclk pins.
void SetBuffer (unsigned int Buffer[], int Rows, int Cols, int Stride, int Offset, bool ZigZag, bool Wrap)
 Set the Buffer.
void Repaint ()
 Repaint the Strip.
int IRGB (unsigned char I, unsigned char R, unsigned char G, unsigned char B)
 Create an IRGB helper function to construct a 4 byte LED Frame.

Detailed Description

Create an APA102 Object.

Definition at line 11 of file APA102.h.


Constructor & Destructor Documentation

APA102 ( PinName  mosi,
PinName  miso,
PinName  sclk,
int  rate 
)

Create an APA102 object connected to the specified mosi,miso,sclk pins.

Parameters:
mosi: SPI Master Out Slave In pin
miso: SPI Master In Slave Out pin (ignored)
sclk: SPI Clock
rate: SPI Rate

Definition at line 4 of file APA102.cpp.


Member Function Documentation

int IRGB ( unsigned char  I,
unsigned char  R,
unsigned char  G,
unsigned char  B 
)

Create an IRGB helper function to construct a 4 byte LED Frame.

Parameters:
I: 5 bits of intensity (0,1,2,...,31)
R: 8 bits of Red (0,1,...,255)
G: 8 bits of Green (0,1,...,255)
B: 8 bits of Blue (0,1,...,255)

Definition at line 48 of file APA102.h.

void Repaint (  )

Repaint the Strip.

Parameters:
none

Definition at line 25 of file APA102.cpp.

void SetBuffer ( unsigned int  Buffer[],
int  Rows,
int  Cols,
int  Stride,
int  Offset,
bool  ZigZag,
bool  Wrap 
)

Set the Buffer.

Parameters:
buffer[]: a buffer of unsigned integers (4 bytes) *Rows*Stride in size
Rows: Number of Rows
Cols: Number of Columns
Stride: The actual number of columns (useful for data alignment)
Offset: The offset into a row
ZigZag: A boolean, do we alternate count up/ count down per row?
Wrap: A boolean, do we wrap if (Offset+Cols) > Stride? (handy for scrolling messages)

Definition at line 14 of file APA102.cpp.