wave switch case fix

This commit is contained in:
Lars H 2017-11-17 15:38:14 +01:00
parent cff91e23b6
commit c3783acf0d

View File

@ -281,45 +281,55 @@ void LARS::hello() {
} }
void LARS::wave(int legNumber){ void LARS::wave(int legNumber){
int amplitude[] = { 0,0,0,0,0,0,0,0};
int offsetLeg[] = { 0,0,0,0,0,0,0,0};
int T = 350; int T = 350;
switch ( legNumer) { switch ( legNumber) {
case 1 : case 1 : {
int amplitude[] = {0, 60, 0, 0, 0, 0, 0, 0}; amplitude[1] = 60;
int offset[] = { int offset[] = {
90-20 , 90-60, 90-20 , 90-60,
90 , 90+70 , 90 , 90+70 ,
90 , 90+90 , 90 , 90+90 ,
90+140 , 90 90+140 , 90
}; };
memcpy ( &offsetLeg, &offset, sizeof(offset) );
break; break;
case 2 : }
int amplitude[] = {60, 0, 0, 0, 0, 0, 0, 0}; case 2 : {
amplitude[0] = 60;
int offset[] = { int offset[] = {
90-60 , 90-20, 90-60 , 90-20,
90+70 , 90 , 90+70 , 90 ,
90 , 90+90 , 90 , 90+90 ,
90+140 , 90 90+140 , 90
}; };
memcpy ( &offsetLeg, &offset, sizeof(offset) );
break; break;
case 3 : }
int amplitude[] = {0, 0, 0, 0, 60, 0, 0, 0}; case 3 : {
amplitude[4] = 60;
int offset[] = { int offset[] = {
90-20 , 90-60, 90-20 , 90-60,
90 , 90+70 , 90 , 90+70 ,
90 , 90+90 , 90 , 90+90 ,
90+140 , 90 90+140 , 90
}; };
memcpy ( &offsetLeg, &offset, sizeof(offset) );
break; break;
case 4 : }
int amplitude[] = {0, 0, 0, 0, 0, 60, 0, 0}; case 4 : {
amplitude[5]= 60;
int offset[] = { int offset[] = {
90-20 , 90-60, 90-20 , 90-60,
90 , 90+70 , 90 , 90+70 ,
90 , 90+90 , 90 , 90+90 ,
90+140 , 90 90+140 , 90
}; };
memcpy ( &offsetLeg, &offset, sizeof(offset) );
break; break;
}
default : default :
if (debug) Serial.println("Error, leg does not exist"); if (debug) Serial.println("Error, leg does not exist");
break; break;
@ -328,7 +338,7 @@ void LARS::wave(int legNumber){
float period[] = {T, T, T, T, T, T, T, T}; float period[] = {T, T, T, T, T, T, T, T};
int phase[] = {0, 0, 0, 90, 0, 0, 0, 0}; int phase[] = {0, 0, 0, 90, 0, 0, 0, 0};
execute(3, period, amplitude, offset, phase); execute(3, period, amplitude, offsetLeg, phase);
delay (200); delay (200);
} }