2 * Copyright © 2011 Keith Packard <keithp@keithp.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
21 #include <ao_profile.h>
27 #include <ao_console.h>
28 #include <ao_sdcard.h>
31 #include <ao_button.h>
33 #include <ao_as1107.h>
35 struct ao_task ball_task;
42 static int ball_dx, ball_dy;
55 ao_sleep(&ball_enable);
57 ao_line(&ao_vga_bitmap,
58 -100, -100, ball_x*2, ball_y*2,
60 ao_text(&ao_vga_bitmap,
64 ao_rect(&ao_vga_bitmap,
70 ao_delay(AO_MS_TO_TICKS(10));
71 ao_rect(&ao_vga_bitmap,
77 ao_text(&ao_vga_bitmap,
81 ao_line(&ao_vga_bitmap,
82 -100, -100, ball_x*2, ball_y*2,
88 if (ball_x + BALL_WIDTH > AO_VGA_WIDTH) {
89 ball_x = AO_VGA_WIDTH - BALL_WIDTH;
96 if (ball_y + BALL_HEIGHT > AO_VGA_HEIGHT) {
97 ball_y = AO_VGA_HEIGHT - BALL_HEIGHT;
111 ao_rect(&ao_vga_bitmap,
112 0, 0, AO_VGA_WIDTH, AO_VGA_HEIGHT,
115 ao_rect(&ao_vga_bitmap,
119 ao_rect(&ao_vga_bitmap,
120 AO_VGA_WIDTH - 20, 10, 10, 10,
123 ao_rect(&ao_vga_bitmap,
124 10, AO_VGA_HEIGHT - 20, 10, 10,
127 ao_rect(&ao_vga_bitmap,
128 AO_VGA_WIDTH - 20, AO_VGA_HEIGHT - 20, 10, 10,
131 ao_text(&ao_vga_bitmap,
136 ao_text(&ao_vga_bitmap,
141 ao_text(&ao_vga_bitmap,
142 1, AO_VGA_HEIGHT - ao_font.descent,
148 ao_video_toggle(void)
153 ao_vga_enable(ao_cmd_lex_i);
160 ball_enable = ao_cmd_lex_i;
161 ao_wakeup(&ball_enable);
165 ao_ps2_read_keys(void)
170 c = ao_ps2_getchar();
171 printf("%02x %c\n", c, ' ' <= c && c < 0x7f ? c : '.');
179 ao_console_send(void)
183 while ((c = getchar()) != '~') {
184 ao_console_putchar(c);
189 static void lisp_cmd() {
190 ao_lisp_read_eval_print();
194 ao_serial_blather(void)
198 while ((c = getchar()) != '~') {
199 ao_serial1_putchar(c);
200 ao_serial2_putchar(c);
211 start = ao_cmd_lex_i;
213 value = ao_cmd_lex_i;
214 if (ao_cmd_status != ao_cmd_success)
216 ao_as1107_write_8(start, value);
219 __code struct ao_cmds ao_demo_cmds[] = {
220 { ao_video_toggle, "V\0Toggle video" },
221 { ao_ball_toggle, "B\0Toggle ball" },
222 { ao_ps2_read_keys, "K\0Read keys from keyboard" },
223 { ao_console_send, "C\0Send data to console, end with ~" },
224 { ao_serial_blather, "S\0Blather on serial ports briefly" },
225 { lisp_cmd, "l\0Run lisp interpreter" },
226 { led_cmd, "L start value\0Show value (byte) at digit start" },
230 static struct ao_task event_task;
239 printf("type %d uint %d tick %d value %d\n",
240 ev.type, ev.unit, ev.tick, ev.value);
279 ao_add_task(&ball_task, ao_ball, "ball");
280 ao_add_task(&event_task, ao_event_loop, "events");
281 ao_cmd_register(&ao_demo_cmds[0]);
283 ao_start_scheduler();