#include #include #include #include #include #include #include #include #include #include #include int servo_power[NUM_SERVOS]; int main(int argc, char **argv) { int fd; int i,j,l,s; int frame; uint32_t time; char c; uint16_t pwm; struct termios t; int step=1; printf("welcome.\n"); spi_open(0,33000000); for(i=0;i "); } else { printf(" > "); } } else { if(servo_power[i]) { printf("! "); } else { printf(" "); } } } printf("%04x (%d) ",servo_offsets[i],servo_offsets[i]); } printf("\n\nazsxdc: move servo\n+-: select leg(%d)\n[]: increase/decrease step size (%d)\np: power on/off leg\n12: save min/max value\nw: dump\nf: save to calibration.bin\nq: quit\n> ",l,step); c=getchar(); printf("%c (%02x)\n",c,c); switch(c) { case 'a': servo_offsets[l*3]+=step; break; case 'z': servo_offsets[l*3]-=step; break; case 's': servo_offsets[l*3+1]+=step; break; case 'x': servo_offsets[l*3+1]-=step; break; case 'd': servo_offsets[l*3+2]+=step; break; case 'c': servo_offsets[l*3+2]-=step; break; case '+': if((l+1)0) l--; break; case '[': if(step>=10) step/=10; break; case ']': step*=10; break; case 'w': printf("/* Servo current values */\n\nuint16_t servo_base[]= {"); for(i=0;i