altos/telelco-v2.0: Mixed up the select_button pin (is E0, was set to E13)
[fw/altos] / src / cortexelf-v1 / ao_cortexelf.c
index 0c6852d96a88c2f98cde2889cda268773c7fd1f5..5ed78bf09c65865041ef80a530403efd9e331d5e 100644 (file)
 #include <ao_console.h>
 #include <ao_sdcard.h>
 #include <ao_fat.h>
+#include <ao_scheme.h>
+#include <ao_button.h>
+#include <ao_event.h>
+#include <ao_as1107.h>
+#include <ao_hex.h>
+#include <ao_1802.h>
 
 struct ao_task ball_task;
 
@@ -182,14 +188,62 @@ ao_console_send(void)
        }
 }
 
+static void scheme_cmd() {
+       ao_scheme_read_eval_print();
+}
+
+static void
+ao_serial_blather(void)
+{
+       char c;
+
+       while ((c = getchar()) != '~') {
+               ao_serial1_putchar(c);
+               ao_serial2_putchar(c);
+       }
+}
+
+static void
+led_cmd(void)
+{
+       uint8_t start;
+       uint8_t value;
+       ao_cmd_decimal();
+
+       start = ao_cmd_lex_i;
+       ao_cmd_hex();
+       value = ao_cmd_lex_i;
+       if (ao_cmd_status != ao_cmd_success)
+               return;
+       ao_as1107_write_8(start, value);
+}
+
 __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" },
+       { scheme_cmd, "l\0Run scheme interpreter" },
+       { led_cmd, "L start value\0Show value (byte) at digit start" },
        { 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)
 {
@@ -218,9 +272,18 @@ main(void)
 
        ao_usb_init();
 
+       ao_button_init();
+
+       ao_as1107_init();
+       ao_matrix_init();
+       ao_1802_init();
+
+       ao_hex_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();