Debug changes but wants to publish back... making a fork...

Dependencies:   PixelArray WS2812 mbed

Fork of ChrisRGB-Ring by Chris Styles

Committer:
michaeljkoster
Date:
Wed Aug 20 16:37:11 2014 +0000
Revision:
3:c2227dba959d
Parent:
2:57db905622ca
Debug version on K64F platform

Who changed what in which revision?

UserRevisionLine numberNew contents of line
chris 0:6b847e039b3b 1 #include "mbed.h"
chris 0:6b847e039b3b 2 #include "WS2812.h"
chris 0:6b847e039b3b 3 #include "PixelArray.h"
chris 0:6b847e039b3b 4
chris 0:6b847e039b3b 5 #define WS2812_BUF 60
chris 0:6b847e039b3b 6
michaeljkoster 3:c2227dba959d 7 //WS2812 ws(p5,WS2812_BUF);
michaeljkoster 3:c2227dba959d 8 WS2812 ws(PTD2,WS2812_BUF);
chris 0:6b847e039b3b 9 PixelArray px(WS2812_BUF);
chris 0:6b847e039b3b 10
chris 1:bf4d674d3692 11 DigitalOut led(LED1);
chris 1:bf4d674d3692 12
chris 0:6b847e039b3b 13 int main()
chris 0:6b847e039b3b 14 {
chris 0:6b847e039b3b 15
chris 0:6b847e039b3b 16 ws.useII(2); // use per-pixel intensity scaling
chris 0:6b847e039b3b 17
chris 0:6b847e039b3b 18 // set up the colours we want to draw with
chris 0:6b847e039b3b 19 int colorbuf[6] = {0x2f0000,0x2f2f00,0x002f00,0x002f2f,0x00002f,0x2f002f};
chris 0:6b847e039b3b 20
chris 1:bf4d674d3692 21 // for each of the colours (j) write out 10 of them
chris 2:57db905622ca 22 // the pixels are written at the colour*10, plus the colour position
chris 1:bf4d674d3692 23 // all modulus 60 so it wraps around
chris 1:bf4d674d3692 24 for (int i =0; i<6; i++) {
chris 1:bf4d674d3692 25 for (int j=0; j<10; j++) {
chris 2:57db905622ca 26 px.Set(((i*10)+j)%60,colorbuf[i]);
chris 0:6b847e039b3b 27 }
chris 0:6b847e039b3b 28 }
chris 1:bf4d674d3692 29
chris 2:57db905622ca 30 // now all the colours are computed, add a fade effect using intensity scaling
chris 1:bf4d674d3692 31 // compute and write the II value for each pixel
chris 1:bf4d674d3692 32 for (int j=0; j<60; j++) {
chris 1:bf4d674d3692 33 // px.SetI(pixel position, II value)
chris 2:57db905622ca 34 px.SetI(j%60, 0xf+(0xf*(j%10)));
chris 1:bf4d674d3692 35 }
chris 1:bf4d674d3692 36
chris 1:bf4d674d3692 37
chris 2:57db905622ca 38 // Now the buffer is written, rotate it
chris 2:57db905622ca 39 // by writing it out with an increasing offset
chris 1:bf4d674d3692 40 while (1) {
chris 1:bf4d674d3692 41 for (int z=59; z >= 0 ; z--) {
chris 2:57db905622ca 42 ws.write_offsets(px.getBuf(),z,z,z);
chris 1:bf4d674d3692 43 wait(0.075);
chris 1:bf4d674d3692 44 }
chris 1:bf4d674d3692 45 }
chris 1:bf4d674d3692 46
chris 0:6b847e039b3b 47 }