Scaling of Analogue inputs

just a thought.

To me it would be nice if you could have the option of having the analogue (where appropriate) and joystick inputs could scaled to the range 0.0f-1.0f or -1.0f-1.0f (where appropriate).
actually while we’re at it, allowing the motor power to be specified as -1.0 to +1.0 too.

To me that make things less device dependent and is generally the way all the libraries I’ve written address devices. It would also make the code more portable should a new controller want to change the resolution of sensors or motor control.

It also means you don’t have to remember if your reading from a 12bit or 8 bit sensor etc and makes scaling them for your own needs easier, just multiply the normalized value by whatever range you want.

It would also be nice to have to have to option of getting the gyro output in radians as that matches the input of ‘standard’ C trig functions.

just some thoughts.

This is something that can be done with a float variable and a little bit of math. For instance, to scale the joystick values to a 0 to +1.0 value range:

task main()
	float values = 0.0;

	while (true)
		values = vexRT[Ch3];
		values = ((values + 127) /255);
		writeDebugStreamLine("%1.3f", values);

To modify this for a -1.0 to 0 range, all you would need to do is replace the ‘values + 127’ with ‘values - 127’; this will scale it to the negative 1 value. You could also put this in a simple function to call whenever the scaling is needed.