![]() |
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. |
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.
|
Re: Inverting Y axis on joystick
Woulden't it be temp = 255 - p1_y? Because other wise you can have negative numbers.
|
Re: Inverting Y axis on joystick
Quote:
|
Re: Inverting Y axis on joystick
Oh, right. But I think the joystick vals go up to 255.
|
Re: Inverting Y axis on joystick
Code:
|
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. |
Re: Inverting Y axis on joystick
Ok, thank you for correcting me. Though I could've sworn I saw 255 on dashboard... :confused: Oh, well :shrug:
|
| All times are GMT -5. The time now is 20:46. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi