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.
22 #include <ao_quadrature.h>
23 #include <ao_button.h>
27 #include <ao_console.h>
29 struct ao_task ball_task;
30 struct ao_task ps2_task;
37 static int ball_dx, ball_dy;
50 ao_sleep(&ball_enable);
52 ao_line(&ao_vga_bitmap,
53 -100, -100, ball_x*2, ball_y*2,
55 ao_text(&ao_vga_bitmap,
59 ao_rect(&ao_vga_bitmap,
65 ao_delay(AO_MS_TO_TICKS(10));
66 ao_rect(&ao_vga_bitmap,
72 ao_text(&ao_vga_bitmap,
76 ao_line(&ao_vga_bitmap,
77 -100, -100, ball_x*2, ball_y*2,
83 if (ball_x + BALL_WIDTH > AO_VGA_WIDTH) {
84 ball_x = AO_VGA_WIDTH - BALL_WIDTH;
91 if (ball_y + BALL_HEIGHT > AO_VGA_HEIGHT) {
92 ball_y = AO_VGA_HEIGHT - BALL_HEIGHT;
108 uint8_t b = ao_ps2_get();
109 printf ("%02x\n", b);
114 if (ao_ps2_get() == 0xfa)
123 ao_rect(&ao_vga_bitmap,
124 0, 0, AO_VGA_WIDTH, AO_VGA_HEIGHT,
127 ao_rect(&ao_vga_bitmap,
131 ao_rect(&ao_vga_bitmap,
132 AO_VGA_WIDTH - 20, 10, 10, 10,
135 ao_rect(&ao_vga_bitmap,
136 10, AO_VGA_HEIGHT - 20, 10, 10,
139 ao_rect(&ao_vga_bitmap,
140 AO_VGA_WIDTH - 20, AO_VGA_HEIGHT - 20, 10, 10,
143 ao_text(&ao_vga_bitmap,
148 ao_text(&ao_vga_bitmap,
153 ao_text(&ao_vga_bitmap,
154 1, AO_VGA_HEIGHT - ao_font.descent,
160 ao_video_toggle(void)
162 uint16_t r = ao_cmd_decimal();
171 ball_enable = ao_cmd_decimal();
172 ao_wakeup(&ball_enable);
176 ao_ps2_read_keys(void)
181 c = ao_ps2_getchar();
182 printf("%02x %c\n", c, ' ' <= c && c < 0x7f ? c : '.');
190 ao_console_send(void)
194 while ((c = getchar()) != '~') {
195 ao_console_putchar(c);
200 const struct ao_cmds ao_demo_cmds[] = {
201 { ao_video_toggle, "V\0Toggle video" },
202 { ao_ball_toggle, "B\0Toggle ball" },
203 { ao_ps2_read_keys, "K\0Read keys from keyboard" },
204 { ao_console_send, "C\0Send data to console, end with ~" },
215 ao_led_init(LEDS_AVAILABLE);
216 ao_led_on(AO_LED_GREEN);
217 ao_led_off(AO_LED_BLUE);
227 ao_add_task(&ball_task, ao_ball, "ball");
228 ao_cmd_register(&ao_demo_cmds[0]);
230 ao_start_scheduler();