Library and demo using the WS2812-based Neopixel strip connected to an LPC114

Dependencies:   mbed

Fork of LEDTape_WS2812 by Suga koubou

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 /*
00002  * WS2812 tape led IC
00003  */
00004 #include "mbed.h"
00005 #include "LEDStrip.h"
00006 #include <stdint.h>
00007 #include "LEDStripFunctions.h"
00008 
00009 //Serial pc(USBTX, USBRX);
00010 DigitalOut led1(LED1), led2(LED2), led3(LED3), led4(LED4);
00011 
00012 extern "C"
00013 void HardFault_Handler() {
00014     printf("Hard Fault!\r\n");
00015     exit(-1);
00016 }
00017 
00018 int main() {
00019     uint32_t i;
00020     int j, k = 0;
00021     
00022     int numLEDs = 59;
00023   //  pc.baud(115200);
00024     tapeInit(0, numLEDs);
00025     led1 = 1;
00026 
00027    // pc.printf("led\r\n");
00028     int color_on = (0xff << 16) | (0xff << 8) | (0xff);
00029 
00030     uint32_t colors[numLEDs];
00031     /*
00032     for (k = 0; k < numLEDs; k++)
00033     {
00034         colors[k] = (k*260000);
00035     }*/
00036     
00037     setEveryMod(colors, 0xff, 6, 0, numLEDs);
00038     setEveryMod(colors, (0xff<<8), 6, 1, numLEDs);
00039     setEveryMod(colors, (0xff<<16), 6, 2, numLEDs);
00040     setEveryMod(colors, (0xff<<16)|(0xff<<8), 6, 3, numLEDs);
00041     setEveryMod(colors, (0xff<<8)|(0xff), 6, 4, numLEDs);
00042     setEveryMod(colors, (0xff<<16)|(0xff), 6, 5, numLEDs);
00043     scaleBrightness(colors, 8, numLEDs);
00044 
00045     for (;;) {
00046             led1 = 1;           
00047             
00048             
00049             
00050             for(i = 0; i < 59; i++);
00051             {
00052                 
00053                 shiftAllFwd(colors, numLEDs);   
00054                 setAll(colors, numLEDs);
00055                 led1 = 0;
00056                 tapeSend();
00057                 wait_ms(500);
00058                 
00059                 shiftAllFwd(colors, numLEDs);                
00060                 setAll(colors, numLEDs);
00061                 led1 = 1;
00062                 tapeSend();
00063                 wait_ms(500);
00064             }
00065     }
00066 }