Ejemplo n.º 1
0
        /// <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.AnalogDevices.ADXL345"/>. The <see cref="Dispose"/> method
        /// leaves the <see cref="CyrusBuilt.MonoPi.Components.Gyroscope.AnalogDevices.ADXL345"/> in an unusable state. After
        /// calling <see cref="Dispose"/>, you must release all references to the
        /// <see cref="CyrusBuilt.MonoPi.Components.Gyroscope.AnalogDevices.ADXL345"/> so the garbage collector can reclaim
        /// the memory that the <see cref="CyrusBuilt.MonoPi.Components.Gyroscope.AnalogDevices.ADXL345"/> was occupying.</remarks>
        public override void Dispose()
        {
            if (base.IsDisposed)
            {
                return;
            }

            if (this._device != null)
            {
                this._device.Dispose();
                this._device = null;
            }

            if (this._aX != null)
            {
                this._aX.Dispose();
                this._aX = null;
            }

            if (this._aY != null)
            {
                this._aY.Dispose();
                this._aY = null;
            }

            if (this._aZ != null)
            {
                this._aZ.Dispose();
                this._aZ = null;
            }

            if (this._x != null)
            {
                this._x.Dispose();
                this._x = null;
            }

            if (this._y != null)
            {
                this._y.Dispose();
                this._y = null;
            }

            if (this._z != null)
            {
                this._z.Dispose();
                this._z = null;
            }
            base.Dispose();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.Components.Gyroscope.AnalogDevices.ADXL345"/>
        /// class with the I2C device that represents the physical connection
        /// to the gyro.
        /// </summary>
        /// <param name="device">
        /// The I2C device that represents the physical connection to the gyro.
        /// If null, then it is assumed that the host is a revision 2 or higher
        /// board and a default <see cref="CyrusBuilt.MonoPi.IO.I2C.I2CBus"/>
        /// using the rev 2 I2C bus path will be used instead.
        /// </param>
        /// <exception cref="IOException">
        /// Unable to open the specified I2C bus device.
        /// </exception>
        /// <exception cref="ObjectDisposedException">
        /// The specified device instance has been disposed.
        /// </exception>
        public ADXL345(II2CBus device)
            : base()
        {
            if (device == null)
            {
                device = new I2CBus(BoardRevision.Rev2);
            }

            this._device = device;
            if (!this._device.IsOpen)
            {
                this._device.Open();
            }

            this._x = new AxisGyroscope(this, 20f);
            this._y = new AxisGyroscope(this, 20f);
            this._z = new AxisGyroscope(this, 20f);

            this._aX = (AxisGyroscope)this._x;
            this._aY = (AxisGyroscope)this._y;
            this._aZ = (AxisGyroscope)this._z;
        }
Ejemplo n.º 3
0
		/// <summary>
		/// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.Components.Gyroscope.AnalogDevices.ADXL345"/>
		/// class with the I2C device that represents the physical connection
		/// to the gyro.
		/// </summary>
		/// <param name="device">
		/// The I2C device that represents the physical connection to the gyro.
		/// If null, then it is assumed that the host is a revision 2 or higher
		/// board and a default <see cref="CyrusBuilt.MonoPi.IO.I2C.I2CBus"/>
		/// using the rev 2 I2C bus path will be used instead.
		/// </param>
		/// <exception cref="IOException">
		/// Unable to open the specified I2C bus device.
		/// </exception>
		/// <exception cref="ObjectDisposedException">
		/// The specified device instance has been disposed.
		/// </exception>
		public ADXL345(II2CBus device)
			: base() {
			if (device == null) {
				device = new I2CBus(BoardRevision.Rev2);
			}

			this._device = device;
			if (!this._device.IsOpen) {
				this._device.Open();
			}

			this._x = new AxisGyroscope(this, 20f);
			this._y = new AxisGyroscope(this, 20f);
			this._z = new AxisGyroscope(this, 20f);

			this._aX = (AxisGyroscope)this._x;
			this._aY = (AxisGyroscope)this._y;
			this._aZ = (AxisGyroscope)this._z;
		}
Ejemplo n.º 4
0
		/// <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.AnalogDevices.ADXL345"/>. The <see cref="Dispose"/> method
		/// leaves the <see cref="CyrusBuilt.MonoPi.Components.Gyroscope.AnalogDevices.ADXL345"/> in an unusable state. After
		/// calling <see cref="Dispose"/>, you must release all references to the
		/// <see cref="CyrusBuilt.MonoPi.Components.Gyroscope.AnalogDevices.ADXL345"/> so the garbage collector can reclaim
		/// the memory that the <see cref="CyrusBuilt.MonoPi.Components.Gyroscope.AnalogDevices.ADXL345"/> was occupying.</remarks>
		public override void Dispose() {
			if (base.IsDisposed) {
				return;
			}

			if (this._device != null) {
				this._device.Dispose();
				this._device = null;
			}

			if (this._aX != null) {
				this._aX.Dispose();
				this._aX = null;
			}

			if (this._aY != null) {
				this._aY.Dispose();
				this._aY = null;
			}

			if (this._aZ != null) {
				this._aZ.Dispose();
				this._aZ = null;
			}

			if (this._x != null) {
				this._x.Dispose();
				this._x = null;
			}

			if (this._y != null) {
				this._y.Dispose();
				this._y = null;
			}

			if (this._z != null) {
				this._z.Dispose();
				this._z = null;
			}
			base.Dispose();
		}