CHENGQI YANG / MGC3130

Dependencies:   BufferedArray

Dependents:   NucleoMGC3130 i2c_master

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SensorData.h Source File

SensorData.h

00001 #ifndef UK_AC_HERTS_SMARTLAB_MGC3130_SensorData
00002 #define UK_AC_HERTS_SMARTLAB_MGC3130_SensorData
00003 
00004 #include "GestICMsg.h"
00005 #include "TouchInfo.h"
00006 #include "GestureInfo.h"
00007 
00008 /** This message contains the sensor data output of the MGC3X30. The content of the
00009 *message can be configured via bit mask.The elements DataOutputConfigMask, TimeStamp, and SystemInfo are always part of the
00010 *message. The inclusion of further payload elements depends on the Configuration, and the
00011 *actual Configuration can be read from the payload element. DataOutputConfigMask.
00012 */
00013 class SensorData : public GestICMsg
00014 {
00015 private:
00016     /** -1 means value not included, so that is... can return false
00017     * to convet the value is... valid still required
00018     *
00019     *   Bit 0: DSPStatus field.
00020     *   Bit 1: GestureInfo field.
00021     *   Bit 2: TouchInfo field.
00022     *   Bit 3: AirWheelInfo field.
00023     *   Bit 4: xyzPosition field.
00024     *   Bit 5: NoisePower field.
00025     *   Bit 6...10: These bits are reserved.
00026     *   Bit 11: CICData field.
00027     *   Bit 12: SDData field.
00028     *   Bit 13...15: These bits are reserved.
00029     */
00030     int _DSPStatus; // 2 bytes
00031     int _GestureInfo; // 4 bytes
00032     int _TouchInfo; // 4 bytes
00033     int _AirWheelInfo; // 2 bytes
00034     int _xyzPosition; // 6 bytes
00035     int _NoisePower; // 4 bytes
00036     int _CICData; // 20 bytes
00037     int _SDData; // 20 bytes
00038 
00039     /** set is... when converting from GestICMsg to SensorData
00040     *
00041     *Bit mask indicating if the respective sensor data is valid. In an application, the sensor data output should only be further processed if the respective bits are set to ‘1’.
00042     *The following bits are used:
00043     *Bit 0: PositionValid, if set indicates that the position in the xyzPosition field is valid.
00044     *Bit 1: AirWheelValid, if set indicates that the AirWheel is active and the data in the AirWheelInfo field is valid.
00045     *Bit 2: RawDataValid, if set indicates that the data of the CICData and SDData fields are valid; otherwise those fields must be ignored.
00046     *Bit 3: NoisePowerValid, if set indicates that the NoisePower field is valid.
00047     *Bit 4: EnvironmentalNoise, if set indicates that environmental noise has been detected.
00048     *Bit 5: Clipping, if set indicates that the ADCs are clipping.
00049     *Bit 6: This bit is reserved.
00050     *Bit 7: DSPRunning, if set indicates that the system is currently running. If not set, the system is about to go to Sleep.
00051     */
00052     void process();
00053 
00054     int xyz[3];
00055     TouchInfo touch;
00056     float raw[5];
00057     GestureInfo gesture;
00058 
00059 public:
00060     /// Construct a empty message.
00061     SensorData();
00062     
00063     /** Construct a message with existing @GestICMsg as its base.
00064     *
00065     * @param msg received @GestICMsg message
00066     *
00067     */
00068     SensorData(GestICMsg * msg);
00069 
00070     /** Apply existing @GestICMsg as its content.
00071     *
00072     * @param msg received @GestICMsg message, used by API itself.
00073     *
00074     * @returns
00075     *   true current @GestICMsg is a sensor payload and content has been updated.
00076     *   false current @GestICMsg is not sensor payload and content not affected.
00077     *
00078     */
00079     bool convert(GestICMsg * msg);
00080 
00081 
00082     /** Check if DPS status information is included.
00083     *
00084     * @returns
00085     *       true included
00086     *       false not included
00087     */
00088     bool isDSPStatus();
00089 
00090     /** Check if the gesture information is included.
00091     *
00092     * @returns
00093     *       true included
00094     *       false not included
00095     */
00096     bool isGestureInfo();
00097 
00098     /** Check if touch information is included.
00099     *
00100     * @returns
00101     *       true included
00102     *       false not included
00103     */
00104     bool isTouchInfo();
00105 
00106     /** Check if air wheel information is included.
00107     *
00108     * @returns
00109     *       true included
00110     *       false not included
00111     */
00112     bool isAirWheelInfo();
00113 
00114     /** Check if xyz position information is included.
00115     *
00116     * @returns
00117     *       true included
00118     *       false not included
00119     */
00120     bool isxyzPosition();
00121 
00122     /** Check if noise power information is included.
00123     *
00124     * @returns
00125     *       true included
00126     *       false not included
00127     */
00128     bool isNoisePower();
00129 
00130     /** Check if uncalibrated sensor data is included.
00131     *
00132     * @returns
00133     *       true included
00134     *       false not included
00135     */
00136     bool isCICData();
00137 
00138     /** Check if signal deviation dtat is included.
00139     *
00140     * @returns
00141     *       true included
00142     *       false not included
00143     */
00144     bool isSDData();
00145 
00146   
00147     /** Check if the position in the xyzPosition field is valid.
00148     *
00149     * @returns
00150     *       true valid
00151     *       false not valid
00152     */
00153     bool isPositionValid();
00154     
00155     /** Check if the AirWheel is active and the data in the AirWheelInfo field is valid.
00156     *
00157     * @returns
00158     *       true valid
00159     *       false not valid
00160     */
00161     bool isAirWheelValid();
00162     
00163     /** Check if raw data is valid, if set indicates that the data of the CICData and SDData fields are valid; otherwise those fields must be ignored.
00164     *
00165     * @returns
00166     *       true valid
00167     *       false not valid
00168     */
00169     bool isRawDataValid();
00170     
00171     /** Check if the NoisePower field is valid.
00172     *
00173     * @returns
00174     *       true valid
00175     *       false not valid
00176     */
00177     bool isNoisePowerValid();
00178     
00179     /** Check if the environmental noise has been detected.
00180     *
00181     * @returns
00182     *       true valid
00183     *       false not valid
00184     */
00185     bool isEnvironmentalNoise();
00186     
00187     /** Check if the the ADCs are clipping.
00188     *
00189     * @returns
00190     *       true valid
00191     *       false not valid
00192     */
00193     bool isClipping();
00194     
00195     /** Check if the system is currently running. If not set, the system is about to go to Sleep.
00196     *
00197     * @returns
00198     *       true valid
00199     *       false not valid
00200     */
00201     bool isDSPRunning();
00202 
00203     /** 
00204     *200 Hz counter value wraps around after 256 ticks. This indicates when an
00205     *event has taken place and allows measuring the elapsed time between two
00206     *events, as long as it is below approximately 1.25 seconds.
00207     *
00208     * @returns 8-Bit Counter of 200 Hz (Sample Interval)
00209     *
00210     */
00211     int getTimeStamp();
00212     
00213     /** Get detailed gesture information.
00214     *
00215     * @returns @GestureInfo NULL means data not avaliable
00216     *
00217     */
00218     GestureInfo * getGestureInfo();
00219 
00220     /** Get detailed touch information.
00221     *
00222     * @returns @TouchInfo NULL means data not avaliable
00223     *
00224     */
00225     TouchInfo * getTouchInfo();
00226 
00227     /**
00228     *First: Value represents the current angular position with a resolution of 32 counts for a full revolution.
00229     *Second: [0 - 7] Counts of full rotations.
00230     *Each time the angular position crosses ‘0’, a full revolution is counted.
00231     *If the users hand is moving in clockwise direction the counter is
00232     *increased. For counterclockwise movements, the counter is decreased.
00233     *
00234     * @returns
00235     *   int array [angular,Counts]  NULL means data not avaliable
00236     */
00237     int * getAirWheelInfo();
00238 
00239     /** Get x, y and z position data.
00240     *
00241     * @returns
00242     *   int array [x,y,z]  NULL means data not avaliable
00243     *
00244     */
00245     int * getxyzPosition();
00246 
00247     /** Get noise power of the GestIC system.
00248     *
00249     * @return float value
00250     *
00251     */
00252     float getNoisePower();
00253 
00254     /**
00255     *Uncalibrated Sensor Data (CIC Data)
00256     *Structure: Vector of five, 32-bit Words interpreted as float values in format. An
00257     *offset of 32000 needs to be added to each channel.
00258     *xxxx.xxxx.xxxx.xxxx.xxxx (South.West.North.East.Center)
00259     *
00260     * @returns int array [South.West.North.East.Center]  NULL means data not avaliable
00261     *
00262     */
00263     float * getUncalibratedData();
00264 
00265     /** Get signal deviation
00266     *Structure: Vector of five, 32-bit Words interpreted as float values in xxxx.xxxx.xxxx.xxxx.xxxx (South.West.North.East.Center) format
00267     *
00268     * @returns int array [South.West.North.East.Center]  NULL means data not avaliable
00269     *
00270     */
00271     float * getSignalDeviation();
00272 };
00273 
00274 #endif