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>
30 #include <ao_scheme.h>
31 #include <ao_button.h>
33 #include <ao_as1107.h>
37 struct ao_task ball_task;
44 static int ball_dx, ball_dy;
57 ao_sleep(&ball_enable);
59 ao_line(&ao_vga_bitmap,
60 -100, -100, ball_x*2, ball_y*2,
62 ao_text(&ao_vga_bitmap,
66 ao_rect(&ao_vga_bitmap,
72 ao_delay(AO_MS_TO_TICKS(10));
73 ao_rect(&ao_vga_bitmap,
79 ao_text(&ao_vga_bitmap,
83 ao_line(&ao_vga_bitmap,
84 -100, -100, ball_x*2, ball_y*2,
90 if (ball_x + BALL_WIDTH > AO_VGA_WIDTH) {
91 ball_x = AO_VGA_WIDTH - BALL_WIDTH;
98 if (ball_y + BALL_HEIGHT > AO_VGA_HEIGHT) {
99 ball_y = AO_VGA_HEIGHT - BALL_HEIGHT;
113 ao_rect(&ao_vga_bitmap,
114 0, 0, AO_VGA_WIDTH, AO_VGA_HEIGHT,
117 ao_rect(&ao_vga_bitmap,
121 ao_rect(&ao_vga_bitmap,
122 AO_VGA_WIDTH - 20, 10, 10, 10,
125 ao_rect(&ao_vga_bitmap,
126 10, AO_VGA_HEIGHT - 20, 10, 10,
129 ao_rect(&ao_vga_bitmap,
130 AO_VGA_WIDTH - 20, AO_VGA_HEIGHT - 20, 10, 10,
133 ao_text(&ao_vga_bitmap,
138 ao_text(&ao_vga_bitmap,
143 ao_text(&ao_vga_bitmap,
144 1, AO_VGA_HEIGHT - ao_font.descent,
150 ao_video_toggle(void)
155 ao_vga_enable(ao_cmd_lex_i);
162 ball_enable = ao_cmd_lex_i;
163 ao_wakeup(&ball_enable);
167 ao_ps2_read_keys(void)
172 c = ao_ps2_getchar();
173 printf("%02x %c\n", c, ' ' <= c && c < 0x7f ? c : '.');
181 ao_console_send(void)
185 while ((c = getchar()) != '~') {
186 ao_console_putchar(c);
191 static void scheme_cmd() {
192 ao_scheme_read_eval_print();
196 ao_serial_blather(void)
200 while ((c = getchar()) != '~') {
201 ao_serial1_putchar(c);
202 ao_serial2_putchar(c);
213 start = ao_cmd_lex_i;
215 value = ao_cmd_lex_i;
216 if (ao_cmd_status != ao_cmd_success)
218 ao_as1107_write_8(start, value);
221 __code struct ao_cmds ao_demo_cmds[] = {
222 { ao_video_toggle, "V\0Toggle video" },
223 { ao_ball_toggle, "B\0Toggle ball" },
224 { ao_ps2_read_keys, "K\0Read keys from keyboard" },
225 { ao_console_send, "C\0Send data to console, end with ~" },
226 { ao_serial_blather, "S\0Blather on serial ports briefly" },
227 { scheme_cmd, "l\0Run scheme interpreter" },
228 { led_cmd, "L start value\0Show value (byte) at digit start" },
232 static struct ao_task event_task;
241 printf("type %d uint %d tick %d value %d\n",
242 ev.type, ev.unit, ev.tick, ev.value);
285 ao_add_task(&ball_task, ao_ball, "ball");
286 ao_add_task(&event_task, ao_event_loop, "events");
287 ao_cmd_register(&ao_demo_cmds[0]);
289 ao_start_scheduler();