cortexelf-v1: Add buttons
[fw/altos] / src / cortexelf-v1 / ao_cortexelf.c
index 67062c85bee05723e3787bf5369a3e56496eb8df..8be7ef151457acd362733157709f0684dd7ff159 100644 (file)
 #include <ao_vga.h>
 #include <ao_console.h>
 #include <ao_sdcard.h>
+#include <ao_fat.h>
+#include <ao_lisp.h>
+#include <ao_button.h>
+#include <ao_event.h>
 
 struct ao_task ball_task;
 
@@ -181,14 +185,46 @@ ao_console_send(void)
        }
 }
 
+static void lisp_cmd() {
+       ao_lisp_read_eval_print();
+}
+
+static void
+ao_serial_blather(void)
+{
+       char c;
+
+       while ((c = getchar()) != '~') {
+               ao_serial1_putchar(c);
+               ao_serial2_putchar(c);
+       }
+}
+
 __code struct ao_cmds ao_demo_cmds[] = {
        { ao_video_toggle, "V\0Toggle video" },
        { ao_ball_toggle, "B\0Toggle ball" },
        { ao_ps2_read_keys, "K\0Read keys from keyboard" },
        { ao_console_send, "C\0Send data to console, end with ~" },
+       { ao_serial_blather, "S\0Blather on serial ports briefly" },
+       { lisp_cmd, "l\0Run lisp interpreter" },
        { 0, NULL }
 };
 
+static struct ao_task event_task;
+
+static void
+ao_event_loop(void)
+{
+       for (;;) {
+               struct ao_event ev;
+
+               ao_event_get(&ev);
+               printf("type %d uint %d tick %d value %d\n",
+                      ev.type, ev.unit, ev.tick, ev.value);
+               flush();
+       }
+}
+
 int
 main(void)
 {
@@ -207,6 +243,7 @@ main(void)
        ao_exti_init();
 
        ao_sdcard_init();
+       ao_fat_init();
 
        ao_ps2_init();
        ao_vga_init();
@@ -216,9 +253,12 @@ main(void)
 
        ao_usb_init();
 
+       ao_button_init();
+
        ao_config_init();
 
        ao_add_task(&ball_task, ao_ball, "ball");
+       ao_add_task(&event_task, ao_event_loop, "events");
        ao_cmd_register(&ao_demo_cmds[0]);
 
        ao_start_scheduler();