#include "system.h"
unsigned char outBuf[5*8] = {
// G5 G6 G7 G2 G3 G4 R7 G0 G1 R4 R5 R6 R1 R2 R3 B6 B7 R0 B3 B4 B5 B2 B1 B0
0b11011011,0b11011011,0b10011011,0b11011011,0b11011011,0b11011011,0b11011011,0b11011011, // red
0b11011010,0b11011011,0b11011011,0b11011011,0b11011011,0b11011011,0b11011011,0b11011011, // green
0b11011011,0b11011011,0b11011011,0b11011011,0b11011011,0b11010011,0b11011011,0b11011011, // blue
0b11011011,0b11011011,0b11011011,0b11011011,0b11011011,0b11011011,0b11011011,0b11011011, // black
0b10010010,0b10010010,0b10010010,0b10010010,0b10010010,0b10010010,0b10010010,0b10010010, // bright white
};
ChangeBaud(2600000);
SendBuffer(outBuf, sizeof(outBuf));
#include "system.h"
/* WS2812 library */
#define nLED 8
unsigned char bufLED[nLED*8];
void setLED(unsigned short n, unsigned char r, unsigned char g, unsigned char b) {
if (n < nLED) {
unsigned short offset = 8*n;
bufLED[offset++] = (((g&0x80)>>7)|((g&0x40)>>3)|((g&0x20)<<1))^0xdb;
bufLED[offset++] = (((g&0x10)>>4)| (g&0x08) |((g&0x04)<<4))^0xdb;
bufLED[offset++] = (((g&0x02)>>1)|((g&0x01)<<3)|((r&0x80)>>1))^0xdb;
bufLED[offset++] = (((r&0x40)>>6)|((r&0x20)>>2)|((r&0x10)<<2))^0xdb;
bufLED[offset++] = (((r&0x08)>>3)|((r&0x04)<<1)|((r&0x02)<<5))^0xdb;
bufLED[offset++] = ( (r&0x01) |((b&0x80)>>4)| (b&0x40) )^0xdb;
bufLED[offset++] = (((b&0x20)>>5)|((b&0x10)>>1)|((b&0x08)<<3))^0xdb;
bufLED[offset++] = (((b&0x04)>>2)|((b&0x02)<<2)|((b&0x01)<<6))^0xdb;
TestValSet( bufLED[8*n] );
}
}
void sendLED() {
ChangeBaud(2100000);
SendBuffer(bufLED, sizeof(bufLED));
}
/* end of RGB-LED library */
short r=0,g=0,b=0;
for (int i=0;i<50;i++) {
for (short n=0; n<8; n++) {
setLED(n,r++,0,0);
}
sendLED();
delay(100);
}