View Full Version : Modifying Default code
great_one411
14-02-2004, 15:37
:confused: How do you modify the Default Code from one joystick to two joysticks :confused:
Mark McLeod
14-02-2004, 15:55
:confused: How do you modify the Default Code from one joystick to two joysticks :confused:[edit] Forgot the rest of the story. This goes in Default_Routine() in the user_routines.c file. Comment out the 1-Joystick lines:
//pwm13 = pwm14 = Limit_Mix(2000...
//pwm15 = pwm16 = Limit_Mix(2000...
and add in
/*------------ 2 Joystick -----------------*/
pwm13 = pwm15 = p1_y;
pwm14 = pwm16 = 254 - p2_y; // Assumes your motors are reversed, just p2_y if not
Basically what he said, just simplified. To map two joysticks, you would do something like this:
// This code assumes the joystick are on ports 1 and 2 and pwm01 and 02 are the drive motors.
// These can be easily changed
pwm01 = p1_y;
pwm02 = p2_y;
That code just makes the Y axis of the joysticks on ports 1 and 2 run the left and right drive motors.
Joe Ross
15-02-2004, 09:44
The default code already has two joystick drive on pwm01 and pwm02. You just need to change pwms. No code changes necessary.
Mark McLeod
15-02-2004, 12:44
The default code already has two joystick drive on pwm01 and pwm02. You just need to change pwms. No code changes necessary.Depends on which copy of the default code you're working with.
IFI dropped the 2-joystick code from later versions.
Joe Ross
15-02-2004, 13:00
Depends on which copy of the default code you're working with.
IFI dropped the 2-joystick code from later versions.
I know it was in the first version posted, and its also in the current version (2-10-2004). I haven't used any intermediate versions, but I find it hard to beleive that Innovation FIRST would have dropped it.
Lines 211 and 212 (in Default_Routine) pwm01 = p1_y;
pwm02 = p2_y;
The default code already has two joystick drive on pwm01 and pwm02. You just need to change pwms. No code changes necessary.I just thought the example without all the extra stuff would be helpful. :)
Mark McLeod
16-02-2004, 10:32
I know it was in the first version posted, and its also in the current version (2-10-2004). I haven't used any intermediate versions, but I find it hard to beleive that Innovation FIRST would have dropped it.
Lines 211 and 212 (in Default_Routine) pwm01 = p1_y;
pwm02 = p2_y;
I looked right past the obvious!:o
I believe at one time (maybe EDU code) they had the line:
/*---------- 2 Joystick Drive ----------------------------------------------
*-------------------------------------------------------------------------
*/
and that's what I was missing.
Thanks!
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.