Subversion Repositories shark

Rev

Rev 1332 | Rev 1334 | Go to most recent revision | 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
/* Manual step increment */
39
#define INC_LEG         2
40
 
41
unsigned char   active_leg;
42
 
43
void pad(KEY_EVT *k)
44
{
45
        switch (k->scan) {
46
                case KEY_Z:
47
                        //sem_wait(&mx_status);
48
                        status.power ^= 1;
49
                        //sem_post(&mx_status);
50
                        break;
51
 
52
                case KEY_Q:
53
                        //sem_wait(&mx_status);
54
                        status.leg[active_leg].pwm ^= 0x1;
55
                        //sem_post(&mx_status);
56
                        break;
57
                case KEY_W:
58
                        //sem_wait(&mx_status);
59
                        status.leg[active_leg].pwm ^= 0x2;
60
                        //sem_post(&mx_status);
61
                        break;
62
                case KEY_E:
63
                        //sem_wait(&mx_status);
64
                        status.leg[active_leg].pwm ^= 0x4;
65
                        //sem_post(&mx_status);
66
                        break;
67
 
68
                case KEY_U:
69
                        //sem_wait(&mx_status);
70
                        status.leg[active_leg].x += INC_LEG;
71
                        if (status.leg[active_leg].x > POS_X_MAX) status.leg[active_leg].x = POS_X_MAX;
72
                        //sem_post(&mx_status);
73
                        break;
74
                case KEY_J:
75
                        //sem_wait(&mx_status);
76
                        status.leg[active_leg].x -= INC_LEG;
77
                        if (status.leg[active_leg].x < POS_X_MIN) status.leg[active_leg].x = POS_X_MIN;
78
                        //sem_post(&mx_status);
79
                        break;
80
                case KEY_I:
81
                        //sem_wait(&mx_status);
82
                        status.leg[active_leg].y += INC_LEG;
83
                        if (status.leg[active_leg].y > POS_Y_MAX) status.leg[active_leg].y = POS_Y_MAX;
84
                        //sem_post(&mx_status);
85
                        break;
86
                case KEY_K:
87
                        //sem_wait(&mx_status);
88
                        status.leg[active_leg].y -= INC_LEG;
89
                        if (status.leg[active_leg].y < POS_Y_MIN) status.leg[active_leg].y = POS_Y_MIN;
90
                        //sem_post(&mx_status);
91
                        break;
92
                case KEY_O:
93
                        //sem_wait(&mx_status);
94
                        status.leg[active_leg].z += INC_LEG;
95
                        if (status.leg[active_leg].z > POS_Z_MAX) status.leg[active_leg].z = POS_Z_MAX;
96
                        //sem_post(&mx_status);
97
                        break;
98
                case KEY_L:
99
                        //sem_wait(&mx_status);
100
                        status.leg[active_leg].z -= INC_LEG;
101
                        if (status.leg[active_leg].z < POS_Z_MIN) status.leg[active_leg].z = POS_Z_MIN;
102
                        //sem_post(&mx_status);
103
                        break;
104
 
105
                case KEY_1:
106
                        active_leg = 0;
107
                        break;
108
                case KEY_2:
109
                        active_leg = 1;
110
                        break;
111
                case KEY_3:
112
                        active_leg = 2;
113
                        break;
114
                case KEY_4:
115
                        active_leg = 3;
116
                        break;
117
                case KEY_5:
118
                        active_leg = 4;
119
                        break;
120
                case KEY_6:
1332 giacomo 121
                        //active_leg = 5;
122
                        calibrate_step(100000);
1331 giacomo 123
                        break;
1332 giacomo 124
/*
125
                case KEY_C:
126
                        calibrate_init();
127
                        break;
128
 
129
                case KEY_A:
1333 giacomo 130
                        calibrate_step(-108000);
1332 giacomo 131
                        break;
132
                case KEY_S:
1333 giacomo 133
                        calibrate_step(-3600);
1332 giacomo 134
                        break;
135
                case KEY_D:
1333 giacomo 136
                        calibrate_step(-60);
1332 giacomo 137
                        break;
138
                case KEY_F:
1333 giacomo 139
                        calibrate_step(+60);
1332 giacomo 140
                        break;
141
                case KEY_G:
1333 giacomo 142
                        calibrate_step(+3600);
1332 giacomo 143
                        break;
144
                case KEY_H:
1333 giacomo 145
                        calibrate_step(+108000);
1332 giacomo 146
                        break;
147
*/
1331 giacomo 148
        }
149
}
150
 
151
void init_key()
152
{
153
        KEY_EVT k;
154
 
155
        /* Leg Selector */
156
        k.flag = 0;
157
        k.scan = KEY_1;
158
        k.ascii = '1';
159
        keyb_hook(k,pad);
160
 
161
        k.flag = 0;
162
        k.scan = KEY_2;
163
        k.ascii = '2';
164
        keyb_hook(k,pad);
165
 
166
        k.flag = 0;
167
        k.scan = KEY_3;
168
        k.ascii = '3';
169
        keyb_hook(k,pad);
170
 
171
        k.flag = 0;
172
        k.scan = KEY_4;
173
        k.ascii = '4';
174
        keyb_hook(k,pad);
175
 
176
        k.flag = 0;
177
        k.scan = KEY_5;
178
        k.ascii = '5';
179
        keyb_hook(k,pad);
180
 
181
        k.flag = 0;
182
        k.scan = KEY_6;
183
        k.ascii = '6';
184
        keyb_hook(k,pad);
185
 
186
        /* Leg Position */
187
        k.flag = 0;
188
        k.scan = KEY_J;
189
        k.ascii = 'j';
190
        keyb_hook(k,pad);
191
 
192
        k.flag = 0;
193
        k.scan = KEY_K;
194
        k.ascii = 'k';
195
        keyb_hook(k,pad);
196
 
197
        k.flag = 0;
198
        k.scan = KEY_L;
199
        k.ascii = 'l';
200
        keyb_hook(k,pad);
201
 
202
        k.flag = 0;
203
        k.scan = KEY_U;
204
        k.ascii = 'u';
205
        keyb_hook(k,pad);
206
 
207
        k.flag = 0;
208
        k.scan = KEY_I;
209
        k.ascii = 'i';
210
        keyb_hook(k,pad);
211
 
212
        k.flag = 0;
213
        k.scan = KEY_O;
214
        k.ascii = 'o';
215
        keyb_hook(k,pad);
216
 
217
        k.flag = 0;
218
        k.scan = KEY_Q;
1332 giacomo 219
        k.ascii = 'q';
1331 giacomo 220
        keyb_hook(k,pad);
221
 
222
        k.flag = 0;
223
        k.scan = KEY_W;
1332 giacomo 224
        k.ascii = 'w';
1331 giacomo 225
        keyb_hook(k,pad);
226
 
227
        k.flag = 0;
228
        k.scan = KEY_E;
1332 giacomo 229
        k.ascii = 'e';
1331 giacomo 230
        keyb_hook(k,pad);
231
 
232
        k.flag = 0;
233
        k.scan = KEY_Z;
1332 giacomo 234
        k.ascii = 'z';
1331 giacomo 235
        keyb_hook(k,pad);
1332 giacomo 236
 
237
 
238
        k.flag = 0;
239
        k.scan = KEY_C;
240
        k.ascii = 'c';
241
        keyb_hook(k,pad);
242
 
243
        k.flag = 0;
244
        k.scan = KEY_A;
245
        k.ascii = 'a';
246
        keyb_hook(k,pad);
247
 
248
        k.flag = 0;
249
        k.scan = KEY_S;
250
        k.ascii = 's';
251
        keyb_hook(k,pad);
252
 
253
        k.flag = 0;
254
        k.scan = KEY_D;
255
        k.ascii = 'd';
256
        keyb_hook(k,pad);
257
 
258
        k.flag = 0;
259
        k.scan = KEY_F;
260
        k.ascii = 'f';
261
        keyb_hook(k,pad);
262
 
263
        k.flag = 0;
264
        k.scan = KEY_G;
265
        k.ascii = 'g';
266
        keyb_hook(k,pad);
267
 
268
        k.flag = 0;
269
        k.scan = KEY_H;
270
        k.ascii = 'h';
271
        keyb_hook(k,pad);
272
 
1331 giacomo 273
}