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.

Committer:
rvt
Date:
Wed Jun 22 12:50:16 2016 +0000
Revision:
5:a0bb17c379ce
Parent:
2:ae7a31a3c618
Latest

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rvt 0:33bc88c4ab31 1 #ifndef ANALOGINFILTERED_H
rvt 0:33bc88c4ab31 2 #define ANALOGINFILTERED_H
rvt 0:33bc88c4ab31 3
rvt 0:33bc88c4ab31 4 #include "mbed.h"
rvt 0:33bc88c4ab31 5 #include "AnalogFilterInterface.h"
rvt 0:33bc88c4ab31 6
rvt 1:5b2ab44eb31f 7 /**
rvt 1:5b2ab44eb31f 8 Analog input, this reads a analog value from a PIN and send the data through the filterchain
rvt 1:5b2ab44eb31f 9 */
rvt 5:a0bb17c379ce 10 class AnalogInFiltered : public AnalogFilterInterface {
rvt 0:33bc88c4ab31 11 private:
rvt 0:33bc88c4ab31 12 AnalogIn *_ain;
rvt 5:a0bb17c379ce 13 const int _fuzzyFactor;
rvt 5:a0bb17c379ce 14 AnalogFilterInterface *_filter;
rvt 0:33bc88c4ab31 15 long _lastValue;
rvt 0:33bc88c4ab31 16 public:
rvt 1:5b2ab44eb31f 17 /**
rvt 1:5b2ab44eb31f 18 filter : Failter chain
rvt 1:5b2ab44eb31f 19 pin : Analog input to read
rvt 1:5b2ab44eb31f 20 */
rvt 2:ae7a31a3c618 21 AnalogInFiltered(AnalogFilterInterface *filter, PinName pin, int fuzzyFactor);
rvt 0:33bc88c4ab31 22 ~AnalogInFiltered();
rvt 1:5b2ab44eb31f 23
rvt 1:5b2ab44eb31f 24 // Read a value from analog in
rvt 5:a0bb17c379ce 25 virtual void setData(long data);
rvt 5:a0bb17c379ce 26 virtual long getData() const;
rvt 1:5b2ab44eb31f 27
rvt 1:5b2ab44eb31f 28 // Test if the input value is changed based on a offset
rvt 2:ae7a31a3c618 29 bool getIsChanged();
rvt 2:ae7a31a3c618 30
rvt 2:ae7a31a3c618 31 int getFuzzyFactor();
rvt 0:33bc88c4ab31 32 };
rvt 0:33bc88c4ab31 33
rvt 0:33bc88c4ab31 34 #endif