add dumpswing, fix bug with uint32 instead of int32

This commit is contained in:
2025-02-19 23:07:26 +03:00
parent 1195393fa8
commit 357a0d7e19
10 changed files with 207 additions and 23 deletions

View File

@@ -30,6 +30,7 @@
typedef struct{
int help;
int Ncycles;
int wait;
char *coordsoutput;
double X;
double Y;
@@ -47,6 +48,7 @@ static sl_option_t cmdlnopts[] = {
{"newx", NEED_ARG, NULL, 'X', arg_double, APTR(&G.X), "new X coordinate"},
{"newy", NEED_ARG, NULL, 'Y', arg_double, APTR(&G.Y), "new Y coordinate"},
{"output", NEED_ARG, NULL, 'o', arg_string, APTR(&G.coordsoutput),"file to log coordinates"},
{"wait", NO_ARGS, NULL, 'w', arg_int, APTR(&G.wait), "wait until mowing stopped"},
end_option
};
@@ -86,6 +88,10 @@ int main(int _U_ argc, char _U_ **argv){
if(MCC_E_OK != Mount.init(&Config)) ERRX("Can't init mount");
coords_t M;
if(!getPos(&M, NULL)) ERRX("Can't get current position");
if(G.coordsoutput){
if(!G.wait) green("When logging I should wait until moving ends; added '-w'");
G.wait = 1;
}
if(G.coordsoutput){
if(!(fcoords = fopen(G.coordsoutput, "w")))
ERRX("Can't open %s", G.coordsoutput);
@@ -98,12 +104,14 @@ int main(int _U_ argc, char _U_ **argv){
if(isnan(G.Y)) G.Y = RAD2DEG(M.Y);
printf("Moving to X=%g deg, Y=%g deg\n", G.X, G.Y);
Mount.moveTo(DEG2RAD(G.X), DEG2RAD(G.Y));
sleep(1);
waitmoving(G.Ncycles);
if(!getPos(&M, NULL)) WARNX("Can't get current position");
else printf("New mount position: X=%g, Y=%g\n", RAD2DEG(M.X), RAD2DEG(M.Y));
if(G.wait){
sleep(1);
waitmoving(G.Ncycles);
if(!getPos(&M, NULL)) WARNX("Can't get current position");
else printf("New mount position: X=%g, Y=%g\n", RAD2DEG(M.X), RAD2DEG(M.Y));
}
out:
if(G.coordsoutput) pthread_join(dthr, NULL);
Mount.quit();
if(G.wait) Mount.quit();
return 0;
}