Alan Rager / Mbed 2 deprecated lightstrip_adafruit

Dependencies:   Adafruit_WS2801 mbed

Committer:
AlanRager
Date:
Fri Jan 16 05:42:59 2015 +0000
Revision:
1:54cf3c557fdf
Parent:
0:63c1f03ccb9c
Wait... this is the actual changes to lightstrip_adafruit? Anyway - here's the code that made things kinda blink, just less bright because it was hurting my eyes.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AlanRager 0:63c1f03ccb9c 1 #include "mbed.h"
AlanRager 0:63c1f03ccb9c 2 #include "Adafruit_WS2801.h"
AlanRager 0:63c1f03ccb9c 3
AlanRager 0:63c1f03ccb9c 4 #define LED_NUM 32
AlanRager 0:63c1f03ccb9c 5 #define RED 1
AlanRager 0:63c1f03ccb9c 6 #define GREEN 2
AlanRager 0:63c1f03ccb9c 7 #define BLUE 4
AlanRager 0:63c1f03ccb9c 8
AlanRager 0:63c1f03ccb9c 9 //Init strip of 32
AlanRager 0:63c1f03ccb9c 10 Adafruit_WS2801 leds( LED_NUM, SPI_MOSI, SPI_SCK, WS2801_RGB );
AlanRager 0:63c1f03ccb9c 11
AlanRager 0:63c1f03ccb9c 12 int main () {
AlanRager 0:63c1f03ccb9c 13 int i, color;
AlanRager 0:63c1f03ccb9c 14
AlanRager 0:63c1f03ccb9c 15 color = 1;
AlanRager 0:63c1f03ccb9c 16
AlanRager 0:63c1f03ccb9c 17 while (1) {
AlanRager 0:63c1f03ccb9c 18 for (i = 0; i < LED_NUM; i++){
AlanRager 0:63c1f03ccb9c 19 leds.setPixelColor(
AlanRager 0:63c1f03ccb9c 20 i,
AlanRager 1:54cf3c557fdf 21 ( color & RED > 0 ? 4 : 0 ),
AlanRager 1:54cf3c557fdf 22 ( color & BLUE > 0 ? 4 : 0 ),
AlanRager 1:54cf3c557fdf 23 ( color & GREEN > 0 ? 4 : 0 )
AlanRager 0:63c1f03ccb9c 24 );
AlanRager 0:63c1f03ccb9c 25 }
AlanRager 0:63c1f03ccb9c 26 leds.show();
AlanRager 0:63c1f03ccb9c 27
AlanRager 0:63c1f03ccb9c 28 color = color * 2;
AlanRager 0:63c1f03ccb9c 29
AlanRager 0:63c1f03ccb9c 30 if ( color > GREEN ) {
AlanRager 0:63c1f03ccb9c 31 color = RED ;
AlanRager 0:63c1f03ccb9c 32 }
AlanRager 0:63c1f03ccb9c 33 }
AlanRager 0:63c1f03ccb9c 34 }