/// <summary> /// Initializes the Gyro. /// </summary> /// <param name="triggeringAxis"> /// The gyro that represents the single axis responsible for /// the triggering of updates. /// </param> /// <param name="mode"> /// The gyro update trigger mode. /// </param> /// <returns> /// Reference to the specified triggering axis, which may or may /// not have been modified. /// </returns> /// <exception cref="System.IO.IOException"> /// Unable to write to gyro. /// </exception> /// <exception cref="ObjectDisposedException"> /// This instance has been disposed. /// </exception> public IGyroscope Init(IGyroscope triggeringAxis, GyroTriggerMode mode) { this.Enable(); if (triggeringAxis == this.aX) { this.aX.SetReadTrigger(mode); } else { this.aX.SetReadTrigger(GyroTriggerMode.ReadNotTriggered); } if (triggeringAxis == this.aY) { this.aY.SetReadTrigger(mode); } else { this.aY.SetReadTrigger(GyroTriggerMode.ReadNotTriggered); } if (triggeringAxis == this.aZ) { this.aZ.SetReadTrigger(mode); } else { this.aZ.SetReadTrigger(GyroTriggerMode.ReadNotTriggered); } return(triggeringAxis); }
/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> /// <filterpriority>2</filterpriority> /// <remarks>Call <see cref="Dispose"/> when you are finished using the /// <see cref="CyrusBuilt.MonoPi.Components.Gyroscope.AxisGyroscope"/>. The <see cref="Dispose"/> method leaves the /// <see cref="CyrusBuilt.MonoPi.Components.Gyroscope.AxisGyroscope"/> in an unusable state. After calling /// <see cref="Dispose"/>, you must release all references to the /// <see cref="CyrusBuilt.MonoPi.Components.Gyroscope.AxisGyroscope"/> so the garbage collector can reclaim the memory /// that the <see cref="CyrusBuilt.MonoPi.Components.Gyroscope.AxisGyroscope"/> was occupying.</remarks> public override void Dispose() { if (base.IsDisposed) { return; } if (this._multiAxisGyro != null) { this._multiAxisGyro.Dispose(); this._multiAxisGyro = null; } this._trigger = GyroTriggerMode.ReadNotTriggered; base.Dispose(); }
/// <summary> /// Initializes the Gyro. /// </summary> /// <param name="triggeringAxis"> /// The gyro that represents the single axis responsible for /// the triggering of updates. /// </param> /// <param name="mode"> /// The gyro update trigger mode. /// </param> /// <returns> /// Reference to the specified triggering axis, which may or may /// not have been modified. /// </returns> /// <exception cref="System.IO.IOException"> /// Unable to write to gyro. /// </exception> /// <exception cref="ObjectDisposedException"> /// This instance has been disposed. /// </exception> public IGyroscope Init(IGyroscope triggeringAxis, GyroTriggerMode mode) { this.Enable(); if (triggeringAxis == this.aX) { this.aX.SetReadTrigger(mode); } else { this.aX.SetReadTrigger(GyroTriggerMode.ReadNotTriggered); } if (triggeringAxis == this.aY) { this.aY.SetReadTrigger(mode); } else { this.aY.SetReadTrigger(GyroTriggerMode.ReadNotTriggered); } if (triggeringAxis == this.aZ) { this.aZ.SetReadTrigger(mode); } else { this.aZ.SetReadTrigger(GyroTriggerMode.ReadNotTriggered); } return triggeringAxis; }
/// <summary> /// Sets the read trigger. /// </summary> /// <param name="readTrigger"> /// The trigger mode to re-read the gyro value. /// </param> public void SetReadTrigger(GyroTriggerMode readTrigger) { this._trigger = readTrigger; }