add speed + a lot of refactoring
This commit is contained in:
@@ -49,7 +49,7 @@ static parameters G = {
|
||||
|
||||
static FILE *fcoords = NULL;
|
||||
|
||||
static coords_t M;
|
||||
static coordval_pair_t M;
|
||||
|
||||
static sl_option_t cmdlnopts[] = {
|
||||
{"help", NO_ARGS, NULL, 'h', arg_int, APTR(&G.help), "show this help"},
|
||||
@@ -92,8 +92,8 @@ static int Wait(double tag){
|
||||
errcnt = 0;
|
||||
if(mdata.millis == millis) continue;
|
||||
millis = mdata.millis;
|
||||
if(*G.axis == 'X') curpos = mdata.motposition.X;
|
||||
else curpos = mdata.motposition.Y;
|
||||
if(*G.axis == 'X') curpos = mdata.motXposition.val;
|
||||
else curpos = mdata.motYposition.val;
|
||||
if(sign == 0.) sign = (curpos > tag) ? 1. : -1.;
|
||||
//printf("%s=%g deg, need %g deg; delta=%g arcmin\n", G.axis, RAD2DEG(curpos),
|
||||
// RAD2DEG(tag), RAD2DEG(sign*(curpos - tag))*60.);
|
||||
@@ -110,22 +110,20 @@ static int Wait(double tag){
|
||||
|
||||
// move X/Y to 40 degr with given speed until given coord
|
||||
static void move(double target, double limit, double speed){
|
||||
#define SCMD() do{if(MCC_E_OK != Mount.shortCmd(&cmd)) ERRX("Can't run command"); }while(0)
|
||||
green("Move %s to %g until %g with %gdeg/s\n", G.axis, target, limit, speed);
|
||||
short_command_t cmd = {0};
|
||||
if(*G.axis == 'X' || *G.axis == 'B'){
|
||||
cmd.Xmot = DEG2RAD(target) + M.X;
|
||||
cmd.Xmot = DEG2RAD(target) + M.X.val;
|
||||
cmd.Xspeed = DEG2RAD(speed);
|
||||
limit = DEG2RAD(limit) + M.X;
|
||||
limit = DEG2RAD(limit) + M.X.val;
|
||||
}
|
||||
if(*G.axis == 'Y' || *G.axis == 'B'){
|
||||
cmd.Ymot = DEG2RAD(target) + M.Y;
|
||||
cmd.Ymot = DEG2RAD(target) + M.Y.val;
|
||||
cmd.Yspeed = DEG2RAD(speed);
|
||||
if(*G.axis != 'B') limit = DEG2RAD(limit) + M.Y;
|
||||
if(*G.axis != 'B') limit = DEG2RAD(limit) + M.Y.val;
|
||||
}
|
||||
SCMD();
|
||||
if(MCC_E_OK != Mount.shortCmd(&cmd)) ERRX("Can't run command");
|
||||
if(!Wait(limit)) signals(9);
|
||||
#undef SCMD
|
||||
}
|
||||
|
||||
|
||||
@@ -169,11 +167,10 @@ int main(int argc, char **argv){
|
||||
move(10., 3., 15./60.);
|
||||
// and go back with 7deg/s
|
||||
move(0., 0., 7.);
|
||||
// be sure to move @ 0,0
|
||||
Mount.moveTo(&M.X, &M.Y);
|
||||
// be sure to move @ starting position
|
||||
Mount.moveTo(&M.X.val, &M.Y.val);
|
||||
// wait moving ends
|
||||
pthread_join(dthr, NULL);
|
||||
#undef SCMD
|
||||
signals(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user