当前位置: 首页>>代码示例>>C#>>正文


C# GpioPin.GetDriveMode方法代码示例

本文整理汇总了C#中Windows.Devices.Gpio.GpioPin.GetDriveMode方法的典型用法代码示例。如果您正苦于以下问题:C# GpioPin.GetDriveMode方法的具体用法?C# GpioPin.GetDriveMode怎么用?C# GpioPin.GetDriveMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Windows.Devices.Gpio.GpioPin的用法示例。


在下文中一共展示了GpioPin.GetDriveMode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: NavioRCInputDevice

        /// <summary>
        /// Creates and initializes an instance.
        /// </summary>
        public NavioRCInputDevice()
        {
            // Initialize buffers and events
            _valueBuffer = new ConcurrentQueue<PwmValue>();
            _valueTrigger = new AutoResetEvent(false);
            _frameBuffer = new ConcurrentQueue<PwmFrame>();
            _frameTrigger = new AutoResetEvent(false);

            // Configure GPIO
            _inputPin = GpioController.GetDefault().OpenPin(InputPinNumber);
            if (_inputPin.GetDriveMode() != GpioPinDriveMode.Input)
                _inputPin.SetDriveMode(GpioPinDriveMode.Input);
            _inputPin.DebounceTimeout = TimeSpan.Zero;
            _inputPin.ValueChanged += OnInputPinValueChanged;

            // Create decoder thread (CPPM only to start with, SBus desired)
            _decoder = new CppmDecoder();
            _stop = new CancellationTokenSource();
            _channels = new int[_decoder.MaximumChannels];
            Channels = new ReadOnlyCollection<int>(_channels);
            _decoderTask = Task.Factory.StartNew(() => { _decoder.Decode(_valueBuffer, _valueTrigger, _frameBuffer, _frameTrigger, _stop.Token); });

            // Create receiver thread
            _receiverTask = Task.Factory.StartNew(() => { Receiver(); });
        }
开发者ID:dpal887,项目名称:Navio-SDK-Windows-IoT,代码行数:28,代码来源:NavioRCInputDevice.cs

示例2: NavioPca9685Device

        /// <summary>
        /// Creates an instance with required mode bits set, but the device state and PWM values unchanged (supporting recovery).
        /// </summary>
        /// <remarks>
        /// <para>
        /// Initializing without restart allows the caller decide whether to recover or reset the device. 
        /// Before starting any output be sure to check the <see cref="NxpPca9685Device.Frequency"/>.
        /// </para>
        /// <para>
        /// To start with new settings, call <see cref="NxpPca9685Device.Clear"/>, <seealso cref="Restart"/> then set <see cref="OutputEnabled"/>.
        /// To resume, call <see cref="NxpPca9685Device.Wake"/> then set <see cref="OutputEnabled"/>.
        /// </para>
        /// </remarks>
        public NavioPca9685Device()
            : base(GetDeviceId(), I2cAddress, ExternalClockSpeed, true, true)
        {
            // Add PWM channel shortcuts
            Pwm = new ObservableCollection<NxpPca9685Channel>();
            for (var index = PwmChannelIndex; index < ChannelCount; index++)
                Pwm.Add(Channels[index]);

            // Initialize output pin and ensure in correct mode (but leave current state)
            _outputEnablePin = GpioController.GetDefault().OpenPin(OutputEnableGpioPin);
            if (_outputEnablePin.GetDriveMode() != GpioPinDriveMode.Output)
                _outputEnablePin.SetDriveMode(GpioPinDriveMode.Output);

            // Enable auto-increment and "all call"
            Hardware.WriteBit((byte)NxpPca9685Register.Mode1, (byte)(NxpPca9685Mode1Bits.AutoIncrement | NxpPca9685Mode1Bits.AllCall), true);

            // Set "all call" address
            Hardware.WriteByte((byte)NxpPca9685Register.AllCall, (byte)I2cAllCallAddress);

            // Update property
            ReadMode1();

            // Setup LED channels

            var redChannel = Channels[LedRedChannelIndex];
            redChannel.ValueChanged += OnLedRedChannelChanged;
            _ledRed = ~redChannel.Value.Length & 0xfff;

            var greenChannel = Channels[LedGreenChannelIndex];
            greenChannel.ValueChanged += OnLedGreenChannelChanged;
            _ledGreen = ~greenChannel.Value.Length & 0xfff;

            var blueChannel = Channels[LedBlueChannelIndex];
            blueChannel.ValueChanged += OnLedBlueChannelChanged;
            _ledBlue = ~blueChannel.Value.Length & 0xfff;
        }
开发者ID:caadam,项目名称:Navio-SDK-Windows-IoT,代码行数:49,代码来源:NavioPca9685Device.cs

示例3: NavioRCInputDevice

        /// <summary>
        /// Creates and initializes an instance.
        /// </summary>
        public NavioRCInputDevice()
        {
            // Initialize
            _timer = new Stopwatch();
            _inputPin = GpioController.GetDefault().OpenPin(InputGpioPin);
            _ppmFrame = new double[8];
            _channels = new Collection<NavioRCInputChannel>();
            Channels = new ReadOnlyCollection<NavioRCInputChannel>(_channels);

            // PPM only in current implementation
            Mode = NavioRCInputMode.PPM;
            for (var index = 0; index < PpmChannelCount; index++)
                _channels.Add(new NavioRCInputChannel(index));

            // Configure GPIO
            if (_inputPin.GetDriveMode() != GpioPinDriveMode.Input)
                _inputPin.SetDriveMode(GpioPinDriveMode.Input);
            _inputPin.ValueChanged += OnInputPinValueChanged;
        }
开发者ID:caadam,项目名称:Navio-SDK-Windows-IoT,代码行数:22,代码来源:NavioRCInputDevice.cs


注:本文中的Windows.Devices.Gpio.GpioPin.GetDriveMode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。