Library and demo using the WS2812-based Neopixel strip connected to an LPC114
Fork of LEDTape_WS2812 by
Details here: http://mbed.org/users/rhodes42/notebook/tiny-neopixel-controller-with-lpc1114/
Revision 3:743570d993aa, committed 2014-04-08
- Comitter:
- rhodes42
- Date:
- Tue Apr 08 20:56:03 2014 +0000
- Parent:
- 2:61abc599f31f
- Commit message:
- added scalebrightness and changed main demo
Changed in this revision
--- a/LEDStripFunctions.cpp Mon Mar 24 10:00:54 2014 +0000 +++ b/LEDStripFunctions.cpp Tue Apr 08 20:56:03 2014 +0000 @@ -51,4 +51,27 @@ { if ((i >= start) && ((i - start) % mod == 0)) buffer[i] = color; } +} + + +void scaleBrightness(uint32_t *buffer, int divider, int n) +{ + int i, r, g, b; + for (i = 0; i < n; i++) + { + r = (buffer[i] >> 16) & 0xff; + g = (buffer[i] >> 8 ) & 0xff; + b = (buffer[i] ) & 0xff; + r /= divider; + g /= divider; + b /= divider; + buffer[i] = (r << 16) | (g << 8) | (b); + } +} + +void setPixelRGB(int pixel, int r, int g, int b) +{ + + int pix = (r << 16) | (g << 8) | (b); + tapeSet(pixel, pix); } \ No newline at end of file
--- a/LEDStripFunctions.h Mon Mar 24 10:00:54 2014 +0000 +++ b/LEDStripFunctions.h Tue Apr 08 20:56:03 2014 +0000 @@ -6,3 +6,5 @@ void shiftAllFwd(uint32_t *buffer, int n); void shiftAllRev(uint32_t *buffer, int n); void setEveryMod(uint32_t * buffer, uint32_t color, int mod, int start, int n); +void scaleBrightness(uint32_t *buffer, int divider, int n); +void setPixelRGB(int pixel, int r, int g, int b); \ No newline at end of file
--- a/main.cpp Mon Mar 24 10:00:54 2014 +0000 +++ b/main.cpp Tue Apr 08 20:56:03 2014 +0000 @@ -34,10 +34,13 @@ colors[k] = (k*260000); }*/ - setEveryMod(colors, 0xff, 3, 0, numLEDs); - setEveryMod(colors, (0xff<<8), 3, 1, numLEDs); - setEveryMod(colors, (0xff<<16), 3, 2, numLEDs); - + setEveryMod(colors, 0xff, 6, 0, numLEDs); + setEveryMod(colors, (0xff<<8), 6, 1, numLEDs); + setEveryMod(colors, (0xff<<16), 6, 2, numLEDs); + setEveryMod(colors, (0xff<<16)|(0xff<<8), 6, 3, numLEDs); + setEveryMod(colors, (0xff<<8)|(0xff), 6, 4, numLEDs); + setEveryMod(colors, (0xff<<16)|(0xff), 6, 5, numLEDs); + scaleBrightness(colors, 8, numLEDs); for (;;) { led1 = 1; @@ -51,13 +54,13 @@ setAll(colors, numLEDs); led1 = 0; tapeSend(); - wait_ms(100); + wait_ms(500); shiftAllFwd(colors, numLEDs); setAll(colors, numLEDs); led1 = 1; tapeSend(); - wait_ms(100); + wait_ms(500); } } }