コード例 #1
0
ファイル: StopSwitch.cs プロジェクト: manf88/ACHIM
 public void Initialize()
 {
     _pinConfiguration = Pin.Input().OnStatusChanged(s => {
         RaiseOnPressedEvent(null);
     });
     _connection = new GpioConnection(_pinConfiguration);
 }
コード例 #2
0
        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();
        }
コード例 #3
0
ファイル: RPi.cs プロジェクト: Zelxin/RPiKeg
        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());
            }


        }
コード例 #4
0
 /// <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));
 }