File Name: JoystickCenter
File Submitter: DJRobX
File Submitted: 06 Jan 2014
File Category: Tutorials
Small utility to help keep Nanotech analog nudging centered/calibrated.
Source is included for anyone who wants to mess around with it. Note that I did just enough to make it do what I needed to do and nothing more. It's ugly, dirty, filthy, proof-of-concept quality code. If someone wants to take this and make it into a more user-friendly package knock yourself out!
Summary:
1) Sample the joystick input once every 30 seconds
2) Record those samples for 10 seconds
3) If any movement during those 10 seconds is above a threshold (i.e., you're nudging), stop and wait for things to settle.
4) If you make it through 10 seconds, average the readings and set the new center. Rinse, repeat.
It has a UI so you can sort of see what it's doing. At startup and runs and minimizes into your tray (as to not mess with Hyperpin). If you open it you can see the numeric readings of your X and Y axis. If you watch it in the first 10 seconds you should see it center itself.
The configuration constants are currently:
#define SAMPLES_TO_TAKE (30 * 10)
#define MAX_DEVIATION 200
#define DELAYTIME (30 * 10)
#define ADJUST_THRESHOLD 5
This does mean your calibrations need to be in the ballpark (idle values no more than +- 200 off of actual center) in order for it to start working. You could set higher deviations, but that means the centers could get temporarily corrupted by gentle nudging.
I have not seen any performance impact from this. Its calculations are very light.
Click here to download this file




Top








are all trademarks of VPFORUMS.