Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Modifying Default code (http://www.chiefdelphi.com/forums/showthread.php?t=25290)

great_one411 14-02-2004 15:37

Modifying Default code
 
:confused: How do you modify the Default Code from one joystick to two joysticks :confused:

Mark McLeod 14-02-2004 15:55

Re: Modifying Default code
 
Quote:

Originally Posted by great_one411
: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:
Code:

//pwm13 = pwm14 = Limit_Mix(2000...
//pwm15 = pwm16 = Limit_Mix(2000...

and add in
Code:

/*------------ 2 Joystick -----------------*/
pwm13 = pwm15 = p1_y;
pwm14 = pwm16 = 254 - p2_y; // Assumes your motors are reversed, just p2_y if not


Ryan M. 15-02-2004 08:58

Re: Modifying Default code
 
Basically what he said, just simplified. To map two joysticks, you would do something like this:

Code:

// 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

Re: Modifying Default code
 
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

Re: Modifying Default code
 
Quote:

Originally Posted by Joe Ross
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

Re: Modifying Default code
 
Quote:

Originally Posted by Mark McLeod
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)
Code:

  pwm01 = p1_y; 
  pwm02 = p2_y;


Ryan M. 15-02-2004 13:02

Re: Modifying Default code
 
Quote:

Originally Posted by Joe Ross
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

Re: Modifying Default code
 
Quote:

Originally Posted by Joe Ross
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)
Code:

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:
Code:

/*---------- 2 Joystick Drive ----------------------------------------------

*-------------------------------------------------------------------------
*/



and that's what I was missing.

Thanks!


All times are GMT -5. The time now is 04:20.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi