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


C# GpioPinValue类代码示例

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


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


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