Rev 1335 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1331 | 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 "chimera.h" |
||
37 | |||
38 | unsigned char active_leg; |
||
39 | |||
1336 | giacomo | 40 | extern volatile int calibrate_status; |
41 | |||
1331 | giacomo | 42 | void pad(KEY_EVT *k) |
43 | { |
||
44 | switch (k->scan) { |
||
45 | case KEY_Z: |
||
46 | //sem_wait(&mx_status); |
||
47 | status.power ^= 1; |
||
48 | //sem_post(&mx_status); |
||
49 | break; |
||
50 | |||
51 | case KEY_Q: |
||
52 | //sem_wait(&mx_status); |
||
1334 | giacomo | 53 | status.cfg[active_leg].pwm ^= 0x1; |
1331 | giacomo | 54 | //sem_post(&mx_status); |
55 | break; |
||
56 | case KEY_W: |
||
57 | //sem_wait(&mx_status); |
||
1334 | giacomo | 58 | status.cfg[active_leg].pwm ^= 0x2; |
1331 | giacomo | 59 | //sem_post(&mx_status); |
60 | break; |
||
61 | case KEY_E: |
||
62 | //sem_wait(&mx_status); |
||
1334 | giacomo | 63 | status.cfg[active_leg].pwm ^= 0x4; |
1331 | giacomo | 64 | //sem_post(&mx_status); |
65 | break; |
||
66 | |||
67 | case KEY_2: |
||
68 | active_leg = 1; |
||
69 | break; |
||
70 | case KEY_3: |
||
71 | active_leg = 2; |
||
72 | break; |
||
73 | case KEY_4: |
||
74 | active_leg = 3; |
||
75 | break; |
||
76 | case KEY_5: |
||
77 | active_leg = 4; |
||
78 | break; |
||
79 | case KEY_6: |
||
1335 | giacomo | 80 | active_leg = 5; |
1331 | giacomo | 81 | break; |
1336 | giacomo | 82 | |
1332 | giacomo | 83 | case KEY_C: |
84 | calibrate_init(); |
||
1336 | giacomo | 85 | if (calibrate_init != 0) calibrate_step(100000); |
1332 | giacomo | 86 | break; |
87 | |||
88 | case KEY_A: |
||
1333 | giacomo | 89 | calibrate_step(-108000); |
1332 | giacomo | 90 | break; |
91 | case KEY_S: |
||
1333 | giacomo | 92 | calibrate_step(-3600); |
1332 | giacomo | 93 | break; |
94 | case KEY_D: |
||
1333 | giacomo | 95 | calibrate_step(-60); |
1332 | giacomo | 96 | break; |
97 | case KEY_F: |
||
1333 | giacomo | 98 | calibrate_step(+60); |
1332 | giacomo | 99 | break; |
100 | case KEY_G: |
||
1333 | giacomo | 101 | calibrate_step(+3600); |
1332 | giacomo | 102 | break; |
103 | case KEY_H: |
||
1333 | giacomo | 104 | calibrate_step(+108000); |
1332 | giacomo | 105 | break; |
1331 | giacomo | 106 | } |
107 | } |
||
108 | |||
109 | void init_key() |
||
110 | { |
||
111 | KEY_EVT k; |
||
112 | |||
113 | /* Leg Selector */ |
||
114 | k.flag = 0; |
||
115 | k.scan = KEY_1; |
||
116 | k.ascii = '1'; |
||
117 | keyb_hook(k,pad); |
||
118 | |||
119 | k.flag = 0; |
||
120 | k.scan = KEY_2; |
||
121 | k.ascii = '2'; |
||
122 | keyb_hook(k,pad); |
||
123 | |||
124 | k.flag = 0; |
||
125 | k.scan = KEY_3; |
||
126 | k.ascii = '3'; |
||
127 | keyb_hook(k,pad); |
||
128 | |||
129 | k.flag = 0; |
||
130 | k.scan = KEY_4; |
||
131 | k.ascii = '4'; |
||
132 | keyb_hook(k,pad); |
||
133 | |||
134 | k.flag = 0; |
||
135 | k.scan = KEY_5; |
||
136 | k.ascii = '5'; |
||
137 | keyb_hook(k,pad); |
||
138 | |||
139 | k.flag = 0; |
||
140 | k.scan = KEY_6; |
||
141 | k.ascii = '6'; |
||
142 | keyb_hook(k,pad); |
||
143 | |||
144 | /* Leg Position */ |
||
145 | k.flag = 0; |
||
146 | k.scan = KEY_J; |
||
147 | k.ascii = 'j'; |
||
148 | keyb_hook(k,pad); |
||
149 | |||
150 | k.flag = 0; |
||
151 | k.scan = KEY_K; |
||
152 | k.ascii = 'k'; |
||
153 | keyb_hook(k,pad); |
||
154 | |||
155 | k.flag = 0; |
||
156 | k.scan = KEY_L; |
||
157 | k.ascii = 'l'; |
||
158 | keyb_hook(k,pad); |
||
159 | |||
160 | k.flag = 0; |
||
161 | k.scan = KEY_U; |
||
162 | k.ascii = 'u'; |
||
163 | keyb_hook(k,pad); |
||
164 | |||
165 | k.flag = 0; |
||
166 | k.scan = KEY_I; |
||
167 | k.ascii = 'i'; |
||
168 | keyb_hook(k,pad); |
||
169 | |||
170 | k.flag = 0; |
||
171 | k.scan = KEY_O; |
||
172 | k.ascii = 'o'; |
||
173 | keyb_hook(k,pad); |
||
174 | |||
175 | k.flag = 0; |
||
176 | k.scan = KEY_Q; |
||
1332 | giacomo | 177 | k.ascii = 'q'; |
1331 | giacomo | 178 | keyb_hook(k,pad); |
179 | |||
180 | k.flag = 0; |
||
181 | k.scan = KEY_W; |
||
1332 | giacomo | 182 | k.ascii = 'w'; |
1331 | giacomo | 183 | keyb_hook(k,pad); |
184 | |||
185 | k.flag = 0; |
||
186 | k.scan = KEY_E; |
||
1332 | giacomo | 187 | k.ascii = 'e'; |
1331 | giacomo | 188 | keyb_hook(k,pad); |
189 | |||
190 | k.flag = 0; |
||
191 | k.scan = KEY_Z; |
||
1332 | giacomo | 192 | k.ascii = 'z'; |
1331 | giacomo | 193 | keyb_hook(k,pad); |
1332 | giacomo | 194 | |
195 | |||
196 | k.flag = 0; |
||
197 | k.scan = KEY_C; |
||
198 | k.ascii = 'c'; |
||
199 | keyb_hook(k,pad); |
||
200 | |||
201 | k.flag = 0; |
||
202 | k.scan = KEY_A; |
||
203 | k.ascii = 'a'; |
||
204 | keyb_hook(k,pad); |
||
205 | |||
206 | k.flag = 0; |
||
207 | k.scan = KEY_S; |
||
208 | k.ascii = 's'; |
||
209 | keyb_hook(k,pad); |
||
210 | |||
211 | k.flag = 0; |
||
212 | k.scan = KEY_D; |
||
213 | k.ascii = 'd'; |
||
214 | keyb_hook(k,pad); |
||
215 | |||
216 | k.flag = 0; |
||
217 | k.scan = KEY_F; |
||
218 | k.ascii = 'f'; |
||
219 | keyb_hook(k,pad); |
||
220 | |||
221 | k.flag = 0; |
||
222 | k.scan = KEY_G; |
||
223 | k.ascii = 'g'; |
||
224 | keyb_hook(k,pad); |
||
225 | |||
226 | k.flag = 0; |
||
227 | k.scan = KEY_H; |
||
228 | k.ascii = 'h'; |
||
229 | keyb_hook(k,pad); |
||
230 | |||
1331 | giacomo | 231 | } |