neopixel library based LED controller

Dependencies:   PixelArray mbed

This program is a controller for Christmas Tree with four ws2812 full color LED.

/media/uploads/morecat_lab/imgp0547.jpg /media/uploads/morecat_lab/imgp0560.jpg /media/uploads/morecat_lab/imgp0567.jpg

Files at this revision

API Documentation at this revision

Comitter:
morecat_lab
Date:
Sat Dec 13 06:58:47 2014 +0000
Commit message:
1st release

Changed in this revision

LAMd.h Show annotated file Show diff for this revision Revisions of this file
PixelArray.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r afb6ebe20c1f LAMd.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LAMd.h	Sat Dec 13 06:58:47 2014 +0000
@@ -0,0 +1,31 @@
+/* Arduino Compatible pin definition for LAM-daccha
+*/
+
+
+#ifndef LAMd
+#define LAMd
+
+#define D0 dp15
+#define D1 dp16
+#define D2 dp1
+#define D3 dp2
+#define D4 dp5    // OpenDrain
+#define D5 dp6
+#define D6 dp14
+#define D7 dp17
+#define D8 dp18
+#define D9 dp24
+#define D10 dp25
+#define D11 dp26
+#define D12 dp27  // OpenDrain
+#define D13 dp28
+
+#define A0 dp4
+#define A1 dp9
+#define A2 dp10
+#define A3 dp11
+#define A4 dp13
+#define A5 dp23
+
+
+#endif
diff -r 000000000000 -r afb6ebe20c1f PixelArray.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PixelArray.lib	Sat Dec 13 06:58:47 2014 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/JacobBramley/code/PixelArray/#47802e75974e
diff -r 000000000000 -r afb6ebe20c1f main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Dec 13 06:58:47 2014 +0000
@@ -0,0 +1,64 @@
+/*
+
+  Neopixel LED controller for mbed LPC1114 (RAMdaccha)
+ 
+  2014/12/13 by morecat_lab
+
+  This program depends on neopixel library.
+  http://developer.mbed.org/users/JacobBramley/code/PixelArray/
+
+*/
+#include "mbed.h"
+#include "neopixel.h"
+#include "LAMd.h"
+
+neopixel::Pixel pattern[] = {
+    {0x55, 0, 0xff},  // magenta
+    {0, 0, 0xff},  // blue
+    {0xaf, 0xaf, 0xaf}, // white
+    {0, 0xff, 0xff},  // cyan
+    {0xaf, 0xaf, 0}, // yellow
+    {0, 0xff, 0}, // greem
+    {0x2f, 0, 0}, // red
+};
+
+#define MAX_PATTERN (sizeof pattern / sizeof (struct neopixel::Pixel))
+#define MAX_INDEX (MAX_PATTERN *256)
+#define NLED (4)
+#define ONE_COLOR
+
+ void generate(neopixel::Pixel * out, uint32_t index, uintptr_t val) {
+#ifdef ONE_COLOR
+    uint32_t pat1 = val / 256;
+#else
+    uint32_t pat1 = val / 256 + index;
+#endif
+    uint32_t pat2;
+    uint32_t seq = val % 256;
+    
+    if (pat1 >= MAX_PATTERN) {
+        pat1 = 0;
+    }
+    pat2 = pat1 + 1;
+    if (pat2 >= MAX_PATTERN) {
+        pat2 = 0;
+    }
+    out->red   = (pattern[pat1].red   * (256-seq) + pattern[pat2].red   * seq) /256;
+    out->green = (pattern[pat1].green * (256-seq) + pattern[pat2].green * seq) /256;
+    out->blue  = (pattern[pat1].blue  * (256-seq) + pattern[pat2].blue  * seq) /256;
+ }
+
+
+int main() {
+    DigitalIn(D3, PullDown);
+    neopixel::PixelArray array(D3);
+ 
+    uint32_t val = 0;
+    while (1) {
+      if ((++val) >= MAX_INDEX) {
+        val = 0;
+      }
+      array.update(generate, NLED, val);
+      wait_ms(10);
+    }
+}
diff -r 000000000000 -r afb6ebe20c1f mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Dec 13 06:58:47 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/4fc01daae5a5
\ No newline at end of file