errors

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
bagbag
Date:
Sat Mar 15 21:29:36 2014 +0000
Commit message:
errors

Changed in this revision

animations.h 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 ed91de6e3a1b animations.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/animations.h	Sat Mar 15 21:29:36 2014 +0000
@@ -0,0 +1,453 @@
+int animation1[][10] = {
+    {
+        1, 0, 0,
+        0, 1, 0,
+        0, 0, 1, 50
+    },
+    {
+        0, 0, 0,
+        1, 1, 1,
+        0, 0, 0, 50
+    },
+    {
+        0, 0, 1,
+        0, 1, 0,
+        1, 0, 0, 50
+    },
+    {
+        0, 1, 0,
+        0, 1, 0,
+        0, 1, 0, 50
+    }
+};
+
+int animation2[][10] = {
+    {
+        1, 0, 0,
+        0, 1, 0,
+        0, 0, 1, 100
+    },
+    {
+        1, 1, 1,
+        0, 0, 0,
+        0, 0, 0, 100
+    },
+    {
+        0, 0, 1,
+        0, 1, 0,
+        1, 0, 0, 100
+    },
+    {
+        0, 0, 1,
+        0, 0, 1,
+        0, 0, 1, 100
+    },
+    {
+        1, 0, 0,
+        0, 1, 0,
+        0, 0, 1, 100
+    },
+    {
+        0, 0, 0,
+        0, 0, 0,
+        1, 1, 1, 100
+    },
+    {
+        0, 0, 1,
+        0, 1, 0,
+        1, 0, 0, 100
+    },
+    {
+        1, 0, 0,
+        1, 0, 0,
+        1, 0, 0, 100
+    }
+};
+
+int animation3[][10] = {
+    {
+        1, 0, 0,
+        1, 0, 0,
+        1, 0, 0, 100
+    },
+    {
+        0, 1, 0,
+        0, 1, 0,
+        0, 1, 0, 100
+    },
+    {
+        0, 0, 1,
+        0, 0, 1,
+        0, 0, 1, 250
+    },
+    {
+        0, 1, 0,
+        0, 1, 0,
+        0, 1, 0, 100
+    },
+    {
+        1, 0, 0,
+        1, 0, 0,
+        1, 0, 0, 100
+    },
+    {
+        0, 1, 0,
+        0, 1, 0,
+        0, 1, 0, 100
+    },
+    {
+        0, 0, 1,
+        0, 0, 1,
+        0, 0, 1, 100
+    },
+    {
+        0, 1, 0,
+        0, 1, 0,
+        0, 1, 0, 100
+    },
+    {
+        1, 0, 0,
+        1, 0, 0,
+        1, 0, 0, 100
+    },
+    {
+        0, 1, 0,
+        0, 1, 0,
+        0, 1, 0, 100
+    },
+    {
+        0, 0, 1,
+        0, 0, 1,
+        0, 0, 1, 100
+    },
+    {
+        0, 0, 0,
+        0, 0, 0,
+        0, 0, 0, 100
+    },
+    {
+        0, 0, 1,
+        0, 0, 1,
+        0, 0, 1, 100
+    },
+    {
+        0, 0, 0,
+        0, 0, 0,
+        0, 0, 0, 50
+    },
+    {
+        1, 0, 0,
+        0, 1, 0,
+        0, 0, 1, 100
+    },
+    {
+        0, 0, 0,
+        0, 0, 0,
+        0, 0, 0, 50
+    },
+    {
+        0, 0, 0,
+        0, 0, 0,
+        1, 1, 1, 100
+    },
+    {
+        0, 0, 0,
+        1, 1, 1,
+        0, 0, 0, 100
+    },
+    {
+        1, 1, 1,
+        0, 0, 0,
+        0, 0, 0, 100
+    },
+    {
+        0, 0, 0,
+        1, 1, 1,
+        0, 0, 0, 100
+    },
+    {
+        0, 0, 0,
+        0, 0, 0,
+        1, 1, 1, 100
+    },
+    {
+        0, 0, 0,
+        1, 1, 1,
+        0, 0, 0, 100
+    },
+    {
+        1, 1, 1,
+        0, 0, 0,
+        0, 0, 0, 100
+    },
+    {
+        0, 0, 0,
+        1, 1, 1,
+        0, 0, 0, 100
+    },
+    {
+        0, 0, 0,
+        0, 0, 0,
+        1, 1, 1, 100
+    },
+    {
+        0, 0, 0,
+        1, 1, 1,
+        0, 0, 0, 100
+    },
+    {
+        1, 1, 1,
+        0, 0, 0,
+        0, 0, 0, 100
+    },
+    {
+        0, 0, 0,
+        0, 0, 0,
+        0, 0, 0, 50
+    },
+    {
+        1, 0, 0,
+        0, 1, 0,
+        0, 0, 1, 100
+    },
+    {
+        0, 0, 0,
+        0, 0, 0,
+        0, 0, 0, 50
+    },
+    {
+        0, 0, 1,
+        0, 1, 0,
+        1, 0, 0, 100
+    },
+    {
+        0, 0, 0,
+        0, 0, 0,
+        0, 0, 0, 50
+    },
+    {
+        1, 0, 1,
+        0, 1, 0,
+        1, 0, 1, 150
+    },
+    {
+        0, 0, 0,
+        0, 0, 0,
+        0, 0, 0, 50
+    },
+    {
+        1, 0, 1,
+        0, 1, 0,
+        1, 0, 1, 150
+    }
+};
+
+int animation4[][10] = {
+    {
+        1, 0, 0,
+        0, 0, 0,
+        0, 0, 0, 100
+    },
+    {
+        1, 0, 0,
+        0, 1, 0,
+        0, 0, 0, 100
+    },
+    {
+        1, 0, 0,
+        0, 1, 0,
+        0, 0, 1, 100
+    },
+    {
+        0, 0, 0,
+        0, 1, 0,
+        0, 0, 1, 100
+    },
+    {
+        0, 0, 0,
+        0, 0, 0,
+        0, 0, 1, 100
+    },
+    {
+        0, 0, 1,
+        0, 0, 0,
+        0, 0, 0, 100
+    },
+    {
+        0, 0, 1,
+        0, 1, 0,
+        0, 0, 0, 100
+    },
+    {
+        0, 0, 1,
+        0, 1, 0,
+        1, 0, 0, 100
+    },
+    {
+        0, 0, 0,
+        0, 1, 0,
+        1, 0, 0, 100
+    },
+    {
+        0, 0, 0,
+        0, 0, 0,
+        1, 0, 0, 100
+    }
+};
+
+int animation5[][10] = {
+    {
+        0, 0, 0,
+        0, 1, 0,
+        0, 0, 0, 70
+    },
+    {
+        0, 0, 1,
+        0, 0, 0,
+        0, 0, 0, 70
+    },
+    {
+        0, 0, 0,
+        0, 1, 0,
+        0, 0, 0, 70
+    },
+    {
+        0, 0, 0,
+        0, 0, 1,
+        0, 0, 0, 70
+    },
+    {
+        0, 0, 0,
+        0, 1, 0,
+        0, 0, 0, 70
+    },
+    {
+        0, 0, 0,
+        0, 0, 0,
+        0, 0, 1, 70
+    },
+    {
+        0, 0, 0,
+        0, 1, 0,
+        0, 0, 0, 70
+    },
+    {
+        0, 0, 0,
+        0, 0, 0,
+        0, 1, 0, 70
+    },
+    {
+        0, 0, 0,
+        0, 1, 0,
+        0, 0, 0, 70
+    },
+    {
+        0, 0, 0,
+        0, 0, 0,
+        1, 0, 0, 70
+    },
+    {
+        0, 0, 0,
+        0, 1, 0,
+        0, 0, 0, 70
+    },
+    {
+        0, 0, 0,
+        1, 0, 0,
+        0, 0, 0, 70
+    },
+    {
+        0, 0, 0,
+        0, 1, 0,
+        0, 0, 0, 70
+    },
+    {
+        1, 0, 0,
+        0, 0, 0,
+        0, 0, 0, 70
+    },
+    {
+        0, 0, 0,
+        0, 1, 0,
+        0, 0, 0, 70
+    },
+    {
+        0, 1, 0,
+        0, 0, 0,
+        0, 0, 0, 70
+    }
+};
+
+int transition6[][10] = {
+    {
+        1, 0, 0,
+        0, 0, 0,
+        0, 0, 0, 100
+    },
+    {
+        1, 1, 0,
+        1, 0, 0,
+        0, 0, 0, 100
+    }
+};
+
+int animation6[][10] = {
+    {
+        1, 1, 1,
+        1, 1, 0,
+        1, 0, 0, 100
+    },
+    {
+        0, 1, 1,
+        1, 1, 1,
+        1, 1, 0, 100
+    },
+    {
+        0, 0, 1,
+        0, 1, 1,
+        1, 1, 1, 100
+    },
+    {
+        1, 0, 0,
+        0, 0, 1,
+        0, 1, 1, 100
+    },
+    {
+        1, 1, 0,
+        1, 0, 0,
+        0, 0, 1, 100
+    }
+};
+
+int end6[][10] = {
+    {
+        1, 1, 1,
+        1, 1, 0,
+        1, 0, 0, 100
+    },
+    {
+        0, 1, 1,
+        1, 1, 1,
+        1, 1, 0, 100
+    },
+    {
+        0, 0, 1,
+        0, 1, 1,
+        1, 1, 1, 100
+    },
+    {
+        0, 0, 0,
+        0, 0, 1,
+        0, 1, 1, 100
+    },
+    {
+        0, 0, 0,
+        0, 0, 0,
+        0, 0, 1, 100
+    },
+    {
+        0, 0, 0,
+        0, 0, 0,
+        0, 0, 0, 100
+    }
+};
diff -r 000000000000 -r ed91de6e3a1b main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Mar 15 21:29:36 2014 +0000
@@ -0,0 +1,137 @@
+#include "mbed.h"
+#include "animations.h"
+
+DigitalOut ledy0(PC_0);
+DigitalOut ledy1(PC_1);
+DigitalOut ledy2(PC_2);
+DigitalOut ledx0(PC_13);
+DigitalOut ledx1(PC_14);
+DigitalOut ledx2(PC_15);
+
+AnalogIn poti(A0);
+
+void turnOn(short x, short y)
+{
+    switch(x) {
+        case 0:
+            ledx0 = 0;
+            break;
+        case 1:
+            ledx1 = 0;
+            break;
+        case 2:
+            ledx2 = 0;
+            break;
+    }
+
+    switch(y) {
+        case 0:
+            ledy0 = 1;
+            break;
+        case 1:
+            ledy1 = 1;
+            break;
+        case 2:
+            ledy2 = 1;
+            break;
+    }
+}
+
+void turnOff(short x, short y)
+{
+    switch(x) {
+        case 0:
+            ledx0 = 1;
+            break;
+        case 1:
+            ledx1 = 1;
+            break;
+        case 2:
+            ledx2 = 1;
+            break;
+    }
+
+    switch(y) {
+        case 0:
+            ledy0 = 0;
+            break;
+        case 1:
+            ledy1 = 0;
+            break;
+        case 2:
+            ledy2 = 0;
+            break;
+    }
+}
+
+void setPixel(int x, int y, bool on)
+{
+    if (on)
+        turnOn(x,y);
+    else
+        turnOff(x,y);
+}
+
+int delay = 100;
+
+void updateDelay()
+{
+    delay = 1000 + pow(poti * 4, 4) * 1000;
+}
+
+int leds[9][2] = {
+    { 0, 0 },
+    { 1, 0 },
+    { 2, 0 },
+    { 0, 1 },
+    { 1, 1 },
+    { 2, 1 },
+    { 0, 2 },
+    { 1, 2 },
+    { 2, 2 },
+};
+
+void animate(int animation[][10] animation, int cycles, bool inverted = false)
+{
+    int frames = sizeof(animation) / 320;
+
+    for (int frame = 0; frame < frames; frame++) {
+        int frameTime = animation[frame][9];
+
+        Timer timer;
+
+        while (timer.read_ms() < frameTime) {
+            for (int pixel = 0; pixel < 9; pixel++) {
+                bool state = (bool)animation[frame][pixel] ^ inverted;
+                setPixel(leds[pixel][0], leds[pixel][1], state);
+                wait_us(delay);
+                setPixel(leds[pixel][0], leds[pixel][1], !state);
+            }
+        }
+    }
+}
+
+void init()
+{
+    for (int x = 0; x<3; x++)
+        for (int y = 0; y<3; y++)
+            turnOff(x,y);
+}
+
+int main()
+{
+    init();
+    Ticker ticker;
+    ticker.attach(&updateDelay, 0.05);
+
+    while(true) {
+        animate(animation1, 8);
+        animate(animation2, 2);
+        animate(animation3, 1);
+        animate(animation4, 2);
+        animate(animation5, 2);
+        animate(transition6, 1);
+        animate(animation6, 3);
+        animate(end6, 1);
+    }
+}
diff -r 000000000000 -r ed91de6e3a1b mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Mar 15 21:29:36 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/8e73be2a2ac1
\ No newline at end of file