A GPIO provider for servos driven via ServoBlaster. This is an implementation of Implementation of https://github.com/richardghirst/PiBits/tree/master/ServoBlaster
Inheritance: IServoProvider
Exemplo n.º 1
0
		/// <summary>
		/// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.Components.Servos.RPIServoBlasterDriver"/>
		/// class with the servo pin, the index of the pin in the servo provider's pin map,
		/// The name of the pin, and the servo provider.
		/// </summary>
		/// <param name="pin">
		/// The pin the servo is attached to.
		/// </param>
		/// <param name="index">
		/// The index of the pin in the servo provider's pin map.
		/// </param>
		/// <param name="pinName">
		/// The name of the pin.
		/// </param>
		/// <param name="provider">
		/// The servo provider.
		/// </param>
		/// <exception cref="ArgumentNullException">
		/// <paramref name="pin"/> cannot be null - or -
		/// <paramref name="pinName"/> cannot be null or empty - or -
		/// <paramref name="provider"/> cannot be null.
		/// </exception>
		public RPIServoBlasterDriver(IRaspiGpio pin, Int32 index, String pinName, RPIServoBlasterProvider provider) {
			if (pin == null) {
				throw new ArgumentNullException("pin");
			}

			if (String.IsNullOrEmpty(pinName)) {
				throw new ArgumentNullException("pinName");
			}

			if (provider == null) {
				throw new ArgumentNullException("provider");
			}

			this._pin = pin;
			this._index = index;
			this._pinString = pinName;
			this._provider = provider;
		}
Exemplo n.º 2
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.Servos.RPIServoBlasterDriver"/>. The <see cref="Dispose"/> method leaves
        /// the <see cref="CyrusBuilt.MonoPi.Components.Servos.RPIServoBlasterDriver"/> in an unusable state. After calling
        /// <see cref="Dispose"/>, you must release all references to the
        /// <see cref="CyrusBuilt.MonoPi.Components.Servos.RPIServoBlasterDriver"/> so the garbage collector can reclaim the
        /// memory that the <see cref="CyrusBuilt.MonoPi.Components.Servos.RPIServoBlasterDriver"/> was occupying.</remarks>
        public void Dispose()
        {
            if (this._isDisposed)
            {
                return;
            }

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

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

            this._isDisposed = true;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.Components.Servos.RPIServoBlasterDriver"/>
        /// class with the servo pin, the index of the pin in the servo provider's pin map,
        /// The name of the pin, and the servo provider.
        /// </summary>
        /// <param name="pin">
        /// The pin the servo is attached to.
        /// </param>
        /// <param name="index">
        /// The index of the pin in the servo provider's pin map.
        /// </param>
        /// <param name="pinName">
        /// The name of the pin.
        /// </param>
        /// <param name="provider">
        /// The servo provider.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="pin"/> cannot be null - or -
        /// <paramref name="pinName"/> cannot be null or empty - or -
        /// <paramref name="provider"/> cannot be null.
        /// </exception>
        public RPIServoBlasterDriver(IRaspiGpio pin, Int32 index, String pinName, RPIServoBlasterProvider provider)
        {
            if (pin == null)
            {
                throw new ArgumentNullException("pin");
            }

            if (String.IsNullOrEmpty(pinName))
            {
                throw new ArgumentNullException("pinName");
            }

            if (provider == null)
            {
                throw new ArgumentNullException("provider");
            }

            this._pin       = pin;
            this._index     = index;
            this._pinString = pinName;
            this._provider  = provider;
        }
Exemplo 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.Servos.RPIServoBlasterDriver"/>. The <see cref="Dispose"/> method leaves
		/// the <see cref="CyrusBuilt.MonoPi.Components.Servos.RPIServoBlasterDriver"/> in an unusable state. After calling
		/// <see cref="Dispose"/>, you must release all references to the
		/// <see cref="CyrusBuilt.MonoPi.Components.Servos.RPIServoBlasterDriver"/> so the garbage collector can reclaim the
		/// memory that the <see cref="CyrusBuilt.MonoPi.Components.Servos.RPIServoBlasterDriver"/> was occupying.</remarks>
		public void Dispose() {
			if (this._isDisposed) {
				return;
			}

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

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

			this._isDisposed = true;
		}