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

C# Gpio.GpioPinValueChangedEventArgs类代码示例

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

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



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

示例1: buttonPin_ValueChanged

        private void buttonPin_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs e)
        {
            // toggle the state of the LED every time the button is pressed
            if (e.Edge == GpioPinEdge.FallingEdge)
            {
                ledPinValue = (ledPinValue == GpioPinValue.Low) ?
                    GpioPinValue.High : GpioPinValue.Low;
                ledPin.Write(ledPinValue);
            }

            // need to invoke UI updates on the UI thread because this event
            // handler gets invoked on a separate thread.
            var task = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => {
                if (e.Edge == GpioPinEdge.FallingEdge)
                {
                    ledEllipse.Fill = (ledPinValue == GpioPinValue.Low) ? 
                        redBrush : grayBrush;
                    GpioStatus.Text = "Button Pressed";
                }
                else
                {
                    GpioStatus.Text = "Button Released";
                }
            });
        }
开发者ID:EBailey67,项目名称:samples,代码行数:25,代码来源:MainPage.xaml.cs


示例2: InputPin_ValueChanged

 private void InputPin_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args)
 {
     if(args.Edge == GpioPinEdge.FallingEdge)
     {
         AccumulatedTotal = AccumulatedTotal + LitersPerPulse;
     }
 }
开发者ID:AerialBreakSoftware,项目名称:Win10RaspberrySprinkle,代码行数:7,代码来源:FlowMeter.cs


示例3: PinPIR_ValueChanged

        /// <summary>
        /// Event called when GPIO PIN 16 changes (PIR signal)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private async void PinPIR_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args)
        {
            //simple guard to prevent it from triggering this function again before it's compelted the first time - one sound at a time please
            if (IsPlaying)
                return;
            else
                IsPlaying = true;
            try
            {
                await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                async () =>
                {
                  PIRStatus.Text = "New PIR pin value: " + args.Edge.ToString();
                 //SoundPlayer mantra = new SoundPlayer(@"C:\WINDOWS\Media\mantra.wav");
                 SoundPlayer mantra = new SoundPlayer(Resource1.mantra);

                  mantra.Play();
                    
                   });
            }
            catch (Exception ex)
            {
                await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                () =>
                {
                    PIRStatus.Text = "PIR Error: " + ex.Message;
                });
            }
            finally
            {
                isPlaying = false;
            }

            return;
        }
开发者ID:Dreitser,项目名称:Mepitate,代码行数:40,代码来源:MainPage.xaml.cs


示例4: Pin_ValueChanged

 private void Pin_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args)
 {
     if (pin.Read() == GpioPinValue.High)
     {
         int bla;
     }
 }
开发者ID:jingleheimerschmidt,项目名称:ThreatDetector,代码行数:7,代码来源:MainPage.xaml.cs


示例5: buttonPin_ValueChanged

        private void buttonPin_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs e)
        {
            //// toggle the state of the LED every time the button is pressed
            //if (e.Edge == GpioPinEdge.FallingEdge)
            //{
            //    ledPinValue = (ledPinValue == GpioPinValue.Low) ?
            //        GpioPinValue.High : GpioPinValue.Low;
            //    ledPin.Write(ledPinValue);
            //} 

            // need to invoke UI updates on the UI thread because this event
            // handler gets invoked on a separate thread.
            var task = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => {
                if (buttonPin.Read() == GpioPinValue.High)
                {
                    ledPinValue = GpioPinValue.High;
                    ledEllipse.Fill = grayBrush;
                    ledPin.Write(ledPinValue);
                    GpioStatus.Text = "No Mouse...";
                    SendMessageToIoTHubAsync(1);
                }
                if (buttonPin.Read() == GpioPinValue.Low)
                {
                    ledPinValue = GpioPinValue.Low;
                    ledEllipse.Fill = redBrush;
                    ledPin.Write(ledPinValue);
                    GpioStatus.Text = "Dead Mouse...";
                    SendMessageToIoTHubAsync(2);
                }
            });
        }
开发者ID:jefking,项目名称:MouseTrapp,代码行数:31,代码来源:MainPage.xaml.cs


示例6: pin_ValueChanged

        private async void pin_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args)
        {
                if (args.Edge.CompareTo(GpioPinEdge.RisingEdge) == 0)
                {
                    //Motion Detected UI
                    UiAlert();

                    //Create JSON payload
                    var json = string.Format("{{sensor:Motion,  room:MsConfRoom1,  utc:{0}}}", DateTime.UtcNow.ToString("MM/dd/yyyy_HH:mm:ss"));
                    var data = new ASCIIEncoding().GetBytes(json);

                    //POST Data
                    string url = "https://rrpiot.azurewebsites.net/SensorData";
                    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                    request.Method = "POST";
                    request.ContentType = "application/json";
                    using (Stream myStream = await request.GetRequestStreamAsync())
                    {
                        myStream.Write(data, 0, data.Length);
                    }
                    await request.GetResponseAsync();
                }
                else
                {
                    //Display No Motion Detected UI
                    UiNoMotion();
                }

        }
开发者ID:RandyPatterson,项目名称:MotionDetector,代码行数:29,代码来源:MainPage.xaml.cs


示例7: MotionSensorPin_ValueChanged

 private void MotionSensorPin_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args)
 {
     if (OnChanged != null)
     {
         OnChanged(this, args);
     }
 }
开发者ID:jadeiceman,项目名称:securitysystem-1,代码行数:7,代码来源:MotionSensor.cs


示例8: M_cadence_sensor_ValueChanged

        private void M_cadence_sensor_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args)
        {
            if (args.Edge == GpioPinEdge.RisingEdge)
            {
                Debug.WriteLine("{0} Pedal Sensor", DateTime.Now);

                //TimeSpan cadence_interval = DateTime.Now - m_last_cadence;

                //m_last_cadence = DateTime.Now;

                m_cadence_blips.Enqueue(DateTime.Now);

                if (m_cadence_blips.Count > 5)
                {
                    m_cadence_blips.Dequeue();
                }

                if (m_cadence_blips.Count > 2)
                {

                    double cadence_interval = (m_cadence_blips.Last() - m_cadence_blips.First()).TotalSeconds / m_cadence_blips.Count;

                    Debug.WriteLine("Interval = {0} (count = {1})", cadence_interval, m_cadence_blips.Count);

                    RPM = (int)Math.Floor(30 / cadence_interval); //its 60 divided by 2 due to the 2 magnets
                }

            }
        }
开发者ID:derektaprell,项目名称:PiBike2,代码行数:29,代码来源:C7ZL_sensors.cs


示例9: ValueChangedHandler

        private void ValueChangedHandler(GpioPin sender, GpioPinValueChangedEventArgs args)
        {
            var pinNumber = sender.PinNumber;
            var gpioPinValue = sender.Read();
            Debug.WriteLine("Pin {0} changed to {1}", pinNumber, gpioPinValue);

            if (pinNumber == TiltSensorPin)
            {
                _halper.DishwasherTilt(gpioPinValue == GpioPinValue.High);
                var currentStatus = _halper.Get().CurrentStatus;
                if (currentStatus == DishwasherStatus.Clean && gpioPinValue == GpioPinValue.High)
                {
                    ThreadPoolTimer.CreatePeriodicTimer(Timer_Tick, TimeSpan.FromMilliseconds(10000));
                }
                return;
            }

            var tiltSensorValue = _gpioSensors[TiltSensorPin].Read();
            if (gpioPinValue == GpioPinValue.High)
            {
                if (pinNumber == CleanLightPin)
                {
                    _halper.EndDishwasherRun();
                }
                else if (tiltSensorValue == GpioPinValue.Low && _pinToCycleTypeMap.ContainsKey(pinNumber))
                {
                    _halper.StartDishwasherRun(_pinToCycleTypeMap[pinNumber]);
                }
            }
        }
开发者ID:ChrisMancini,项目名称:DishwasherMonitor,代码行数:30,代码来源:GpioMonitor.cs


示例10: handleButton

 private void handleButton(GpioPin sender, GpioPinValueChangedEventArgs args)
 {
     Debug.WriteLine("Value Change on pin:" + sender.PinNumber + " : " + args.Edge);
     TelemetryManager.WriteTelemetryEvent("Action_PhysicalButton");
     if (args.Edge == GpioPinEdge.RisingEdge)
     {
         switch (this.buttonPins[sender.PinNumber])
         {
             case InputAction.NextChannel:
                 this.playlistManager.NextTrack();
                 break;
             case InputAction.PreviousChannel:
                 this.playlistManager.PreviousTrack();
                 break;
             case InputAction.VolumeUp:
                 this.playbackManager.Volume += 0.1;
                 break;
             case InputAction.VolumeDown:
                 this.playbackManager.Volume -= 0.1;
                 break;
             case InputAction.Sleep:
                 if (PowerState.Powered == this.powerManager.PowerState)
                 {
                     this.powerManager.PowerState = PowerState.Standby;
                 }
                 else
                 {
                     this.powerManager.PowerState = PowerState.Powered;
                 }
                 break;
         }
     }
 }
开发者ID:codekaizen,项目名称:internetradio,代码行数:33,代码来源:GpioInterfaceManager.cs


示例11: Pin_ValueChanged

        private void Pin_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs e)
        {
            var edge = e.Edge;
            if ((pressedValue == GpioPinValue.High) && (edge == GpioPinEdge.RisingEdge))
            {
                isPressed = true;
            }
            else if ((pressedValue == GpioPinValue.Low) && (edge == GpioPinEdge.FallingEdge))
            {
                isPressed = true;
            }
            else
            {
                isPressed = false;
            }

            // Notify
            if (isPressed)
            {
                pressedEvent.Raise(owner, EmptyEventArgs.Instance);
                if (ClickMode == ButtonClickMode.Press)
                {
                    clickEvent.Raise(owner, EmptyEventArgs.Instance);
                }
            }
            else
            {
                releasedEvent.Raise(owner, EmptyEventArgs.Instance);
                if (ClickMode == ButtonClickMode.Release)
                {
                    clickEvent.Raise(owner, EmptyEventArgs.Instance);
                }
            }
        }
开发者ID:msherburne,项目名称:iot-devices,代码行数:34,代码来源:PushButtonHelper.cs


示例12: OverCurrentPin_ValueChanged

        private void OverCurrentPin_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args)
        {
            bool state_changed = false;
            GpioPinValue curr_pin_value = _pin.Read();

            // Detect a change in pin state
            if ( (_last_pin_value == INACTIVE &&  curr_pin_value == ACTIVE) ||
                 (_last_pin_value == ACTIVE && curr_pin_value == INACTIVE) )
            {
                state_changed = true;
            }

            _last_pin_value = curr_pin_value;

            if (curr_pin_value == ACTIVE)
            {
                _state = DETECT_STATE;
            }
            else
            {
                _state = NO_DETECT_STATE;
            }

            // Send an alert only on a change
            if (state_changed)
            {                
                foreach (var callback in _alert_callbacks)
                {
                    callback("overcurrent:" + _id + ":" + _state);
                }
            }

        }
开发者ID:micklab,项目名称:isavewater,代码行数:33,代码来源:overcurrent.cs


示例13: ButtonpinValueChanged

 private void ButtonpinValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args)
 {
     // Just shutdown on one edge
     if (args.Edge == GpioPinEdge.RisingEdge)
     {
         ShutdownManager.BeginShutdown(ShutdownKind.Shutdown, TimeSpan.FromSeconds(0.5));
     }
 }
开发者ID:paul-charlton,项目名称:iot-trials,代码行数:8,代码来源:StartupTask.cs


示例14: irqPin_ValueChanged

 private void irqPin_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args)
 {
     if (args.Edge != GpioPinEdge.FallingEdge) return;
     _logger.Trace("IRQ Event Received!");
     RegisterContainer.StatusRegister.Load();
     Interrupted?.Invoke(this, new InterruptedEventArgs { StatusRegister = RegisterContainer.StatusRegister });
     _irqPin.Write(GpioPinValue.High);
 }
开发者ID:RodneyWimberly,项目名称:Windows.Devices.Radios.nRF24L01P,代码行数:8,代码来源:Radio.cs


示例15: PirSensor_OnChanged

 /*******************************************************************************************
 * PRIVATE METHODS
 ********************************************************************************************/
 private async void PirSensor_OnChanged(object sender, GpioPinValueChangedEventArgs e)
 {
     //Start the timer for the duration of motion
     if (e.Edge == GpioPinEdge.FallingEdge)
     {
         await TakePhotoAsync();
     }
 }
开发者ID:jadeiceman,项目名称:securitysystem-1,代码行数:11,代码来源:UsbCamera.cs


示例16: Interrupt

        private void Interrupt(GpioPin sender, GpioPinValueChangedEventArgs args)
        {
            if (device == null)
                return;

            int interruptStatus = readWriteHelper.ReadByte(Constants.IntStatus);
            if ((interruptStatus & 0x10) != 0)
                readWriteHelper.WriteByte(Constants.UserCtrl, 0x44); // reset and enable fifo

            if ((interruptStatus & 0x1) == 0)
                return;

            var ea = new MpuSensorEventArgs
            {
                Status = (byte)interruptStatus,
                SamplePeriod = 0.02f
            };

            var l = new List<MpuSensorValue>();

            int count = readWriteHelper.ReadWord(Constants.FifoCount);

            while (count >= Constants.SensorBytes)
            {
                var data = readWriteHelper.ReadBytes(Constants.FifoRW, Constants.SensorBytes);
                count -= Constants.SensorBytes;

                var xa = (short)(data[0] << 8 | data[1]);
                var ya = (short)(data[2] << 8 | data[3]);
                var za = (short)(data[4] << 8 | data[5]);

                var xg = (short)(data[6] << 8 | data[7]);
                var yg = (short)(data[8] << 8 | data[9]);
                var zg = (short)(data[10] << 8 | data[11]);

                var sv = new MpuSensorValue
                {
                    AccelerationX = xa / (float)16384,
                    AccelerationY = ya / (float)16384,
                    AccelerationZ = za / (float)16384,
                    GyroX = xg / (float)131,
                    GyroY = yg / (float)131,
                    GyroZ = zg / (float)131
                };

                l.Add(sv);
            }

            ea.Values = l.ToArray();

            if (SensorInterruptEvent == null)
                return;

            if (ea.Values.Length > 0)
                SensorInterruptEvent(this, ea);
        }
开发者ID:KonstantinKolesnik,项目名称:SmartHub,代码行数:56,代码来源:Mpu6050.cs


示例17: FlowPin_ValueChanged

        private void FlowPin_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args)
        {
            GpioPinValue state = _pin.Read();

            if (_last_flow_state == GpioPinValue.Low && state == GpioPinValue.High)
            {
                _low_to_high_count++;
            }
            _last_flow_state = state;
        }
开发者ID:micklab,项目名称:isavewater,代码行数:10,代码来源:flow.cs


示例18: OnValueChanged

        private void OnValueChanged( GpioPin sender, GpioPinValueChangedEventArgs args )
        {
            EventHandler eventToFire = args.Edge == GpioPinEdge.FallingEdge
                ? this.Pushed
                : this.Released;

            if( eventToFire != null )
            {
                eventToFire( this, new EventArgs() );
            }
        }
开发者ID:balassy,项目名称:iot-interaction-pack,代码行数:11,代码来源:PushButton.cs


示例19: _forwardButton_ValueChanged

 private void _forwardButton_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args)
 {
     if (forwardButton.Read() == GpioPinValue.Low)
     {
         currentPulseWidth = ForwardPulseWidth;
     }
     else
     {
         currentPulseWidth = 0;
     }
 }
开发者ID:EBailey67,项目名称:samples,代码行数:11,代码来源:StartupTask.cs


示例20: CheckParking

 private void CheckParking(GpioPin sender, GpioPinValueChangedEventArgs args)
 {
     if (switch_right.Read() == GpioPinValue.High && switch_left.Read() == GpioPinValue.High) //When both switches are pressed
     {
         led_blue.Write(GpioPinValue.Low); //Turn on blue LED
     }
     else
     {
         led_blue.Write(GpioPinValue.High); //Turn off blue LED
     }
 }
开发者ID:mderoode,项目名称:OVCClient,代码行数:11,代码来源:HomeStation.xaml.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# I2c.I2cConnectionSettings类代码示例发布时间:2022-05-26
下一篇:
C# Gpio.GpioPin类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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