Hi, I am studying the code of the hexapod and I have some doubts.
which, in the following parts of the code.
The code is in "c ", but I think you can understand.
There are 3 parts of code.
[code]********************************************************************************************
if (bit_test(DualShock[1],5) == 0 & bit_test(LastButton[0],5)){ //Right Button test
if (RegNo<31)
RegNo++;
}
And here?:
if (bit_test(DualShock[2],6) == 0 & bit_test(LastButton[1],6)){ //X Button test
if (SetupMode == 0){
SetupMode = 1;
generate_tone(2000,100);
generate_tone(10000,100);
}
else{
SetupMode = 0;
generate_tone(8000,250);
}
}
and this function is used to?:
//Setup
void Setup(void){
char Res[5];
short Neg;
int Val,Val1,Val2,Val3,I,c,d;
RegNo=32;
//while(){
for (RegNo=0;RegNo<=31;RegNo++){
d=0;
for(c=0;c<=4;c++){
Res[c]=’.’;
}
printf(“R%u%c”,(RegNo+32),13);
Neg=0;
for(c=0;c<=4;c++){
Res[c]=getch();
if((Res[c]==’-’)&(c==0)){
Neg=1;
}
if(Res[c]==13){
break;
}
}
Val1=255;
Val2=255;
Val3=255;
d=c-1;
for(i=0;i<=d;i++){
if(Neg&i==0){
continue;
}
switch(Res*){
case ‘0’:Val=0;
break;
case ‘1’:Val=1;
break;
case ‘2’:Val=2;
break;
case ‘3’:Val=3;
break;
case ‘4’:Val=4;
break;
case ‘5’:Val=5;
break;
case ‘6’:Val=6;
break;
case ‘7’:Val=7;
break;
case ‘8’:Val=8;
break;
case ‘9’:Val=9;
break;
}
//printf(“Val=%d%c”,Val,13);
if(Neg){
switch(I){
case 1:Val1=Val;
break;
case 2:Val2=Val;
break;
case 3:Val3=Val;
break;
}
}
else{
switch(I){
case 0:Val1=Val;
break;
case 1:Val2=Val;
break;
case 2:Val3=Val;
break;
}
}
}
//printf(“Val1=%u Val2=%u Val3=%u%c”,Val1,Val2,Val3,13);
if(Val2==255&Val3==255){
ValReg[RegNo]=(signed int)Val1;
}
else{
if(Val3==255)
ValReg[RegNo]=(signed int)(Val110+Val2);
else
ValReg[RegNo]=(signed int)(Val1100+Val2*10+Val3);
}
if(Neg){
ValReg[RegNo]=ValReg[RegNo]*-1;
}
printf("ValReg%u]=%d%c",(RegNo+32),ValReg[RegNo],13);
//delay_ms(10);
}
//return;
RegNo=0;
while (SetupMode){
Ps2Input();
printf("#%u PO %d%c",RegNo,ValReg[RegNo],13);
printf("R%u = %d%c",(RegNo+32),ValReg[RegNo],13);
delay_ms(100);
}
}
[/code]
thanks for the help
MA_BLACK*