The xplane_io (X-Plane I/O) program is used to establish network communications, via UDP, with the X-Plane flight simulator running on a computer. The code consists of class libraries that abstract the lower-level UDP packet encoding and decoding details, according to the UDP protocol specifications in X-Plane version 9. Any X-Plane DATA packets can be sent and received, and any X-Plane DataRefs can be set by sending DREF packets to X-Plane.
Dependencies: EthernetNetIf mbed ConfigFile
XPlaneIO/XPlaneAnalogIn.h@0:a5d13af495af, 2011-12-21 (annotated)
- Committer:
- bapowell
- Date:
- Wed Dec 21 22:29:59 2011 +0000
- Revision:
- 0:a5d13af495af
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bapowell | 0:a5d13af495af | 1 | #ifndef XPLANEANALOGIN_H_INCLUDED |
bapowell | 0:a5d13af495af | 2 | #define XPLANEANALOGIN_H_INCLUDED |
bapowell | 0:a5d13af495af | 3 | |
bapowell | 0:a5d13af495af | 4 | #include "mbed.h" |
bapowell | 0:a5d13af495af | 5 | #include "Scaler.h" |
bapowell | 0:a5d13af495af | 6 | #include "XPlaneUdpDATA.h" |
bapowell | 0:a5d13af495af | 7 | |
bapowell | 0:a5d13af495af | 8 | class XPlaneAnalogIn { |
bapowell | 0:a5d13af495af | 9 | public: |
bapowell | 0:a5d13af495af | 10 | |
bapowell | 0:a5d13af495af | 11 | XPlaneAnalogIn(PinName pin, Scaler<float> scale1, Scaler<float> scale2, int msgIdx, int msgFloatIdx); |
bapowell | 0:a5d13af495af | 12 | |
bapowell | 0:a5d13af495af | 13 | /** |
bapowell | 0:a5d13af495af | 14 | * Perform a read() on the AnalogIn pin, and return that value. |
bapowell | 0:a5d13af495af | 15 | */ |
bapowell | 0:a5d13af495af | 16 | float read_unscaled(); |
bapowell | 0:a5d13af495af | 17 | |
bapowell | 0:a5d13af495af | 18 | /** |
bapowell | 0:a5d13af495af | 19 | * Perform a read() on the AnalogIn pin, and return the value scaled by the scale1 and scale2 ranges. |
bapowell | 0:a5d13af495af | 20 | * The range used for the scaling is returned via the reference parameter: |
bapowell | 0:a5d13af495af | 21 | * 0 = input fell in between the ranges (i.e. deadband zone), so scaled output is midpoint between scale1 outputTo and scale2 outputFrom |
bapowell | 0:a5d13af495af | 22 | * 1 = input fell in the scale1 range |
bapowell | 0:a5d13af495af | 23 | * 2 = input fell in the scale2 range |
bapowell | 0:a5d13af495af | 24 | * 3 = input was less than scale1 inputFrom, so scaled output is (bounded by) scale1 outputFrom |
bapowell | 0:a5d13af495af | 25 | * 4 = input was greater than scale2 inputTo, so scaled output is (bounded by) scale2 outputTo |
bapowell | 0:a5d13af495af | 26 | * The scaledOutputNoChange reference parameter will be set true if the scaled value didn't changed since the last read. |
bapowell | 0:a5d13af495af | 27 | */ |
bapowell | 0:a5d13af495af | 28 | float read_scaled(int & range, bool & scaledOutputNoChange); |
bapowell | 0:a5d13af495af | 29 | |
bapowell | 0:a5d13af495af | 30 | |
bapowell | 0:a5d13af495af | 31 | // Property accessors and mutators |
bapowell | 0:a5d13af495af | 32 | |
bapowell | 0:a5d13af495af | 33 | //Scaler<float> scale1(); |
bapowell | 0:a5d13af495af | 34 | //void scale1(Scaler<float> scale1); |
bapowell | 0:a5d13af495af | 35 | |
bapowell | 0:a5d13af495af | 36 | //Scaler<float> scale2(); |
bapowell | 0:a5d13af495af | 37 | //void scale2(Scaler<float> scale2); |
bapowell | 0:a5d13af495af | 38 | |
bapowell | 0:a5d13af495af | 39 | int xplaneDATAMsgIdx(); |
bapowell | 0:a5d13af495af | 40 | //void xplaneDATAMsgIdx(int xplaneDATAMsgIdx); |
bapowell | 0:a5d13af495af | 41 | |
bapowell | 0:a5d13af495af | 42 | int xplaneDATAMsgFloatIdx(); |
bapowell | 0:a5d13af495af | 43 | //void xplaneDATAMsgFloatIdx(int xplaneDATAMsgFloatIdx); |
bapowell | 0:a5d13af495af | 44 | |
bapowell | 0:a5d13af495af | 45 | /** |
bapowell | 0:a5d13af495af | 46 | * Print a representation of this instance to outputStream. |
bapowell | 0:a5d13af495af | 47 | */ |
bapowell | 0:a5d13af495af | 48 | void toString(FILE * outputStream); |
bapowell | 0:a5d13af495af | 49 | |
bapowell | 0:a5d13af495af | 50 | private: |
bapowell | 0:a5d13af495af | 51 | |
bapowell | 0:a5d13af495af | 52 | PinName _pin; |
bapowell | 0:a5d13af495af | 53 | Scaler<float> _scale1; |
bapowell | 0:a5d13af495af | 54 | Scaler<float> _scale2; |
bapowell | 0:a5d13af495af | 55 | int _xplaneDATAMsgIdx; |
bapowell | 0:a5d13af495af | 56 | int _xplaneDATAMsgFloatIdx; |
bapowell | 0:a5d13af495af | 57 | |
bapowell | 0:a5d13af495af | 58 | AnalogIn _ain; |
bapowell | 0:a5d13af495af | 59 | |
bapowell | 0:a5d13af495af | 60 | float _lastUnscaledRead; |
bapowell | 0:a5d13af495af | 61 | float _lastScaledRead; |
bapowell | 0:a5d13af495af | 62 | int _lastScaleRange; |
bapowell | 0:a5d13af495af | 63 | }; |
bapowell | 0:a5d13af495af | 64 | |
bapowell | 0:a5d13af495af | 65 | #endif // XPLANEANALOGIN_H_INCLUDED |