The London Hackspace bandwidth meter

Dependencies:   LPD8806 MODSERIAL mbed picojson

See:

Files at this revision

API Documentation at this revision

Comitter:
Jasper
Date:
Sun Jun 10 19:23:12 2012 +0000
Child:
1:e384e7146746
Commit message:
initial version, in the middle of simplifying

Changed in this revision

LPD8806.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.lib Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LPD8806.lib	Sun Jun 10 19:23:12 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/ehbmbed2/libraries/LPD8806/m2abi7
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Jun 10 19:23:12 2012 +0000
@@ -0,0 +1,137 @@
+#include "mbed.h"
+
+#include "LPD8806.h"
+
+DigitalOut led1(LED1);
+DigitalOut led2(LED2);
+DigitalOut led3(LED3);
+DigitalOut led4(LED4);
+
+LPD8806 strip = LPD8806(32);
+
+/* 0 - 16 */
+void top_strip(int quantity){
+    int i;
+    
+    if (quantity == 0) {
+        // blank it
+        setPixelsTop(0, 16, 0);
+    }
+
+    setPixelsTop(0, quantity < 12 ? quantity : 12, strip.Color(0, 127, 0));
+        
+    for (i = 0 ; i < 12 ; i++) {
+        if (i <= quantity)
+            strip.setPixelColor(i, 0, 127, 0);
+        else
+            strip.setPixelColor(i, 0, 0, 0);
+    }
+    i = 12;
+    if (i <= quantity)
+        strip.setPixelColor(i, 127, 127, 0);
+    else
+        strip.setPixelColor(i, 0, 0, 0);
+
+    i = 13;
+    if (i <= quantity)
+        strip.setPixelColor(i, 127, 127, 0);
+    else
+        strip.setPixelColor(i, 0, 0, 0);
+
+    i = 14;
+    if (i <= quantity)
+        strip.setPixelColor(i, 127, 0, 0);
+    else
+        strip.setPixelColor(i, 0, 0, 0);
+
+    i = 15;
+    if (i <= quantity)
+        strip.setPixelColor(i, 127, 0, 0);
+    else
+        strip.setPixelColor(i, 0, 0, 0);
+
+    strip.show();
+}
+
+void bottom_strip(int quantity){
+    int i;
+    
+    for (i = 0 ; i < 12 ; i++) {
+        if (i <= quantity)
+            strip.setPixelColor(16 + i, 0, 127, 0);
+        else
+            strip.setPixelColor(16 + i, 0, 0, 0);
+    }
+    i = 12;
+    if (i <= quantity)
+        strip.setPixelColor(16 + i, 127, 127, 0);
+    else
+        strip.setPixelColor(16 + i, 0, 0, 0);
+
+    i = 13;
+    if (i <= quantity)
+        strip.setPixelColor(16 + i, 127, 127, 0);
+    else
+        strip.setPixelColor(16 + i, 0, 0, 0);
+
+    i = 14;
+    if (i <= quantity)
+        strip.setPixelColor(16 + i, 127, 0, 0);
+    else
+        strip.setPixelColor(16 + i, 0, 0, 0);
+
+    i = 15;
+    if (i <= quantity)
+        strip.setPixelColor(16 + i, 127, 0, 0);
+    else
+        strip.setPixelColor(16 + i, 0, 0, 0);
+}
+
+void setPixelsTop(int start, int end, int colour) {
+    int i;
+
+    for (i = start; i < end + 1 ; i++) {
+        strip.setPixelColor(i, colour);
+    }
+}
+
+void setPixelsBottom(int start, int end, int colour) {
+    int i;
+
+    for (i = start; i < end + 1 ; i++) {
+        strip.setPixelColor(16 + i, colour);
+    }
+}
+
+int main() {
+    int count = 0;
+    int c2 = 0;
+    int i;
+
+    strip.begin();
+    
+    for (i = 0 ; i < strip.numPixels() ; i++) {
+        // clear the strip
+        strip.setPixelColor(i, 0);
+    }
+    
+    strip.show();
+    
+    while(1) {
+
+        if (c2 > 16) c2 = 0;
+
+        led1 = 1;
+        wait(0.25);
+        led1 = 0;
+        count ++;
+        if (count > 2)
+        {
+            top_strip(c2);
+            bottom_strip(c2);
+            strip.show();
+            count = 0;
+            c2 ++;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.lib	Sun Jun 10 19:23:12 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/projects/libraries/svn/mbed/trunk@43
\ No newline at end of file