本文整理汇总了C#中Windows.Devices.Gpio.GpioPinValueChangedEventArgs类的典型用法代码示例。如果您正苦于以下问题:C# GpioPinValueChangedEventArgs类的具体用法?C# GpioPinValueChangedEventArgs怎么用?C# GpioPinValueChangedEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GpioPinValueChangedEventArgs类属于Windows.Devices.Gpio命名空间,在下文中一共展示了GpioPinValueChangedEventArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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";
}
});
}
示例2: InputPin_ValueChanged
private void InputPin_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args)
{
if(args.Edge == GpioPinEdge.FallingEdge)
{
AccumulatedTotal = AccumulatedTotal + LitersPerPulse;
}
}
示例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;
}
示例4: Pin_ValueChanged
private void Pin_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args)
{
if (pin.Read() == GpioPinValue.High)
{
int bla;
}
}
示例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);
}
});
}
示例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();
}
}
示例7: MotionSensorPin_ValueChanged
private void MotionSensorPin_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args)
{
if (OnChanged != null)
{
OnChanged(this, args);
}
}
示例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
}
}
}
示例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]);
}
}
}
示例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;
}
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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));
}
}
示例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);
}
示例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();
}
}