Rev 1625 |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
/*
* Project: S.Ha.R.K.
*
* Coordinators: Giorgio Buttazzo <giorgio@sssup.it>
*
*
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
*
* http://www.sssup.it
* http://retis.sssup.it
* http://shark.sssup.it
*/
#include "chimera.h"
unsigned char active_leg;
extern volatile int calibrate_status;
void pad(KEY_EVT *k)
{
switch (k->scan) {
case KEY_Z:
status.power ^= 1;
break;
case KEY_Q:
status.cfg[active_leg].pwm ^= 0x1;
break;
case KEY_W:
status.cfg[active_leg].pwm ^= 0x2;
break;
case KEY_E:
status.cfg[active_leg].pwm ^= 0x4;
break;
case KEY_1:
active_leg = 0;
break;
case KEY_2:
active_leg = 1;
break;
case KEY_3:
active_leg = 2;
break;
case KEY_4:
active_leg = 3;
break;
case KEY_5:
active_leg = 4;
break;
case KEY_6:
active_leg = 5;
break;
case KEY_C:
if (calibrate_status != 0) calibrate_step(100000);
else calibrate_init();
break;
case KEY_A:
calibrate_step(-108000);
break;
case KEY_S:
calibrate_step(-3600);
break;
case KEY_D:
calibrate_step(-60);
break;
case KEY_F:
calibrate_step(+60);
break;
case KEY_G:
calibrate_step(+3600);
break;
case KEY_H:
calibrate_step(+108000);
break;
}
}
void init_key()
{
KEY_EVT k;
k.flag = 0;
k.scan = KEY_1;
k.ascii = '1';
k.status = KEY_PRESSED;
keyb_hook(k,pad,FALSE);
k.flag = 0;
k.scan = KEY_2;
k.ascii = '2';
k.status = KEY_PRESSED;
keyb_hook(k,pad,FALSE);
k.flag = 0;
k.scan = KEY_3;
k.ascii = '3';
k.status = KEY_PRESSED;
keyb_hook(k,pad,FALSE);
k.flag = 0;
k.scan = KEY_4;
k.ascii = '4';
k.status = KEY_PRESSED;
keyb_hook(k,pad,FALSE);
k.flag = 0;
k.scan = KEY_5;
k.ascii = '5';
k.status = KEY_PRESSED;
keyb_hook(k,pad,FALSE);
k.flag = 0;
k.scan = KEY_6;
k.ascii = '6';
k.status = KEY_PRESSED;
keyb_hook(k,pad,FALSE);
k.flag = 0;
k.scan = KEY_J;
k.ascii = 'j';
k.status = KEY_PRESSED;
keyb_hook(k,pad,FALSE);
k.flag = 0;
k.scan = KEY_K;
k.ascii = 'k';
k.status = KEY_PRESSED;
keyb_hook(k,pad,FALSE);
k.flag = 0;
k.scan = KEY_L;
k.ascii = 'l';
k.status = KEY_PRESSED;
keyb_hook(k,pad,FALSE);
k.flag = 0;
k.scan = KEY_U;
k.ascii = 'u';
k.status = KEY_PRESSED;
keyb_hook(k,pad,FALSE);
k.flag = 0;
k.scan = KEY_I;
k.ascii = 'i';
k.status = KEY_PRESSED;
keyb_hook(k,pad,FALSE);
k.flag = 0;
k.scan = KEY_O;
k.ascii = 'o';
k.status = KEY_PRESSED;
keyb_hook(k,pad,FALSE);
k.flag = 0;
k.scan = KEY_Q;
k.ascii = 'q';
k.status = KEY_PRESSED;
keyb_hook(k,pad,FALSE);
k.flag = 0;
k.scan = KEY_W;
k.ascii = 'w';
k.status = KEY_PRESSED;
keyb_hook(k,pad,FALSE);
k.flag = 0;
k.scan = KEY_E;
k.ascii = 'e';
k.status = KEY_PRESSED;
keyb_hook(k,pad,FALSE);
k.flag = 0;
k.scan = KEY_Z;
k.ascii = 'z';
k.status = KEY_PRESSED;
keyb_hook(k,pad,FALSE);
k.flag = 0;
k.scan = KEY_C;
k.ascii = 'c';
k.status = KEY_PRESSED;
keyb_hook(k,pad,FALSE);
k.flag = 0;
k.scan = KEY_A;
k.ascii = 'a';
k.status = KEY_PRESSED;
keyb_hook(k,pad,FALSE);
k.flag = 0;
k.scan = KEY_S;
k.ascii = 's';
k.status = KEY_PRESSED;
keyb_hook(k,pad,FALSE);
k.flag = 0;
k.scan = KEY_D;
k.ascii = 'd';
k.status = KEY_PRESSED;
keyb_hook(k,pad,FALSE);
k.flag = 0;
k.scan = KEY_F;
k.ascii = 'f';
k.status = KEY_PRESSED;
keyb_hook(k,pad,FALSE);
k.flag = 0;
k.scan = KEY_G;
k.ascii = 'g';
k.status = KEY_PRESSED;
keyb_hook(k,pad,FALSE);
k.flag = 0;
k.scan = KEY_H;
k.ascii = 'h';
k.status = KEY_PRESSED;
keyb_hook(k,pad,FALSE);
}