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 struct ao_task ball_task;
34 static int ball_dx, ball_dy;
47 ao_sleep(&ball_enable);
49 ao_line(&ao_vga_bitmap,
50 -100, -100, ball_x*2, ball_y*2,
52 ao_text(&ao_vga_bitmap,
56 ao_rect(&ao_vga_bitmap,
62 ao_delay(AO_MS_TO_TICKS(10));
63 ao_rect(&ao_vga_bitmap,
69 ao_text(&ao_vga_bitmap,
73 ao_line(&ao_vga_bitmap,
74 -100, -100, ball_x*2, ball_y*2,
80 if (ball_x + BALL_WIDTH > AO_VGA_WIDTH) {
81 ball_x = AO_VGA_WIDTH - BALL_WIDTH;
88 if (ball_y + BALL_HEIGHT > AO_VGA_HEIGHT) {
89 ball_y = AO_VGA_HEIGHT - BALL_HEIGHT;
103 ao_rect(&ao_vga_bitmap,
104 0, 0, AO_VGA_WIDTH, AO_VGA_HEIGHT,
107 ao_rect(&ao_vga_bitmap,
111 ao_rect(&ao_vga_bitmap,
112 AO_VGA_WIDTH - 20, 10, 10, 10,
115 ao_rect(&ao_vga_bitmap,
116 10, AO_VGA_HEIGHT - 20, 10, 10,
119 ao_rect(&ao_vga_bitmap,
120 AO_VGA_WIDTH - 20, AO_VGA_HEIGHT - 20, 10, 10,
123 ao_text(&ao_vga_bitmap,
128 ao_text(&ao_vga_bitmap,
133 ao_text(&ao_vga_bitmap,
134 1, AO_VGA_HEIGHT - ao_font.descent,
140 ao_video_toggle(void)
145 ao_vga_enable(ao_cmd_lex_i);
152 ball_enable = ao_cmd_lex_i;
153 ao_wakeup(&ball_enable);
156 __code struct ao_cmds ao_demo_cmds[] = {
157 { ao_video_toggle, "V\0Toggle video" },
158 { ao_ball_toggle, "B\0Toggle ball" },
169 ao_led_init(LEDS_AVAILABLE);
170 ao_led_on(AO_LED_GREEN);
171 ao_led_off(AO_LED_BLUE);
178 ao_add_task(&ball_task, ao_ball, "ball");
179 ao_cmd_register(&ao_demo_cmds[0]);
181 ao_start_scheduler();