|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
Inverting Y axis on joystick
Hey,
We need to invert the Y axis and I don't know how I would code it, any input on this would be great. |
|
#2
|
|||
|
|||
|
Re: Inverting Y axis on joystick
All you have to do is subtract your current value from 254. I think you can just do p1_y=254-p1_y; but just to be safe I would use a temp variable. Sooo, temp=254-p1_y; then just use temp instead of p1_y (or whatever joystick port) in your program.
|
|
#3
|
|||||
|
|||||
|
Re: Inverting Y axis on joystick
Woulden't it be temp = 255 - p1_y? Because other wise you can have negative numbers.
|
|
#4
|
||||
|
||||
|
Re: Inverting Y axis on joystick
Quote:
|
|
#5
|
|||||
|
|||||
|
Re: Inverting Y axis on joystick
Oh, right. But I think the joystick vals go up to 255.
|
|
#6
|
||||
|
||||
|
Re: Inverting Y axis on joystick
Code:
temp = (p1_y == 255) ? 0 : (254 - p1_y); ![]() |
|
#7
|
|||
|
|||
|
Re: Inverting Y axis on joystick
255 is not a valid output on a PWM. I think 3 consecutive 255's result in a reset or something.
The range is 0-254, so you want: p1_y = 254 - p1_y; No need for a temp variable, the compiler will handle that just fine. |
|
#8
|
|||||
|
|||||
|
Re: Inverting Y axis on joystick
Ok, thank you for correcting me. Though I could've sworn I saw 255 on dashboard...
Oh, well :shrug: |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Changing 1 joystick code to 2 (rookie team) | Brawler006 | Programming | 5 | 20-02-2004 17:00 |
| Fried program slots? | Jeff Waegelin | Programming | 18 | 19-03-2003 18:08 |
| robot goes haywire with the one joystick default code | Miles | Programming | 7 | 24-01-2003 14:58 |
| joystick problem | archiver | 2000 | 12 | 23-06-2002 23:08 |
| switching joystick axis????? | team222badbrad | Technical Discussion | 9 | 16-01-2002 23:07 |