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>
34 struct ao_task ball_task;
41 static int ball_dx, ball_dy;
54 ao_sleep(&ball_enable);
56 ao_line(&ao_vga_bitmap,
57 -100, -100, ball_x*2, ball_y*2,
59 ao_text(&ao_vga_bitmap,
63 ao_rect(&ao_vga_bitmap,
69 ao_delay(AO_MS_TO_TICKS(10));
70 ao_rect(&ao_vga_bitmap,
76 ao_text(&ao_vga_bitmap,
80 ao_line(&ao_vga_bitmap,
81 -100, -100, ball_x*2, ball_y*2,
87 if (ball_x + BALL_WIDTH > AO_VGA_WIDTH) {
88 ball_x = AO_VGA_WIDTH - BALL_WIDTH;
95 if (ball_y + BALL_HEIGHT > AO_VGA_HEIGHT) {
96 ball_y = AO_VGA_HEIGHT - BALL_HEIGHT;
110 ao_rect(&ao_vga_bitmap,
111 0, 0, AO_VGA_WIDTH, AO_VGA_HEIGHT,
114 ao_rect(&ao_vga_bitmap,
118 ao_rect(&ao_vga_bitmap,
119 AO_VGA_WIDTH - 20, 10, 10, 10,
122 ao_rect(&ao_vga_bitmap,
123 10, AO_VGA_HEIGHT - 20, 10, 10,
126 ao_rect(&ao_vga_bitmap,
127 AO_VGA_WIDTH - 20, AO_VGA_HEIGHT - 20, 10, 10,
130 ao_text(&ao_vga_bitmap,
135 ao_text(&ao_vga_bitmap,
140 ao_text(&ao_vga_bitmap,
141 1, AO_VGA_HEIGHT - ao_font.descent,
147 ao_video_toggle(void)
152 ao_vga_enable(ao_cmd_lex_i);
159 ball_enable = ao_cmd_lex_i;
160 ao_wakeup(&ball_enable);
164 ao_ps2_read_keys(void)
169 c = ao_ps2_getchar();
170 printf("%02x %c\n", c, ' ' <= c && c < 0x7f ? c : '.');
178 ao_console_send(void)
182 while ((c = getchar()) != '~') {
183 ao_console_putchar(c);
188 static void lisp_cmd() {
189 ao_lisp_read_eval_print();
193 ao_serial_blather(void)
197 while ((c = getchar()) != '~') {
198 ao_serial1_putchar(c);
199 ao_serial2_putchar(c);
203 __code struct ao_cmds ao_demo_cmds[] = {
204 { ao_video_toggle, "V\0Toggle video" },
205 { ao_ball_toggle, "B\0Toggle ball" },
206 { ao_ps2_read_keys, "K\0Read keys from keyboard" },
207 { ao_console_send, "C\0Send data to console, end with ~" },
208 { ao_serial_blather, "S\0Blather on serial ports briefly" },
209 { lisp_cmd, "l\0Run lisp interpreter" },
213 static struct ao_task event_task;
222 printf("type %d uint %d tick %d value %d\n",
223 ev.type, ev.unit, ev.tick, ev.value);
260 ao_add_task(&ball_task, ao_ball, "ball");
261 ao_add_task(&event_task, ao_event_loop, "events");
262 ao_cmd_register(&ao_demo_cmds[0]);
264 ao_start_scheduler();