Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Reversing the joystick axis (http://www.chiefdelphi.com/forums/showthread.php?t=34291)

JBotAlan 09-02-2005 19:22

Reversing the joystick axis
 
Sorry if I didn't search well enough, but how does one go about reversing the joystick value? I tried a negative, but I realized the pwm value is an unsigned val, what is the math I need to do on the joystick value to make it so foreward is backward and backward is foreward?

Tristan Lall 09-02-2005 19:34

Re: Reversing the joystick axis
 
Code:

#DEFINE PWM_MAX 254
...
pwm01 = PWM_MAX - p1_y //Your joystick 1 y-value is reversed


jgannon 09-02-2005 19:34

Re: Reversing the joystick axis
 
Quote:

Originally Posted by JBotAlan
Sorry if I didn't search well enough, but how does one go about reversing the joystick value? I tried a negative, but I realized the pwm value is an unsigned val, what is the math I need to do on the joystick value to make it so foreward is backward and backward is foreward?

Instead of:
Code:

pwm01=p1_x;
do:
Code:

pwm01=255-p1_x;
Good luck.

pakrat 09-02-2005 19:47

Re: Reversing the joystick axis
 
Quote:

Originally Posted by jgannon
Instead of:
Code:

pwm01=p1_x;
do:
Code:

pwm01=255-p1_x;
Good luck.


Yeah, this worked for us


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

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