• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# GpioPinValue类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中GpioPinValue的典型用法代码示例。如果您正苦于以下问题:C# GpioPinValue类的具体用法?C# GpioPinValue怎么用?C# GpioPinValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



GpioPinValue类属于命名空间,在下文中一共展示了GpioPinValue类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: InitGPIO

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

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

            pin = gpio.OpenPin(LED_PIN);
            pinValue = GpioPinValue.High;
            pin.Write(pinValue);
            pin.SetDriveMode(GpioPinDriveMode.Output);

            waterPin = gpio.OpenPin(WATER_PIN);
            waterPinValue = GpioPinValue.High;
            //waterPin.Read(waterPinValue);
            waterPin.SetDriveMode(GpioPinDriveMode.Input);

            GpioStatus.Text = "GPIO pin initialized correctly.";

        }
开发者ID:mistryhardik,项目名称:iothandson,代码行数:26,代码来源:MainPage.xaml.cs


示例2: PinInterruptValue

 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="pin">oin the value is for.</param>
 /// <param name="interruptOccurred">True when interrupt occurs, false otherwise.</param>
 /// <param name="edge">Edge that occurred</param>
 /// <param name="currentValue">Current value.</param>
 internal PinInterruptValue(int pin, bool interruptOccurred, GpioPinEdge edge, GpioPinValue currentValue)
 {
     this.Pin = pin;
     this.InterruptOccurred = interruptOccurred;
     this.Edge = edge;
     this.CurrentValue = currentValue;
 }
开发者ID:CaptainBart,项目名称:Windows.Devices.Gpio.Components,代码行数:14,代码来源:InterruptEventArgs.cs


示例3: Write

        public void Write(byte[] data)
        {
            var bits = new GpioPinValue[data.Length * 8];

            for (int i = 0; i < data.Length; i++)
            {
                var datumValues = GetBits(data[i]);
                datumValues.CopyTo(bits, i * 8);
            }

            _csPin.Write(GpioPinValue.Low);
            SyncWaitInterval();

            foreach(var bit in bits)
            {
                _mosiPin.Write(bit);
                _clkPin.Write(GpioPinValue.High);
                SyncWaitInterval();
                _clkPin.Write(GpioPinValue.Low);
                SyncWaitInterval();
            }

            _csPin.Write(GpioPinValue.High);
            SyncWaitInterval();
        }
开发者ID:ajbowen249,项目名称:RasPiLCDSandbox,代码行数:25,代码来源:OsoyooCustomSPI.cs


示例4: SetValue

        public void SetValue(GpioPinValue value)
        {
            if(pin == null)
                throw new Exception("GPIO Pin not initalized!");

            pin.Write(value);
        }
开发者ID:thomasjetzinger,项目名称:smarthomecloud,代码行数:7,代码来源:GPIO.cs


示例5: WriteOutputPinValue

 public void WriteOutputPinValue(int pinNumber, GpioPinValue pinValue)
 {
     foreach (var c in _controls.Where(r => r.PinNumber == pinNumber))
     {
         c.WriteOutputPinValue(pinValue);
     }
 }
开发者ID:valeriob,项目名称:Pi2,代码行数:7,代码来源:SetupGpio.cs


示例6: TurnLEDsOff

 public void TurnLEDsOff()
 {
     greenPinValue = GpioPinValue.High;
     greenPin.Write(greenPinValue);
     redPinValue = GpioPinValue.High;
     redPin.Write(redPinValue);
 }
开发者ID:VantivLabs,项目名称:RaspberryPi.CSharp,代码行数:7,代码来源:CustomGPIOController.cs


示例7: InitGPIO

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

            // Show an error if there is no GPIO controller
            if (mygpio == null)
            {
                buttonPin = null;
                ledPin = null;
                return;
            }
            ledPin = mygpio.OpenPin(LEDPINNBR);
            ledPin.Write(GpioPinValue.Low); //initialize Led to On as wired in active Low config (+3.3-Led-GPIO)
            ledPin.SetDriveMode(GpioPinDriveMode.Output);

            buttonPin = mygpio.OpenPin(BUTTONPINNBR);
            buttonPin.Write(GpioPinValue.High);
            buttonPin.SetDriveMode(GpioPinDriveMode.Output);
            buttonPinValCurrent = buttonPin.Read();
            buttonPin.SetDriveMode(GpioPinDriveMode.Input);
            buttonPinValPrior = GpioPinValue.High;

            Debug.WriteLine("ButtonPin Value at Init: " + buttonPin.Read() + ",      with Pin ID = " + buttonPin.PinNumber);

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

            // Register for the ValueChanged event so our buttonPin_ValueChanged
            // function is called when the button is pressed
            buttonPin.ValueChanged += buttonPressAction;
        }
开发者ID:dettwild,项目名称:ButtonClick2,代码行数:32,代码来源:MainPage.xaml.cs


示例8: InitGPIO

        private void InitGPIO()
        {
            GpioController gpio = null;
            try
            {
                gpio = GpioController.GetDefault();
            }
            catch (Exception e)
            {
                GpioStatus.Text = e.Message;
            }

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

            _pin = gpio.OpenPin(LED_PIN);
            _pinValue = GpioPinValue.High;
            _pin.Write(_pinValue);
            _pin.SetDriveMode(GpioPinDriveMode.Output);

            GpioStatus.Text = "GPIO pin intitialized correctly.";
        }
开发者ID:fr3gu,项目名称:Nascon.Blinky,代码行数:26,代码来源:MainPage.xaml.cs


示例9: PulseIn

        private double PulseIn(GpioPin echoPin, GpioPinValue value)
        {
            var t = Task.Run(() =>
            {
                //Recieve pusle
                while (this.echoPin.Read() != value)
                {
                }
                timeWatcher.Start();

                while (this.echoPin.Read() == value)
                {
                }
                timeWatcher.Stop();
                //Calculating distance
                double distance = timeWatcher.Elapsed.TotalSeconds * 17000;
                return distance;
            });
            bool didComplete = t.Wait(TimeSpan.FromMilliseconds(100));
            if(didComplete)
            {
                return t.Result;
            }
            else
            {
                return 0.0;                
            }
        }
开发者ID:farukc,项目名称:MTPSolution,代码行数:28,代码来源:HCSR04.cs


示例10: CheckNum

        public int CheckNum()
        {
            var inputs = new GpioPinValue[4];
            inputs[0] = irPins[0].Read();
            inputs[1] = irPins[1].Read();
            inputs[2] = irPins[2].Read();
            inputs[3] = irPins[3].Read();
            int returnValue = 0;

            if (inputs[0] == GpioPinValue.High)
            {
                returnValue += 1;
            }
            if (inputs[1] == GpioPinValue.High)
            {
                returnValue += 2;
            }
            if (inputs[2] == GpioPinValue.High)
            {
                returnValue += 4;
            }
            if (inputs[3] == GpioPinValue.High)
            {
                returnValue += 8;
            }

            return returnValue;
        }
开发者ID:Bongorian,项目名称:MSPlatoon1,代码行数:28,代码来源:IrSensor.cs


示例11: Sleep

 public void Sleep()
 {
     if (pin != null)
     {
         pinValue = GpioPinValue.High;
         pin.Write(pinValue);
     }
 }
开发者ID:jamessdixon,项目名称:EjectABed,代码行数:8,代码来源:SingleLight.cs


示例12: Reset

 public void Reset()
 {
     if (pin != null)
     {
         pinValue = GpioPinValue.Low;
         pin.Write(pinValue);
     }
 }
开发者ID:jamessdixon,项目名称:EjectABed,代码行数:8,代码来源:SingleLight.cs


示例13: Led

        public Led(GpioPin pin)
        {
            _pin = pin;

            _pin.SetDriveMode(GpioPinDriveMode.Output);

            _pinValue = GpioPinValue.Low;
            _pin.Write(_pinValue);
        }
开发者ID:teonivalois,项目名称:IoT.CSharp,代码行数:9,代码来源:Led.cs


示例14: AccelStepper

        public AccelStepper(GpioPin motorPinEntity, GpioPin directionPinEntity, GpioPinValue clockwiseVal)
        {
            motorPin = motorPinEntity;
            directionPin = directionPinEntity;
            clockwiseValue = clockwiseVal;

            stopwatch = new Stopwatch();
            stopwatch.Start();
        }
开发者ID:Rbecca,项目名称:samples,代码行数:9,代码来源:AccelStepper.cs


示例15: SignalOutputPin

        public void SignalOutputPin(int pinId, GpioPinValue value)
        {
            if (_pin == null)
            {
                _pin = _gpioController.OpenPin(pinId);
                _pin.SetDriveMode(GpioPinDriveMode.Output);
            }

            _pin.Write(value);
        }
开发者ID:Pavel-Durov,项目名称:pet-feeder,代码行数:10,代码来源:PhisicalBoardService.cs


示例16: BlimkTimer_Tick

 private void BlimkTimer_Tick(object sender, object e)
 {
     this.button.Fill = grayBrush;
     this.blinkTimer.Stop();
     if (bGpioStatus)
     {
         pinValue = GpioPinValue.Low;
         pin.Write(pinValue);
     }
 }
开发者ID:Robotonics,项目名称:iotSampler,代码行数:10,代码来源:MainPage.xaml.cs


示例17: WriteValue

 public void WriteValue(int c, int r, GpioPinValue value)
 {
     try
     {
         matrix[c, r].Write(value);
     }
     catch
     {
         // TODO: Handle this
     }
 }
开发者ID:joakimglysing,项目名称:ProjectKallax,代码行数:11,代码来源:LEDMatrix.cs


示例18: TurnGreen

        public void TurnGreen()
        {
            _redPinValue = GpioPinValue.Low;
            _redPin.Write(_redPinValue);

            _greenPinValue = GpioPinValue.High;
            _greenPin.Write(_greenPinValue);

            _bluePinValue = GpioPinValue.Low;
            _bluePin.Write(_bluePinValue);
        }
开发者ID:teonivalois,项目名称:IoT.CSharp,代码行数:11,代码来源:RGBLed.cs


示例19: InitializeGPIO

        private async void InitializeGPIO()
        {
            try
            {
                GpioController controller = GpioController.GetDefault();

                if (null != controller)
                {
                    // Create and initialize color sensor instance
                    _colorSensor = new TCS34725(RGB_LED_PIN);
                    await _colorSensor.Initialize();
                    _colorSensor.LedState = TCS34725.eLedState.Off;

                    // Setup button pin
                    _gpioPushbutton = controller.OpenPin(PUSH_BUTTON_PIN);
                    _gpioPushbutton.DebounceTimeout = TimeSpan.FromMilliseconds(100); // 100 ms
                    _gpioPushbutton.SetDriveMode(GpioPinDriveMode.Input);
                    _gpioPushbutton.ValueChanged += gpioPushbutton_ValueChanged;

                    // Setup LEDs
                    // Red
                    _gpioRedLED = controller.OpenPin(RED_LED_PIN);
                    _gpioRedLED.SetDriveMode(GpioPinDriveMode.Output);
                    _pinValRed = SetGpioPinState(_gpioRedLED, GpioPinValue.High); // HIGH == ON

                    _timerRed = new DispatcherTimer();
                    _timerRed.Tick += timerRed_Tick;

                    // Green
                    _gpioGreenLED = controller.OpenPin(GREEN_LED_PIN);
                    _gpioGreenLED.SetDriveMode(GpioPinDriveMode.Output);
                    _pinValGreen = SetGpioPinState(_gpioGreenLED, GpioPinValue.High); // HIGH == ON

                    _timerGreen = new DispatcherTimer();
                    _timerGreen.Tick += timerGreen_Tick;

                    // Blue
                    _gpioBlueLED = controller.OpenPin(BLUE_LED_PIN);
                    _gpioBlueLED.SetDriveMode(GpioPinDriveMode.Output);
                    _pinValBlue = SetGpioPinState(_gpioBlueLED, GpioPinValue.High); // HIGH == ON

                    _timerBlue = new DispatcherTimer();
                    _timerBlue.Tick += timerBlue_Tick;

                    _isInitialized = true;
                    Debug.WriteLine("All pins initialized");
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }
开发者ID:acklenx,项目名称:TrichromySaturation,代码行数:53,代码来源:MainPage.xaml.cs


示例20: InitGPIO

 private void InitGPIO()
 {
     var gpio = GpioController.GetDefault();
     if (gpio == null)
     {
         throw new Exception("Gpio expected on this device");
     }
     ledPin = gpio.OpenPin(ledPinNumber);
     ledPin.SetDriveMode(GpioPinDriveMode.Output);
     ledPin.Write(GpioPinValue.Low);
     ledVal = GpioPinValue.Low;
 }
开发者ID:farukc,项目名称:MTPSolution,代码行数:12,代码来源:App.xaml.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# GpuMat类代码示例发布时间:2022-05-24
下一篇:
C# GpPen类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap