Test program to exercise the filagree library: http://mbed.org/users/yusufx/libraries/filagree

Dependencies:   mbed filagree

Files at this revision

API Documentation at this revision

Comitter:
yusufx
Date:
Wed May 30 21:14:32 2012 +0000
Commit message:

Changed in this revision

filagree.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 23a8b3249249 filagree.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/filagree.lib	Wed May 30 21:14:32 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/yusufx/code/filagree/#1a89e28dea91
diff -r 000000000000 -r 23a8b3249249 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed May 30 21:14:32 2012 +0000
@@ -0,0 +1,27 @@
+#include "mbed.h"
+#include "vm.h"
+#include "compile.h"
+#include "interpret.h"
+
+BusOut leds(LED1, LED2, LED3, LED4);
+Serial pc(USBTX, USBRX); // tx, rx
+
+void callback(struct Context *context) {
+    struct stack *stack = context->rhs;
+    struct variable *f = (struct variable*)stack_pop(stack);
+    const char *fstr = byte_array_to_string(f->str);
+    struct variable *v = (struct variable*)stack_pop(stack);
+
+    if (!strcmp(fstr, "blink")) {
+        pc.printf("blink %d\n\r", v->integer);
+        leds = 1 << v->integer;
+    } else if (!strcmp(fstr, "wait")) {
+        pc.printf("wait %.1f\n\r", v->floater);
+        wait(v->floater);
+    }
+}
+
+int main() {
+    const char *fg = "b = 0 while b<40 vm.yield('blink',b%4) b = b+1 vm.yield('wait',0.5) end";
+    interpret_string(fg, &callback);
+}
\ No newline at end of file
diff -r 000000000000 -r 23a8b3249249 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed May 30 21:14:32 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/737756e0b479