HID Joystick - For use with X-Plane or other programs that can read HID JoySticks

Dependencies:   USBDevice mbed-rtos mbed

Fork of JoyStick by Ries Twisk

This is a simple Joystick HID that I use for xplane and a home build yoke + paddels, see this forum with the look and feel of it : http://forums.x-plane.org/index.php?showtopic=70041

The analog input are filtered with a LowPass IIR filter and the digital input's will be derived from the analog input and de-bounced.

The analog values are read at a 1Khz interval and to ensure we don't push the USB stack to much at a maximum rate of 20 updates/sec HID data is send over USB only if any values where changed. The JoyStick will send 16Bit analog values as opposite of 8 bit values that are normally used to increase accuracy of the whole system. This is well noticeable within x-plane!

The JoyStick uses the JoyStick copied from Wim Huiskamp and modified to suite my needs and the MBED RTOS libraries for reading analog inputs, sending debug data over USB and sending HID data, 3 threads in total.

AutoScale.h

Committer:
rvt
Date:
2016-06-22
Revision:
5:a0bb17c379ce

File content as of revision 5:a0bb17c379ce:

#ifndef AUTOSCALE_H
#define AUTOSCALE_H

#include "mbed.h"
#include "AnalogFilterInterface.h"

/**
Auto scale a analog input to it's desired min/max values
This is handy of you connect a potentiometer to a analog input where you cannot make the full values, but
your flight simulator expects full values
**/
class AutoScale : public AnalogFilterInterface
{
private:
    const long _expectedMax;
    const long _expectedMin;
    long _currentMax;
    long _currentMin;
    long _current;
    double _a;
    double _b;
    double _mul;
public:
    AutoScale(AnalogFilterInterface *chain,long expectedMin, long expectedMax);
    AutoScale(AnalogFilterInterface *chain,long expectedMin, long expectedMax, double multiplier);
    ~AutoScale();

    virtual void setData(long data);
    virtual long getData() const;
private:
    void reCalc();
};

#endif