Rev 1655 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1655 | giacomo | 1 | |
2 | /* |
||
3 | * Project: S.Ha.R.K. |
||
4 | * |
||
5 | * Coordinators: Giorgio Buttazzo <giorgio@sssup.it> |
||
6 | * |
||
7 | * Authors : Paolo Gai <pj@hartik.sssup.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 <drivers/keyb.h> |
||
40 | #include <math.h> |
||
41 | |||
42 | #include "joy.h" |
||
43 | |||
44 | PID pid; |
||
45 | |||
46 | void endfun(KEY_EVT *k) |
||
47 | { |
||
48 | cprintf("Ctrl-Brk pressed! Ending...\n"); |
||
49 | sys_end(); |
||
50 | } |
||
51 | |||
52 | void my_close(void *arg) |
||
53 | { |
||
54 | int i; |
||
55 | TIME tmp; |
||
56 | |||
57 | kern_printf("Taskset Execution Time\n\n"); |
||
58 | for (i=3; i<MAX_PROC; i++){ |
||
59 | if (!jet_getstat(i, NULL, &tmp, NULL, NULL)) |
||
60 | kern_printf("Task Name : %s - Max Time : %d\n", proc_table[i].name, (int)tmp); |
||
61 | } |
||
62 | } |
||
63 | |||
64 | |||
65 | TASK write() |
||
66 | { |
||
67 | JOY_STATE jsa; |
||
68 | |||
69 | while (1) { |
||
70 | get_joystick_A(&jsa); |
||
71 | place(2,4); |
||
72 | cprintf("The X coord. is: %3d and the Y coord. is: %3d of the joystick1\n", jsa.x, jsa.y); |
||
73 | place(2,12); |
||
74 | cprintf("The button 1, joystick 1 is: %3d\n", jsa.b1); |
||
75 | place(2,14); |
||
76 | cprintf("The button 2, joystick 1 is: %3d\n", jsa.b2); |
||
77 | |||
78 | task_endcycle(); |
||
79 | } |
||
80 | return 0; |
||
81 | } |
||
82 | |||
83 | int main(int argc, char **argv) |
||
84 | { |
||
85 | SOFT_TASK_MODEL ms; |
||
86 | KEY_EVT k; |
||
87 | TIME seme; |
||
88 | |||
89 | JOY_BOUND jb; |
||
90 | |||
91 | k.flag = CNTR_BIT; |
||
92 | k.scan = KEY_C; |
||
93 | k.ascii = 'c'; |
||
94 | keyb_hook(k,endfun); |
||
95 | |||
96 | k.flag = CNTL_BIT; |
||
97 | k.scan = KEY_C; |
||
98 | k.ascii = 'c'; |
||
99 | keyb_hook(k,endfun); |
||
100 | |||
101 | seme = sys_gettime(NULL); |
||
102 | srand(seme); |
||
103 | |||
104 | sys_atrunlevel(my_close, NULL, RUNLEVEL_BEFORE_EXIT); |
||
105 | |||
106 | clear(); |
||
107 | |||
108 | if (get_joystick_bound_A(&jb)) { |
||
109 | perror("Could not find Joystick."); |
||
110 | sys_end(); |
||
111 | } |
||
112 | |||
113 | place(2,2); |
||
114 | cprintf("The X bounds are: [ %3d - %3d ] and the Y bounds are: [ %3d - %3d ]\n", jb.x_min,jb.x_max,jb.y_min,jb.y_max); |
||
115 | |||
116 | soft_task_default_model(ms); |
||
117 | soft_task_def_level(ms,1); |
||
118 | soft_task_def_ctrl_jet(ms); |
||
119 | soft_task_def_met(ms,100); |
||
120 | soft_task_def_period(ms,10000); |
||
121 | soft_task_def_usemath(ms); |
||
122 | pid = task_create("Write", write, &ms, NULL); |
||
123 | if (pid == NIL) { |
||
124 | perror("Could not create task <Write>"); |
||
125 | sys_end(); |
||
126 | } else { |
||
127 | task_activate(pid); |
||
128 | } |
||
129 | |||
130 | return 0; |
||
131 | } |