Rev 1624 |
Go to most recent revision |
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';
keyb_hook(k,pad);
k.flag = 0;
k.scan = KEY_2;
k.ascii = '2';
keyb_hook(k,pad);
k.flag = 0;
k.scan = KEY_3;
k.ascii = '3';
keyb_hook(k,pad);
k.flag = 0;
k.scan = KEY_4;
k.ascii = '4';
keyb_hook(k,pad);
k.flag = 0;
k.scan = KEY_5;
k.ascii = '5';
keyb_hook(k,pad);
k.flag = 0;
k.scan = KEY_6;
k.ascii = '6';
keyb_hook(k,pad);
k.flag = 0;
k.scan = KEY_J;
k.ascii = 'j';
keyb_hook(k,pad);
k.flag = 0;
k.scan = KEY_K;
k.ascii = 'k';
keyb_hook(k,pad);
k.flag = 0;
k.scan = KEY_L;
k.ascii = 'l';
keyb_hook(k,pad);
k.flag = 0;
k.scan = KEY_U;
k.ascii = 'u';
keyb_hook(k,pad);
k.flag = 0;
k.scan = KEY_I;
k.ascii = 'i';
keyb_hook(k,pad);
k.flag = 0;
k.scan = KEY_O;
k.ascii = 'o';
keyb_hook(k,pad);
k.flag = 0;
k.scan = KEY_Q;
k.ascii = 'q';
keyb_hook(k,pad);
k.flag = 0;
k.scan = KEY_W;
k.ascii = 'w';
keyb_hook(k,pad);
k.flag = 0;
k.scan = KEY_E;
k.ascii = 'e';
keyb_hook(k,pad);
k.flag = 0;
k.scan = KEY_Z;
k.ascii = 'z';
keyb_hook(k,pad);
k.flag = 0;
k.scan = KEY_C;
k.ascii = 'c';
keyb_hook(k,pad);
k.flag = 0;
k.scan = KEY_A;
k.ascii = 'a';
keyb_hook(k,pad);
k.flag = 0;
k.scan = KEY_S;
k.ascii = 's';
keyb_hook(k,pad);
k.flag = 0;
k.scan = KEY_D;
k.ascii = 'd';
keyb_hook(k,pad);
k.flag = 0;
k.scan = KEY_F;
k.ascii = 'f';
keyb_hook(k,pad);
k.flag = 0;
k.scan = KEY_G;
k.ascii = 'g';
keyb_hook(k,pad);
k.flag = 0;
k.scan = KEY_H;
k.ascii = 'h';
keyb_hook(k,pad);
}