nano_stepper icon indicating copy to clipboard operation
nano_stepper copied to clipboard

setpos to negative number error

Open brianmichalk1 opened this issue 1 year ago • 0 comments

If a setpos command is issued with a negative value, a resulting readpos value will be the abs() of the negative.

move -124.00 400
:>
 deg
:>
readpos
encoder -124.10
:>
setpos -10
:>
readpos
encoder 10.08

The current implementation:

static int setpos_cmd(sCmdUart *ptrUart,int argc, char * argv[])
{
	if (argc>=1)
	{
		int64_t a;
		float x;
		x=fabs(atof(argv[0]));
		a=ANGLE_FROM_DEGREES(x);
		stepperCtrl.setAngle(a);
		return 0;
	}
	return 1;
}

Is there a reason why the fabs() is used?

brianmichalk1 avatar Apr 18 '23 21:04 brianmichalk1