Routines to drive a chain of APA102 Leds.
Fork of APA102 by
A library to drive arrays of APA102 leds.
Diff: APA102a.cpp
- Revision:
- 4:2afea45fce8f
- Parent:
- 3:bf8c63d10824
- Child:
- 5:863fb3a71efd
--- a/APA102a.cpp Sat Mar 14 18:17:53 2015 +0000 +++ b/APA102a.cpp Sat Mar 14 20:45:03 2015 +0000 @@ -1,17 +1,17 @@ #include "APA102a.h" #include "mbed.h" -APA102::APA102(PinName mosi,PinName miso,PinName sclk,int rate) +APA102a::APA102a(PinName mosi,PinName miso,PinName sclk,int rate) : _spi(mosi, miso, sclk) { // Setup the spi for 8 bit data, high steady state clock, - // second edge capture, with a 1MHz clock rate + // second edge capture, with clock rate _spi.format(8,3); _spi.frequency(rate); } -void APA102::SetBuffer(unsigned int Buffer[],int Rows,int Cols, int Stride,int Offset, bool ZigZag,bool Wrap) +void APA102a::SetBuffer(unsigned int Buffer[],int Rows,int Cols, int Stride,int Offset, bool ZigZag,bool Wrap) { Buf = Buffer; NR = Rows; @@ -22,7 +22,7 @@ WF = Wrap; } -void APA102::Repaint() +void APA102a::Repaint() { int index; unsigned int val; @@ -37,13 +37,13 @@ for(int c = off;c<(NC+off);c++) { int cc = (WF)?(c%NS):((c<NS)?c:NS); - if (ZF) - if((r&0x01)>0) + // if (ZF) + // { if((r&0x01)>0) index = r*NS + NC+off-cc; - else - index = r*NS + cc; - else - index = r*NS + cc; + // else + // index = r*NS + cc;} + // else + index = r*NS + c; val = Buf[index]; _spi.write((val>>24)&0xFF);