當前位置: 首頁>>代碼示例>>C#>>正文


C# GpioPin.IsDriveModeSupported方法代碼示例

本文整理匯總了C#中Windows.Devices.Gpio.GpioPin.IsDriveModeSupported方法的典型用法代碼示例。如果您正苦於以下問題:C# GpioPin.IsDriveModeSupported方法的具體用法?C# GpioPin.IsDriveModeSupported怎麽用?C# GpioPin.IsDriveModeSupported使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Windows.Devices.Gpio.GpioPin的用法示例。


在下文中一共展示了GpioPin.IsDriveModeSupported方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: InitGpio

        /// <summary>
        /// 
        /// </summary>
        private void InitGpio()
        {
            var gpio = GpioController.GetDefault();
            if (gpio== null)
            {
                Debug.WriteLine("Can't find GpioController.");
                return;
            }

            pin = gpio.OpenPin(inputPin);

            if (pin.IsDriveModeSupported(GpioPinDriveMode.InputPullUp))
            {
                pin.SetDriveMode(GpioPinDriveMode.InputPullUp);
            }
            else
            {
                pin.SetDriveMode(GpioPinDriveMode.Input);
            }

            Debug.WriteLine("GPIO initializing...");

            //Sleep
            for (int i = 0; i <= 10000; i++) { }

            //Event
            pin.ValueChanged += Pin_ValueChanged;

            Debug.WriteLine("GPIO initialized.");
        }
開發者ID:linyixian,項目名稱:SecurityWebcam,代碼行數:33,代碼來源:MainPage.xaml.cs

示例2: InitGPIO

        private void InitGPIO()
        {
            var gpio = GpioController.GetDefault();

            if (gpio == null)
            {
                GpioStatus.Text = "There is no GPIO controller on this device.";
                return;
            }

            button1Pin = gpio.OpenPin(BUTTON1_PIN);
            led1Pin = gpio.OpenPin(LED1_PIN);

            // Initialize LED to the OFF state by first writing a HIGH value
            led1Pin.Write(GpioPinValue.High);
            led1Pin.SetDriveMode(GpioPinDriveMode.Output);

            // Check if input pull-up resistors are supported
            if (button1Pin.IsDriveModeSupported(GpioPinDriveMode.InputPullUp))
                button1Pin.SetDriveMode(GpioPinDriveMode.InputPullUp);
            else
                button1Pin.SetDriveMode(GpioPinDriveMode.Input);

            // Set a debounce timeout to filter out switch bounce noise from a button press
            button1Pin.DebounceTimeout = TimeSpan.FromMilliseconds(50);

            // Register for the ValueChanged event so our buttonPin_ValueChanged 
            // function is called when the button is pressed
            button1Pin.ValueChanged += buttonPin_ValueChanged;

            GpioStatus.Text = "GPIO pins initialized correctly.";
        }
開發者ID:thebeebs,項目名稱:microedgecase,代碼行數:32,代碼來源:MainPage.xaml.cs

示例3: InitGPIO

        private void InitGPIO()
        {
            var gpio = GpioController.GetDefault();

            // error prompt
            if (gpio == null) {
                GpioStatus.Text = "There's no GPIO controller on this device";
                return -1;
            }

            buttonPin = gpio.OpenPin(BUTTON_PIN);
            ledPin = gpio.OpenPin(LED_PIN);

            // init LED to OFF by HIGH, cuz LED is wired in LOW config
            ledPin.Write(GpioPinValue.High);
            ledPin.SetDriveMode(GpioPinDriveMode.Output);

            // checking if input pull-up resistors are supported
            if (buttonPin.IsDriveModeSupported(GpioPinDriveMode.InputPullUp)) {
                buttonPin.SetDriveMode(GpioPinDriveMode.InputPullUp);
            }
            else {
                buttonPin.SetDriveMode(GpioPinDriveMode.Input);
            }

            // setting debounce timeout
            buttonPin.DebounceTimeout = TimeSpan.FromMilliseconds(50);

            // register for ValueChanged event
            // so buttonPin_ValueChanged()
            // is called when button is pressed
            buttonPin.ValueChanged += buttonPin_ValueChanged;

            GpioStatus.Text = "GPIO pins initialized correctly";
        }
開發者ID:btlone,項目名稱:Quiet-Maker,代碼行數:35,代碼來源:PushButton.cs

示例4: Init

        public override void Init()
        {
            Debug.WriteLine("Initializing push button.");

            try
            {
                _pushButtonPin = _gpioController.OpenPin(Pin);

                if (_pushButtonPin == null)
                {
                    Debug.WriteLine(string.Format("Push button pin not found at GPIO {0}.", Pin));
                    throw new Exception(string.Format("Push button pin not found at GPIO {0}.", Pin));
                }
                else
                {
                    Debug.WriteLine(string.Format("Push button initialized at GPIO {0}.", Pin));
                }

                if (_pushButtonPin.IsDriveModeSupported(GpioPinDriveMode.InputPullUp))
                    _pushButtonPin.SetDriveMode(GpioPinDriveMode.InputPullUp);
                else
                    _pushButtonPin.SetDriveMode(GpioPinDriveMode.Input);

                _pushButtonPin.DebounceTimeout = TimeSpan.FromMilliseconds(50);

                _pushButtonPin.ValueChanged += _pushButtonPin_ValueChanged;

                Debug.WriteLine("Push button initialized.");
            }
            catch
            {
                Debug.WriteLine("Failed to initialize push button.");
                throw new Exception("Failed to initialize push button.");
            }
        }
開發者ID:adgroc,項目名稱:win-iot-core,代碼行數:35,代碼來源:PushButton.cs

示例5: InitGPIO

        private void InitGPIO()
        {
            var gpio = GpioController.GetDefault();

            // Show an error if there is no GPIO controller
            if (gpio == null)
            {
                _buttonpin = null;
                _buzzerpin = null;
                GpioStatus.Text = "There is no GPIO controller on this device.";
                return;
            }

            _buttonpin = gpio.OpenPin(BUTTON_PIN);
            _buzzerpin = gpio.OpenPin(BUZZER_PIN);

            if (_buttonpin.IsDriveModeSupported(GpioPinDriveMode.InputPullUp))
                _buttonpin.SetDriveMode(GpioPinDriveMode.InputPullUp);
            else
                _buttonpin.SetDriveMode(GpioPinDriveMode.Input);

            _buttonpin.DebounceTimeout = TimeSpan.FromMilliseconds(50);
            _buttonpin.ValueChanged += Buttonpin_ValueChanged;

            _buzzerpin.Write(GpioPinValue.Low);
            _buzzerpin.SetDriveMode(GpioPinDriveMode.Output);

            GpioStatus.Text = "GPIO button and buzzer pin initialized correctly.";
        }
開發者ID:nielsvdc,項目名稱:raspberrypi-sunfounder,代碼行數:29,代碼來源:MainPage.xaml.cs

示例6: Init

        public void Init(GpioPin gpioPin)
        {
            // Use InputPullUp if supported, otherwise fall back to Input (floating)
            inputDriveMode =
                gpioPin.IsDriveModeSupported(GpioPinDriveMode.InputPullUp) ?
                GpioPinDriveMode.InputPullUp : GpioPinDriveMode.Input;

            gpioPin.SetDriveMode(inputDriveMode);
            pin = gpioPin;
        }
開發者ID:BeRoces,項目名稱:iot,代碼行數:10,代碼來源:Dht11.cs

示例7: _init

        void _init()
        {
            _pin = _gpio.OpenPin(_pinNumber, _sharingMode);

            if (!_pin.IsDriveModeSupported(_driveMode))
            {
                throw new NotSupportedException($"Drive mode {_driveMode} not supported on pin {_pinNumber}");    
            }

            _pin.SetDriveMode(_driveMode);
        }
開發者ID:rahuldasnaskar,項目名稱:xIOT,代碼行數:11,代碼來源:XGpio.cs

示例8: Initialize

        /// <summary>
        /// Attempts to initialize Gpio for application. This includes doorbell interaction and locking/unlccking of door.
        /// Returns true if initialization is successful and Gpio can be utilized. Returns false otherwise.
        /// </summary>
        public bool Initialize()
        {
            // Gets the GpioController
            gpioController = GpioController.GetDefault();
            if(gpioController == null)
            {
                // There is no Gpio Controller on this device, return false.
                return false;
            }

            // Opens the GPIO pin that interacts with the doorbel button
            doorbellPin = gpioController.OpenPin(GpioConstants.ButtonPinID);

            if (doorbellPin == null)
            {
                // Pin wasn't opened properly, return false
                return false;
            }

            // Set a debounce timeout to filter out switch bounce noise from a button press
            doorbellPin.DebounceTimeout = TimeSpan.FromMilliseconds(25);

            if (doorbellPin.IsDriveModeSupported(GpioPinDriveMode.InputPullUp))
            {
                // Take advantage of built in pull-up resistors of Raspberry Pi 2 and DragonBoard 410c
                doorbellPin.SetDriveMode(GpioPinDriveMode.InputPullUp);
            }
            else
            {
                // MBM does not support PullUp as it does not have built in pull-up resistors 
                doorbellPin.SetDriveMode(GpioPinDriveMode.Input);
            }

            // Opens the GPIO pin that interacts with the door lock system
            doorLockPin = gpioController.OpenPin(GpioConstants.DoorLockPinID);
            if(doorLockPin == null)
            {
                // Pin wasn't opened properly, return false
                return false;
            }
            // Sets doorbell pin drive mode to output as pin will be used to output information to lock
            doorLockPin.SetDriveMode(GpioPinDriveMode.Output);
            // Initializes pin to high voltage. This locks the door. 
            doorLockPin.Write(GpioPinValue.High);

            //Initialization was successfull, return true
            return true;
        }
開發者ID:vishalishere,項目名稱:Facial-Recognition-Door,代碼行數:52,代碼來源:GpioHelper.cs

示例9: InitGPIO

        private void InitGPIO()
        {
            // Initialize the GPIO controller
            GpioController gpio = GpioController.GetDefault();

            // Show an error if there is no GPIO controller
            if (gpio == null)
            {
                _pin1 = null;
                _pin2 = null;
                _pin3 = null;
                GpioStatus.Text = "There is no GPIO controller on this device.";
                return;
            }

            // Initialize the GPIO pin for the first LED
            _pin1 = gpio.OpenPin(LED1_PIN);
            _pin1.SetDriveMode(GpioPinDriveMode.Output);
            _pin1.Write(GpioPinValue.High);

            // Initialize the GPIO pin for the second LED
            _pin2 = gpio.OpenPin(LED2_PIN);
            _pin2.SetDriveMode(GpioPinDriveMode.Output);
            _pin2.Write(GpioPinValue.Low);

            // Initialize the LED1 Ellipse to draw Gray
            LED1.Fill = _redBrush;

            // Initialize Button pin
            _pin3 = gpio.OpenPin(BUTT_PIN);

            // Check if input pull-up resistors are supported
            if (_pin3.IsDriveModeSupported(GpioPinDriveMode.InputPullUp))
                _pin3.SetDriveMode(GpioPinDriveMode.InputPullUp);
            else
                _pin3.SetDriveMode(GpioPinDriveMode.Input);
            
            // Set a debounce timeout to filter out switch bounce noise from a button press
            _pin3.DebounceTimeout = TimeSpan.FromMilliseconds(50);
            
            // Register for the ValueChanged event so our buttonPin_ValueChanged 
            // function is called when the button is pressed
            _pin3.ValueChanged += _pin3_ValueChanged;

            // Show the GPIO is OK message
            GpioStatus.Text = "GPIO pin initialized correctly.";
        }
開發者ID:mort8088,項目名稱:Windows-IoT-Tutorials,代碼行數:47,代碼來源:MainPage.xaml.cs

示例10: MainPage

        public MainPage()
        {
            this.InitializeComponent();
            //GPIO();
            //InitDancing();

            stopwatch = Stopwatch.StartNew();

            GpioController gpio = GpioController.GetDefault();
            buttonPin = gpio.OpenPin(21);
            if (buttonPin.IsDriveModeSupported(GpioPinDriveMode.InputPullUp))
                buttonPin.SetDriveMode(GpioPinDriveMode.InputPullUp);
            else
                buttonPin.SetDriveMode(GpioPinDriveMode.Input);
            buttonPin.DebounceTimeout = TimeSpan.FromMilliseconds(50);

            buttonPin2 = gpio.OpenPin(20);
            if (buttonPin2.IsDriveModeSupported(GpioPinDriveMode.InputPullUp))
                buttonPin2.SetDriveMode(GpioPinDriveMode.InputPullUp);
            else
                buttonPin2.SetDriveMode(GpioPinDriveMode.Input);
            buttonPin2.DebounceTimeout = TimeSpan.FromMilliseconds(50);

            timer = new DispatcherTimer();
            timer.Interval = TimeSpan.FromMilliseconds(BEAT_PACE);
            timer.Tick += Beat;
            
            servoPinA = gpio.OpenPin(SERVO_PIN_A);
            servoPinA.SetDriveMode(GpioPinDriveMode.Output);
            buttonPin.ValueChanged += Pin1_ValueChanged;
            buttonPin2.ValueChanged += ButtonPin2_ValueChanged;

            force();
            //AsyncFunc();

            //WebSocket();
        }
開發者ID:GillianPerard,項目名稱:IoT-serrure-CFGPT,代碼行數:37,代碼來源:MainPage.xaml.cs

示例11: InitGPIO

        private void InitGPIO()
        {
            // Instantiate the Azure device client
            deviceClient = DeviceClient.CreateFromConnectionString(IOT_HUB_CONN_STRING);

            var gpio = GpioController.GetDefault();

            // Show an error if there is no GPIO controller
            if (gpio == null)
            {
                GpioStatus.Text = "There is no GPIO controller on this device.";
                return;
            }

            buttonPin = gpio.OpenPin(BUTTON_PIN);
            ledPin = gpio.OpenPin(LED_PIN);

            // Initialize LED to the OFF state by first writing a HIGH value
            // We write HIGH because the LED is wired in a active LOW configuration
            ledPin.Write(GpioPinValue.High);
            ledPin.SetDriveMode(GpioPinDriveMode.Output);

            // Check if input pull-up resistors are supported
            if (buttonPin.IsDriveModeSupported(GpioPinDriveMode.InputPullUp))
                buttonPin.SetDriveMode(GpioPinDriveMode.InputPullUp);
            else
                buttonPin.SetDriveMode(GpioPinDriveMode.Input);

            // Set a debounce timeout to filter out switch bounce noise from a button press
            buttonPin.DebounceTimeout = TimeSpan.FromMilliseconds(5);

            // Register for the ValueChanged event so our buttonPin_ValueChanged 
            // function is called when the button is pressed
            buttonPin.ValueChanged += buttonPin_ValueChanged;

            GpioStatus.Text = "GPIO pins initialized correctly.";
        }
開發者ID:jefking,項目名稱:MouseTrapp,代碼行數:37,代碼來源:MainPage.xaml.cs

示例12: InitGPIO

        private void InitGPIO()
        {
            var gpio = GpioController.GetDefault();

            // Show an error if there is no GPIO controller
            if (gpio == null)
            {
                return;
            }

            _doorUpPin = gpio.OpenPin(DOOR_UP_PIN);
            _doorDownPin = gpio.OpenPin(DOOR_DOWN_PIN);

            if (_doorUpPin.IsDriveModeSupported(GpioPinDriveMode.InputPullUp))
                _doorUpPin.SetDriveMode(GpioPinDriveMode.InputPullUp);
            else
                _doorUpPin.SetDriveMode(GpioPinDriveMode.Input);
            _doorUpPin.DebounceTimeout = TimeSpan.FromMilliseconds(50);
            _doorUpPin.ValueChanged += _doorUpPin_ValueChanged;

            if (_doorDownPin.IsDriveModeSupported(GpioPinDriveMode.InputPullUp))
                _doorDownPin.SetDriveMode(GpioPinDriveMode.InputPullUp);
            else
                _doorDownPin.SetDriveMode(GpioPinDriveMode.Input);
            _doorDownPin.DebounceTimeout = TimeSpan.FromMilliseconds(50);
            _doorDownPin.ValueChanged += _doorDownPin_ValueChanged;

            _doorRelayPin = gpio.OpenPin(DOOR_RELAY_PIN);
            _doorRelayPin.Write(GpioPinValue.High);
            _doorRelayPin.SetDriveMode(GpioPinDriveMode.Output);
        }
開發者ID:mlinnen,項目名稱:HacksterIOWin10IoT,代碼行數:31,代碼來源:GarageDoorDriver.cs

示例13: InitHeartRateSensor

        private void InitHeartRateSensor()
        {
            m_heart_rate_sensor = m_gpio.OpenPin(HEART_RATE_SENSOR_PIN);


            if (m_heart_rate_sensor.IsDriveModeSupported(GpioPinDriveMode.InputPullUp))
            {
                //change this if you get rid of the external pull up
                m_heart_rate_sensor.SetDriveMode(GpioPinDriveMode.Input);
            }
            else
            {
                m_heart_rate_sensor.SetDriveMode(GpioPinDriveMode.Input);
            }

            m_heart_rate_sensor.DebounceTimeout = TimeSpan.FromMilliseconds(0);
            m_heart_rate_sensor.ValueChanged += M_heart_rate_sensor_ValueChanged;

        }
開發者ID:derektaprell,項目名稱:PiBike2,代碼行數:19,代碼來源:C7ZL_init.cs

示例14: InitGpio

    /// <summary>
    /// Initializes the GpioController on the board if it exists, and initializes the Led and Button pins.
    /// </summary>
    private void InitGpio()
    {
      //Attempt to get the GpioController instance for the 
      //device.  
      var gpio = GpioController.GetDefault();

      // If no GpioController was found (gpio==null), null out the pins
      // And throw an exception indicating there was no GPIO controller
      if (gpio == null)
      {
        ledPin = null;
        buttonPin = null;
        throw new Exception("There is no GPIO controller on this device.");
      }

      //Init LED pin
      ledPin = gpio.OpenPin(LED_PIN);
      ledPin.SetDriveMode(GpioPinDriveMode.Output);
      SetLedState(false);

      //Init Button pin
      buttonPin = gpio.OpenPin(BUTTON_PIN);

      //Remember Windows 10 IoT Core runs on multiple boards.
      //If the board's pin that the button is connected to supports
      //pullup resistors, enable the pullup resistor, otherwise, just use
      //it as a normal input
      if (buttonPin.IsDriveModeSupported(GpioPinDriveMode.InputPullUp))
      {
        buttonPin.SetDriveMode(GpioPinDriveMode.InputPullUp);
      }
      else
      {
        buttonPin.SetDriveMode(GpioPinDriveMode.Input);
      }

      //Set a debounce timeout to filter out switch bounce noice from a button press
      buttonPin.DebounceTimeout = TimeSpan.FromMilliseconds(50);

      //Wire up an event hander to be called whenever the button gets pressed.
      buttonPin.ValueChanged += ButtonPin_ValueChanged;
    }
開發者ID:BretStateham,項目名稱:WindowsOnPi,代碼行數:45,代碼來源:MainPage.xaml.cs

示例15: InitCadenceSensor

        private void InitCadenceSensor()
        {
            m_cadence_sensor = m_gpio.OpenPin(CADENCE_SENSOR_PIN);


            if (m_cadence_sensor.IsDriveModeSupported(GpioPinDriveMode.InputPullUp))
            { 
                
                m_cadence_sensor.SetDriveMode(GpioPinDriveMode.InputPullUp);
            }
            else
            {
                m_cadence_sensor.SetDriveMode(GpioPinDriveMode.Input);
            }

            m_cadence_sensor.DebounceTimeout = TimeSpan.FromMilliseconds(10);
            m_cadence_sensor.ValueChanged += M_cadence_sensor_ValueChanged;

            RPM = 0;


        }
開發者ID:derektaprell,項目名稱:PiBike2,代碼行數:22,代碼來源:C7ZL_init.cs


注:本文中的Windows.Devices.Gpio.GpioPin.IsDriveModeSupported方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。