Rev 1347 | Rev 1389 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1347 | giacomo | 1 | |
2 | /* |
||
3 | * Project: S.Ha.R.K. |
||
4 | * |
||
5 | * Coordinators: Giorgio Buttazzo <giorgio@sssup.it> |
||
6 | * |
||
7 | * Authors : Mauro Marinoni <mauro.marinoni@unipv.it> |
||
8 | * (see authors.txt for full list of hartik's authors) |
||
9 | * |
||
10 | * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
||
11 | * |
||
12 | * http://www.sssup.it |
||
13 | * http://retis.sssup.it |
||
14 | * http://shark.sssup.it |
||
15 | */ |
||
16 | |||
17 | /* |
||
18 | * Copyright (C) 2000 Paolo Gai |
||
19 | * |
||
20 | * This program is free software; you can redistribute it and/or modify |
||
21 | * it under the terms of the GNU General Public License as published by |
||
22 | * the Free Software Foundation; either version 2 of the License, or |
||
23 | * (at your option) any later version. |
||
24 | * |
||
25 | * This program is distributed in the hope that it will be useful, |
||
26 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
27 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
28 | * GNU General Public License for more details. |
||
29 | * |
||
30 | * You should have received a copy of the GNU General Public License |
||
31 | * along with this program; if not, write to the Free Software |
||
32 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||
33 | * |
||
34 | */ |
||
35 | |||
36 | #include <kernel/kern.h> |
||
37 | #include <kernel/func.h> |
||
38 | #include <stdlib.h> |
||
39 | #include <string.h> |
||
40 | |||
41 | #include <drivers/shark_linuxc26.h> |
||
1363 | mauro | 42 | |
43 | #include <drivers/shark_fb26.h> |
||
44 | |||
1347 | giacomo | 45 | #include <drivers/shark_input26.h> |
46 | #include <drivers/shark_mouse26.h> |
||
47 | #include <drivers/shark_keyb26.h> |
||
48 | #include <drivers/shark_spk26.h> |
||
1363 | mauro | 49 | #include <drivers/shark_joy26.h> |
1347 | giacomo | 50 | |
1363 | mauro | 51 | #define FRAME_BUFFER_DEVICE 0 |
52 | |||
53 | #define RGB_BLACK rgb16( 0, 0, 0) |
||
54 | #define RGB_GRAY rgb16(127,127,127) |
||
55 | #define RGB_WHITE rgb16(255,255,255) |
||
56 | #define RGB_RED rgb16(255, 0, 0) |
||
57 | #define RGB_GREEN rgb16( 0,255, 0) |
||
58 | #define RGB_BLUE rgb16( 0, 0,255) |
||
59 | #define RGB_YELLOW rgb16(255,255, 0) |
||
60 | #define RGB_MAGENTA rgb16(255, 0,255) |
||
61 | #define RGB_CYAN rgb16( 0,255,255) |
||
62 | #define RGB_D_RED rgb16(127, 0, 0) |
||
63 | #define RGB_D_GREEN rgb16( 0,127, 0) |
||
64 | #define RGB_D_BLUE rgb16( 0, 0,127) |
||
65 | #define RGB_D_YELLOW rgb16(127,127, 0) |
||
66 | #define RGB_D_MAGENTA rgb16(127, 0,127) |
||
67 | #define RGB_D_CYAN rgb16( 0,127,127) |
||
68 | |||
1347 | giacomo | 69 | void my_sysclose(KEY_EVT *e) |
70 | { |
||
1363 | mauro | 71 | mouse_grxcursor(DISABLE, 0); |
72 | |||
73 | FB26_close(FRAME_BUFFER_DEVICE); |
||
74 | |||
75 | MOUSE26_close(); |
||
1347 | giacomo | 76 | KEYB26_close(); |
77 | SPEAK26_close(); |
||
1363 | mauro | 78 | JOY26_close(); |
1347 | giacomo | 79 | INPUT26_close(); |
80 | |||
81 | kern_printf("S.Ha.R.K. closed.\n\n"); |
||
82 | sys_end(); |
||
83 | } |
||
84 | |||
1363 | mauro | 85 | TASK my_getjoy(void *arg) { |
86 | |||
87 | int a0, a1, a2, a3, btn; |
||
88 | char st[20]; |
||
89 | |||
90 | while (1) { |
||
91 | joy_getstatus(&a0, &a1, &a2, &a3, &btn); |
||
92 | |||
93 | sprintf(st, "X Axis : %6d ", a0); |
||
94 | grx_text(st, 100, 64, RGB_CYAN, RGB_BLACK); |
||
95 | sprintf(st, "Y Axis : %6d ", a1); |
||
96 | grx_text(st, 100, 114, RGB_CYAN, RGB_BLACK); |
||
97 | sprintf(st, "Buttons: %2x ", btn); |
||
98 | grx_text(st, 100, 164, RGB_CYAN, RGB_BLACK); |
||
99 | |||
100 | task_endcycle(); |
||
101 | if (btn == 0xF) |
||
102 | my_sysclose(NULL); |
||
103 | } |
||
104 | } |
||
105 | |||
106 | TASK my_getch(void *arg) { |
||
107 | |||
108 | BYTE ch; |
||
109 | int i = 0; |
||
110 | char st[20]; |
||
111 | |||
112 | while (1) { |
||
113 | ch = keyb_getch(NON_BLOCK); |
||
114 | if (ch) { |
||
115 | sprintf(st, "%c", ch); |
||
116 | grx_text(st, 340 + 10 * (i%25), 30 + 20 * (i/25), RGB_BLUE, RGB_BLACK); |
||
117 | |||
118 | if (++i >= 200) |
||
119 | i = 0; |
||
120 | } |
||
121 | |||
122 | task_endcycle(); |
||
123 | } |
||
124 | } |
||
125 | |||
126 | void graph_init(void) |
||
127 | { |
||
128 | grx_rect( 4, 4, 634, 474, RGB_WHITE); |
||
129 | grx_rect( 14, 14, 304, 214, RGB_YELLOW); |
||
130 | grx_rect(314, 14, 624, 214, RGB_RED); |
||
131 | } |
||
132 | |||
1347 | giacomo | 133 | int main(int argc, char **argv) |
134 | { |
||
1363 | mauro | 135 | SOFT_TASK_MODEL mp; |
136 | PID pid; |
||
137 | |||
1347 | giacomo | 138 | KEY_EVT ev; |
139 | |||
140 | ev.ascii = 'c'; |
||
141 | ev.scan = KEY_C; |
||
142 | ev.status = KEY_PRESSED; |
||
143 | ev.flag = CNTL_BIT; |
||
144 | keyb_hook(ev, my_sysclose, FALSE); |
||
145 | ev.flag = CNTR_BIT; |
||
146 | keyb_hook(ev, my_sysclose, FALSE); |
||
147 | |||
1363 | mauro | 148 | FB26_init(); |
1347 | giacomo | 149 | |
1363 | mauro | 150 | FB26_open(FRAME_BUFFER_DEVICE); |
151 | |||
152 | FB26_use_grx(FRAME_BUFFER_DEVICE); |
||
153 | |||
154 | FB26_setmode(FRAME_BUFFER_DEVICE,"640x480-16"); |
||
155 | |||
156 | graph_init(); |
||
157 | |||
158 | mouse_grxlimits(639, 479); |
||
159 | mouse_setposition(319, 239, 0); |
||
160 | mouse_grxcursor(ENABLE, 2); |
||
161 | |||
162 | soft_task_default_model(mp); |
||
163 | soft_task_def_level(mp,2); |
||
164 | soft_task_def_ctrl_jet(mp); |
||
165 | soft_task_def_met(mp,700); |
||
166 | soft_task_def_period(mp,10000); |
||
167 | //soft_task_def_aperiodic(mp); |
||
168 | soft_task_def_usemath(mp); |
||
169 | pid = task_create("Joy_Print", my_getjoy, &mp, NULL); |
||
170 | if (pid == NIL) { |
||
171 | perror("Could not create task <Joy_Print>"); |
||
172 | sys_end(); |
||
173 | } else |
||
174 | task_activate(pid); |
||
175 | |||
176 | soft_task_default_model(mp); |
||
177 | soft_task_def_level(mp,2); |
||
178 | soft_task_def_ctrl_jet(mp); |
||
179 | soft_task_def_met(mp,700); |
||
180 | soft_task_def_period(mp,10000); |
||
181 | //soft_task_def_aperiodic(mp); |
||
182 | soft_task_def_usemath(mp); |
||
183 | pid = task_create("Key_Print", my_getch, &mp, NULL); |
||
184 | if (pid == NIL) { |
||
185 | perror("Could not create task <Key_Print>"); |
||
186 | sys_end(); |
||
187 | } else |
||
188 | task_activate(pid); |
||
189 | |||
1347 | giacomo | 190 | return 0; |
191 | } |