Rev 1625 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1624 | giacomo | 1 | /* |
2 | * Project: S.Ha.R.K. |
||
3 | * |
||
4 | * Coordinators: Giorgio Buttazzo <giorgio@sssup.it> |
||
5 | * |
||
6 | * |
||
7 | * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
||
8 | * |
||
9 | * http://www.sssup.it |
||
10 | * http://retis.sssup.it |
||
11 | * http://shark.sssup.it |
||
12 | */ |
||
13 | |||
14 | #include "chimera.h" |
||
15 | |||
16 | unsigned char active_leg; |
||
17 | |||
18 | extern volatile int calibrate_status; |
||
19 | |||
20 | void pad(KEY_EVT *k) |
||
21 | { |
||
22 | switch (k->scan) { |
||
23 | case KEY_Z: |
||
24 | status.power ^= 1; |
||
25 | break; |
||
26 | |||
27 | case KEY_Q: |
||
28 | status.cfg[active_leg].pwm ^= 0x1; |
||
29 | break; |
||
30 | case KEY_W: |
||
31 | status.cfg[active_leg].pwm ^= 0x2; |
||
32 | break; |
||
33 | case KEY_E: |
||
34 | status.cfg[active_leg].pwm ^= 0x4; |
||
35 | break; |
||
36 | case KEY_1: |
||
37 | active_leg = 0; |
||
38 | break; |
||
39 | case KEY_2: |
||
40 | active_leg = 1; |
||
41 | break; |
||
42 | case KEY_3: |
||
43 | active_leg = 2; |
||
44 | break; |
||
45 | case KEY_4: |
||
46 | active_leg = 3; |
||
47 | break; |
||
48 | case KEY_5: |
||
49 | active_leg = 4; |
||
50 | break; |
||
51 | case KEY_6: |
||
52 | active_leg = 5; |
||
53 | break; |
||
54 | |||
55 | case KEY_C: |
||
56 | if (calibrate_status != 0) calibrate_step(100000); |
||
57 | else calibrate_init(); |
||
58 | break; |
||
59 | |||
60 | case KEY_A: |
||
61 | calibrate_step(-108000); |
||
62 | break; |
||
63 | case KEY_S: |
||
64 | calibrate_step(-3600); |
||
65 | break; |
||
66 | case KEY_D: |
||
67 | calibrate_step(-60); |
||
68 | break; |
||
69 | case KEY_F: |
||
70 | calibrate_step(+60); |
||
71 | break; |
||
72 | case KEY_G: |
||
73 | calibrate_step(+3600); |
||
74 | break; |
||
75 | case KEY_H: |
||
76 | calibrate_step(+108000); |
||
77 | break; |
||
78 | } |
||
79 | } |
||
80 | |||
81 | void init_key() |
||
82 | { |
||
83 | KEY_EVT k; |
||
84 | |||
85 | k.flag = 0; |
||
86 | k.scan = KEY_1; |
||
87 | k.ascii = '1'; |
||
1647 | giacomo | 88 | k.status = KEY_PRESSED; |
89 | keyb_hook(k,pad,FALSE); |
||
1624 | giacomo | 90 | |
91 | k.flag = 0; |
||
92 | k.scan = KEY_2; |
||
93 | k.ascii = '2'; |
||
1647 | giacomo | 94 | k.status = KEY_PRESSED; |
95 | keyb_hook(k,pad,FALSE); |
||
1624 | giacomo | 96 | |
97 | k.flag = 0; |
||
98 | k.scan = KEY_3; |
||
99 | k.ascii = '3'; |
||
1647 | giacomo | 100 | k.status = KEY_PRESSED; |
101 | keyb_hook(k,pad,FALSE); |
||
1624 | giacomo | 102 | |
103 | k.flag = 0; |
||
104 | k.scan = KEY_4; |
||
105 | k.ascii = '4'; |
||
1647 | giacomo | 106 | k.status = KEY_PRESSED; |
107 | keyb_hook(k,pad,FALSE); |
||
1624 | giacomo | 108 | |
109 | k.flag = 0; |
||
110 | k.scan = KEY_5; |
||
111 | k.ascii = '5'; |
||
1647 | giacomo | 112 | k.status = KEY_PRESSED; |
113 | keyb_hook(k,pad,FALSE); |
||
1624 | giacomo | 114 | |
115 | k.flag = 0; |
||
116 | k.scan = KEY_6; |
||
117 | k.ascii = '6'; |
||
1647 | giacomo | 118 | k.status = KEY_PRESSED; |
119 | keyb_hook(k,pad,FALSE); |
||
1624 | giacomo | 120 | |
121 | k.flag = 0; |
||
122 | k.scan = KEY_J; |
||
123 | k.ascii = 'j'; |
||
1647 | giacomo | 124 | k.status = KEY_PRESSED; |
125 | keyb_hook(k,pad,FALSE); |
||
1624 | giacomo | 126 | |
127 | k.flag = 0; |
||
128 | k.scan = KEY_K; |
||
129 | k.ascii = 'k'; |
||
1647 | giacomo | 130 | k.status = KEY_PRESSED; |
131 | keyb_hook(k,pad,FALSE); |
||
1624 | giacomo | 132 | |
133 | k.flag = 0; |
||
134 | k.scan = KEY_L; |
||
135 | k.ascii = 'l'; |
||
1647 | giacomo | 136 | k.status = KEY_PRESSED; |
137 | keyb_hook(k,pad,FALSE); |
||
1624 | giacomo | 138 | |
139 | k.flag = 0; |
||
140 | k.scan = KEY_U; |
||
141 | k.ascii = 'u'; |
||
1647 | giacomo | 142 | k.status = KEY_PRESSED; |
143 | keyb_hook(k,pad,FALSE); |
||
1624 | giacomo | 144 | |
145 | k.flag = 0; |
||
146 | k.scan = KEY_I; |
||
147 | k.ascii = 'i'; |
||
1647 | giacomo | 148 | k.status = KEY_PRESSED; |
149 | keyb_hook(k,pad,FALSE); |
||
1624 | giacomo | 150 | |
151 | k.flag = 0; |
||
152 | k.scan = KEY_O; |
||
153 | k.ascii = 'o'; |
||
1647 | giacomo | 154 | k.status = KEY_PRESSED; |
155 | keyb_hook(k,pad,FALSE); |
||
1624 | giacomo | 156 | |
157 | k.flag = 0; |
||
158 | k.scan = KEY_Q; |
||
159 | k.ascii = 'q'; |
||
1647 | giacomo | 160 | k.status = KEY_PRESSED; |
161 | keyb_hook(k,pad,FALSE); |
||
1624 | giacomo | 162 | |
163 | k.flag = 0; |
||
164 | k.scan = KEY_W; |
||
165 | k.ascii = 'w'; |
||
1647 | giacomo | 166 | k.status = KEY_PRESSED; |
167 | keyb_hook(k,pad,FALSE); |
||
1624 | giacomo | 168 | |
169 | k.flag = 0; |
||
170 | k.scan = KEY_E; |
||
171 | k.ascii = 'e'; |
||
1647 | giacomo | 172 | k.status = KEY_PRESSED; |
173 | keyb_hook(k,pad,FALSE); |
||
1624 | giacomo | 174 | |
175 | k.flag = 0; |
||
176 | k.scan = KEY_Z; |
||
177 | k.ascii = 'z'; |
||
1647 | giacomo | 178 | k.status = KEY_PRESSED; |
179 | keyb_hook(k,pad,FALSE); |
||
1624 | giacomo | 180 | |
181 | |||
182 | k.flag = 0; |
||
183 | k.scan = KEY_C; |
||
184 | k.ascii = 'c'; |
||
1647 | giacomo | 185 | k.status = KEY_PRESSED; |
186 | keyb_hook(k,pad,FALSE); |
||
1624 | giacomo | 187 | |
188 | k.flag = 0; |
||
189 | k.scan = KEY_A; |
||
190 | k.ascii = 'a'; |
||
1647 | giacomo | 191 | k.status = KEY_PRESSED; |
192 | keyb_hook(k,pad,FALSE); |
||
1624 | giacomo | 193 | |
194 | k.flag = 0; |
||
195 | k.scan = KEY_S; |
||
196 | k.ascii = 's'; |
||
1647 | giacomo | 197 | k.status = KEY_PRESSED; |
198 | keyb_hook(k,pad,FALSE); |
||
1624 | giacomo | 199 | |
200 | k.flag = 0; |
||
201 | k.scan = KEY_D; |
||
202 | k.ascii = 'd'; |
||
1647 | giacomo | 203 | k.status = KEY_PRESSED; |
204 | keyb_hook(k,pad,FALSE); |
||
1624 | giacomo | 205 | |
206 | k.flag = 0; |
||
207 | k.scan = KEY_F; |
||
208 | k.ascii = 'f'; |
||
1647 | giacomo | 209 | k.status = KEY_PRESSED; |
210 | keyb_hook(k,pad,FALSE); |
||
1624 | giacomo | 211 | |
212 | k.flag = 0; |
||
213 | k.scan = KEY_G; |
||
214 | k.ascii = 'g'; |
||
1647 | giacomo | 215 | k.status = KEY_PRESSED; |
216 | keyb_hook(k,pad,FALSE); |
||
1624 | giacomo | 217 | |
218 | k.flag = 0; |
||
219 | k.scan = KEY_H; |
||
220 | k.ascii = 'h'; |
||
1647 | giacomo | 221 | k.status = KEY_PRESSED; |
222 | keyb_hook(k,pad,FALSE); |
||
1624 | giacomo | 223 | } |