This commit is contained in:
2025-02-24 22:23:52 +03:00
parent 5e3cc5b31a
commit f83f95c9cc
12 changed files with 186 additions and 61 deletions

View File

@@ -31,6 +31,7 @@ typedef struct{
int help;
int Ncycles;
int wait;
int relative;
char *coordsoutput;
double X;
double Y;
@@ -49,6 +50,7 @@ static sl_option_t cmdlnopts[] = {
{"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"},
{"relative", NO_ARGS, NULL, 'r', arg_int, APTR(&G.relative), "relative move"},
end_option
};
@@ -100,10 +102,22 @@ int main(int _U_ argc, char _U_ **argv){
}
printf("Mount position: X=%g, Y=%g\n", RAD2DEG(M.X), RAD2DEG(M.Y));
if(isnan(G.X) && isnan(G.Y)) goto out;
if(isnan(G.X)) G.X = RAD2DEG(M.X);
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));
double *xtag = NULL, *ytag = NULL, xr, yr;
if(!isnan(G.X)){
xr = DEG2RAD(G.X);
if(G.relative) xr += M.X;
xtag = &xr;
}
if(!isnan(G.Y)){
yr = DEG2RAD(G.Y);
if(G.relative) yr += M.Y;
ytag = &yr;
}
printf("Moving to ");
if(xtag) printf("X=%gdeg ", G.X);
if(ytag) printf("Y=%gdeg", G.Y);
printf("\n");
Mount.moveTo(xtag, ytag);
if(G.wait){
sleep(1);
waitmoving(G.Ncycles);