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:
1:5b2ab44eb31f
Latest

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rvt 0:33bc88c4ab31 1 #ifndef LOWPASSFILTER_H
rvt 0:33bc88c4ab31 2 #define LOWPASSFILTER_H
rvt 0:33bc88c4ab31 3 #include "mbed.h"
rvt 0:33bc88c4ab31 4 #include "AnalogFilterInterface.h"
rvt 0:33bc88c4ab31 5
rvt 1:5b2ab44eb31f 6 /**
rvt 1:5b2ab44eb31f 7 * A simple First Order Low Pass filter for analog input's
rvt 1:5b2ab44eb31f 8 * This is a IIR filter based on http://en.wikipedia.org/wiki/Iir_filter
rvt 1:5b2ab44eb31f 9 */
rvt 0:33bc88c4ab31 10 class LowPassFilter : public AnalogFilterInterface {
rvt 0:33bc88c4ab31 11 private:
rvt 0:33bc88c4ab31 12 double _alpha;
rvt 0:33bc88c4ab31 13 double smoothedValue;
rvt 0:33bc88c4ab31 14 public:
rvt 1:5b2ab44eb31f 15 /*
rvt 1:5b2ab44eb31f 16 chain : a interface to AnalogFilterInterface in case you want to chain several filters
rvt 1:5b2ab44eb31f 17 alpha : Filter coefficient. The lower the value of alpha, the less filtering is done
rvt 1:5b2ab44eb31f 18 */
rvt 0:33bc88c4ab31 19 LowPassFilter(AnalogFilterInterface *chain, double alpha);
rvt 0:33bc88c4ab31 20 ~LowPassFilter();
rvt 0:33bc88c4ab31 21 virtual void setData(long data);
rvt 5:a0bb17c379ce 22 virtual long getData() const;
rvt 0:33bc88c4ab31 23 };
rvt 0:33bc88c4ab31 24
rvt 0:33bc88c4ab31 25 #endif