Exemplo n.º 1
0
        /// <summary>
        /// Opens the ADC pin.
        /// </summary>
        /// <param name="device">The ADC device number.</param>
        /// <param name="channel">The ADC channel number to control.</param>
        public AdcChannel(int device, int channel)
        {
            var ret = NativeAdc.Open(device, channel, out _handle);

            if (ret != Internals.Errors.ErrorCode.None)
            {
                throw ExceptionFactory.CreateException(ret);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Disposes the ADC pin.
        /// </summary>
        protected virtual void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            NativeAdc.Close(_handle);
            _disposed = true;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets the current value of the ADC pin.
        /// </summary>
        public uint ReadValue()
        {
            var ret = NativeAdc.Read(_handle, out uint adcValue);

            if (ret != Internals.Errors.ErrorCode.None)
            {
                throw ExceptionFactory.CreateException(ret);
            }
            return(adcValue);
        }