public void Initialize() { _pinConfiguration = Pin.Input().OnStatusChanged(s => { RaiseOnPressedEvent(null); }); _connection = new GpioConnection(_pinConfiguration); }
public clsDialHookListener(InputPinConfiguration HookInput, InputPinConfiguration PulseDialInput) { HookIO = HookInput; DialIO = PulseDialInput; var config = new GpioConnectionSettings() { PollInterval = 5, }; GPIO = new GpioConnection(config,HookIO,DialIO); GPIO.PinStatusChanged += (object sender, PinStatusEventArgs e) => { //switch change event handler if (e.Configuration.Pin == HookIO.Pin) { if (GPIO[HookIO]) HookPulseCount++; HookWaitEvent.Set(); } else if (e.Configuration.Pin == DialIO.Pin) { if (GPIO[DialIO]) { DialPulseCount++; DialWaitEvent.Set(); } } else { Console.WriteLine("Huh?! Wrong IO: "+e.Configuration.Name); } }; DialListenerThread = new Thread(ListenDial) { Name = "DialListener", IsBackground = true, }; DialListenerThread.Start(); HookListenerThread = new Thread(ListenHookSwitch) { Name = "HookListener", IsBackground = true, }; HookListenerThread.Start(); }
public FlowMeter(InputPinConfiguration pin) { pinChange = lastPinChange; flowSensorPin = pin; try { cn = new GpioConnection(pin); cn.PinStatusChanged += PinStatusChanged; } catch (Exception ex) { Console.WriteLine("Failed To Create FlowController"); Console.WriteLine(ex.ToString()); } }
/// <summary> /// Configures the specified input pin as a switch. /// </summary> /// <param name="pin">The pin.</param> /// <returns>The pin configuration</returns> public static SwitchInputPinConfiguration Switch(this InputPinConfiguration pin) { return(new SwitchInputPinConfiguration(pin)); }