I apologize in advance because my knowledge of EasyC functions is limited. In both cases I think you should use the FourWheelDrive() or TwoWheelDrive() functions (depending on what you are using). The you can use the Drive(int speed, int direction) function to control the robot. Keep in mind that Drive how drive works
Quote:
|
Originally Posted by WPILIB documentation
// Drive functions that are based on motor and direction values ranging from:
// -127 - +127 for full backwards to full forwards
// -127 - +127 for full right to full left turns (see Drive function)
|
Quote:
Originally Posted by Neurovirus
1. make the input and output relationship a cubic function - no clue how to do that tho i would prefer a look up table to save processing power...
|
one way to create a lookup table is to declare the table:
Code:
rom const char lookup[256] = { 0th char, ..., 255th char};
then in your Drive function:
Code:
Drive(lookup[y-axis of joystick], lookup[x-axis of joystick]);
Quote:
Originally Posted by Neurovirus
2. use a divide function when a button is held down to give control - i am confused since 127 would not be 127 and things could go wrong...i don't know how to spread out the limited output over the whole joystick axis with 127 still being 127...
|
Normal C is centered around 127, so you would have to calculate an offset to bring it back to 127 center. For example: 127/2 = 63, 127 -63 = 64, so: (new joy axis)= (old joy axis)/2 +64;
However since EasyC's Drive is centered around 0, you can just:
Code:
Drive((y-axis of joystick-127)/(factor), (x-axis of joystick-127)/(factor));
And enclose it in a if (button pressed) statement.
I hope this helps. There may be a few minor difficulties with EasyC. I am trying to learn EasyC this year for Team 1495, but I don't have my own license. I'll PM you an email address.