Quote:
|
Originally Posted by Validius
well everybody, i have spent the last two days working painstakingly on this Perl script that generates a lookup table for C. Right now it generates the joystick position then a tab then the corresponding PWM value. It is easy to switch the output format to generate a series of array definitions for a C .h file. I am not completely familiar with the max and min values that can be sent to the PWM (255 or 254? and 0 or 1?) so the program protect against anything lower then 126 away from the center of the graph on either side.
The program defaults to having 127 be zero but all that needs to be done to change that is to set the x offset variable. The left side and right side curves can be independently controlled as well as up and down (in their position, not the function used to generate them).
The script can graph 2 functions. There is a variable ($yOuterOffset) that controls how far from the center the first function ends and the second begins. The center of the graph is determined by ($xOffset,$yOffset).
I included a .xls file of some sample data generated by the script. The other lines represent 10 and -10 (the minimum for the victors) and a line with the slope 1 to give perspective.
This is my first contribution to Open Source and i would appreciate all comments/suggestions.
I move that .pl be legit attachment extentions
I apologies for my bad spelling and such. QBasic was my first language and i am just now learning English.
|
It would be nice to see some user input instead of it all being hard-coded. Reasons being, I know Perl is an interpreted language and that its quick to execute, but on-the-fly curve changes would be very efficient. You could even go further and use another language to build a GUI that graphs the curve while you input the equation for the curve. If you need an example, I can show you a GUI written in Java that graphs equations (written by a friend) and change it so that it can fit your needs. Otherwise, the script is nice. Good job on it.
