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

Dependencies:   mbed

Fork of LEDTape_WS2812 by Suga koubou

Details here: http://mbed.org/users/rhodes42/notebook/tiny-neopixel-controller-with-lpc1114/

Committer:
rhodes42
Date:
Mon Mar 24 10:00:54 2014 +0000
Revision:
2:61abc599f31f
Child:
3:743570d993aa
Working demo shifting Red Green & Blue

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rhodes42 2:61abc599f31f 1 #include "mbed.h"
rhodes42 2:61abc599f31f 2 #include "LEDStrip.h"
rhodes42 2:61abc599f31f 3 #include <stdint.h>
rhodes42 2:61abc599f31f 4
rhodes42 2:61abc599f31f 5
rhodes42 2:61abc599f31f 6 void setAll(uint32_t *buffer, int n)
rhodes42 2:61abc599f31f 7 {
rhodes42 2:61abc599f31f 8 int i;
rhodes42 2:61abc599f31f 9 for (i = 0; i < n; i++)
rhodes42 2:61abc599f31f 10 {
rhodes42 2:61abc599f31f 11 tapeSet(i, buffer[i]);
rhodes42 2:61abc599f31f 12 }
rhodes42 2:61abc599f31f 13 }
rhodes42 2:61abc599f31f 14
rhodes42 2:61abc599f31f 15 void setAllOneColor(uint32_t color, int n)
rhodes42 2:61abc599f31f 16 {
rhodes42 2:61abc599f31f 17 int i;
rhodes42 2:61abc599f31f 18 for (i = 0; i < n; i++)
rhodes42 2:61abc599f31f 19 {
rhodes42 2:61abc599f31f 20 tapeSet(i, color);
rhodes42 2:61abc599f31f 21 }
rhodes42 2:61abc599f31f 22 }
rhodes42 2:61abc599f31f 23
rhodes42 2:61abc599f31f 24 void shiftAllFwd(uint32_t *buffer, int n)
rhodes42 2:61abc599f31f 25 {
rhodes42 2:61abc599f31f 26 int i;
rhodes42 2:61abc599f31f 27 uint32_t temp = buffer[n];
rhodes42 2:61abc599f31f 28 for (i = n; i > 0; i--)
rhodes42 2:61abc599f31f 29 {
rhodes42 2:61abc599f31f 30 buffer[i] = buffer[i-1];
rhodes42 2:61abc599f31f 31 }
rhodes42 2:61abc599f31f 32 buffer[0] = temp;
rhodes42 2:61abc599f31f 33 }
rhodes42 2:61abc599f31f 34
rhodes42 2:61abc599f31f 35 void shiftAllRev(uint32_t *buffer, int n)
rhodes42 2:61abc599f31f 36 {
rhodes42 2:61abc599f31f 37 int i;
rhodes42 2:61abc599f31f 38 uint32_t temp = buffer[0];
rhodes42 2:61abc599f31f 39 for (i = 0; i <= n-1; i++)
rhodes42 2:61abc599f31f 40 {
rhodes42 2:61abc599f31f 41 buffer[i] = buffer[i+1];
rhodes42 2:61abc599f31f 42 }
rhodes42 2:61abc599f31f 43 buffer[n] = temp;
rhodes42 2:61abc599f31f 44 }
rhodes42 2:61abc599f31f 45
rhodes42 2:61abc599f31f 46
rhodes42 2:61abc599f31f 47 void setEveryMod(uint32_t * buffer, uint32_t color, int mod, int start, int n)
rhodes42 2:61abc599f31f 48 {
rhodes42 2:61abc599f31f 49 int i;
rhodes42 2:61abc599f31f 50 for (i = 0; i < n; i ++)
rhodes42 2:61abc599f31f 51 {
rhodes42 2:61abc599f31f 52 if ((i >= start) && ((i - start) % mod == 0)) buffer[i] = color;
rhodes42 2:61abc599f31f 53 }
rhodes42 2:61abc599f31f 54 }