/// <summary> /// xIMUserial QuaternionDataReceived event updates oscilloscope. /// </summary> private void xIMUserial_QuaternionDataReceived(object sender, x_IMU_API.QuaternionData e) { float[] euler = e.ConvertToEulerAngles(); eulerAnglesOscilloscope.Caption = "Euler Angles Data (˚)"; eulerAnglesOscilloscope.AddScopeData(euler[0], euler[1], euler[2]); form_3Dcuboid.RotationMatrix = e.ConvertToRotationMatrix(); }
/// <summary> /// QuaternionDataReceived event to set mouse position. /// </summary> /// <remarks> /// Mouse position will not be updated if fewer than 32 packets received since last button down. Design assumes quaternion data output rate = 128 Hz. /// Cursor horizontal position over screen width is represented by ±30 degrees range of psi. /// Cursor vertical position over screen height is represented by ±20 degrees range of theta. /// </remarks> static void xIMUserial_QuaternionDataReceived(object sender, x_IMU_API.QuaternionData e) { if (((x_IMU_API.xIMUserial)sender).PacketsReadCounter.QuaternionDataPackets > sampledCount + 32) { float[] euler = e.ConvertToEulerAngles(); SendInputClass.MouseEvent((int)(SendInputClass.MOUSEEVENTF.ABSOLUTE | SendInputClass.MOUSEEVENTF.MOVE), (int)(32768.5f + ((-euler[2] / 30) * 32768.5f)), (int)(32768.5f + ((-euler[1] / 20) * 32768.5f)), 0); } }