/// <summary> /// A sensor is an input device /// We have a pull resister on our physical board per sensor /// Our physical board connection has a digital read of HIGH on an open circuit, /// we detect both rising and failling edges for our sensors /// </summary> private void Initialize() { _gpioPin.PinMode = GpioPinDriveMode.Input; _gpioPin.InputPullMode = GpioPinResistorPullMode.Off; _gpioPin.RegisterInterruptCallback(EdgeDetection.RisingAndFallingEdges, OnValueChanged); _value = Tripped; }
/// <summary> /// Initializes a new instance of the <see cref="Button"/> class. /// </summary> /// <param name="gpioPin">The gpio pin.</param> public Button(GpioPin gpioPin) { _gpioPin = gpioPin; _gpioPin.InputPullMode = GpioPinResistorPullMode.PullDown; _gpioPin.PinMode = GpioPinDriveMode.Input; _gpioPin.RegisterInterruptCallback(EdgeDetection.RisingAndFallingEdges, HandleInterrupt); }
/// <summary> /// Initializes a new instance of the <see cref="Button"/> class. /// </summary> /// <param name="gpioPin">The gpio pin.</param> public Button(GpioPin gpioPin, ulong interruptTime = 100) { Pin = gpioPin; Pin.InputPullMode = GpioPinResistorPullMode.PullDown; Pin.PinMode = GpioPinDriveMode.Input; Pin.RegisterInterruptCallback(EdgeDetection.RisingAndFallingEdges, HandleInterrupt); InterruptTime = interruptTime; }
public void Init() { var controller = GpioController.Instance; pin = controller.Pins.First(p => p.PinNumber == _pinNumber); if (pin.Capabilities.All(c => c != PinCapability.GP)) { return; } pin.PinMode = GpioPinDriveMode.Input; pin.RegisterInterruptCallback(EdgeDetection.FallingEdge, () => { _doOnChange(); Thread.Sleep(300); }); }
/// <summary> /// Initializes a new instance of the <see cref="LogicProbe"/> class. /// </summary> /// <param name="inputPin">The input pin.</param> public LogicProbe(GpioPin inputPin) { InputPin = inputPin; InputPin.PinMode = GpioPinDriveMode.Input; InputPin.InputPullMode = GpioPinResistorPullMode.PullUp; InputPin.RegisterInterruptCallback(EdgeDetection.RisingAndFallingEdges, () => { if (Timer.IsRunning == false) { return; } var value = InputPin.Read(); var elapsed = Timer.ElapsedMicroseconds; var data = new ProbeDataEventArgs(elapsed, value); ProbeDataAvailable?.Invoke(this, data); }); }
public void Init() { _forwardPin.PinMode = GpioPinDriveMode.Output; _backwardPin.PinMode = GpioPinDriveMode.Output; // As we have a bit too much power for our motors, we set the pwm to 500 max but limit the range to 255 max _pwmPin.StartSoftPwm(0, 500); //_pwmPin.PinMode = GpioPinDriveMode.Output; //_pwmPin.PinMode = GpioPinDriveMode.PwmOutput; //_pwmPin.PwmMode = PwmMode.Balanced; SetSpeed(0); _sensorPin.PinMode = GpioPinDriveMode.Input; _sensorPin.InputPullMode = GpioPinResistorPullMode.PullUp; _sensorPin.RegisterInterruptCallback(EdgeDetection.RisingAndFallingEdges, this.SensorInterupt); }
/// <summary> /// Enables the sensor, and listens for motion detection /// </summary> /// <param name="sensorPin">The GPIO pin of the PIR Sensor</param> public PirSensor(GpioPin sensorPin) { sensorPin.PinMode = GpioPinDriveMode.Input; sensorPin.RegisterInterruptCallback(EdgeDetection.FallingEdge, () => MotionDetected.Invoke(this, EventArgs.Empty)); }
public void RegisterISRCallback(Action callBack) => GpioPin.RegisterInterruptCallback( EdgeDetection.FallingEdge, callBack.Invoke);
/// <summary> /// Momentary Push Button is an input device /// We have a pull resister on our physical board /// Our physical board connection has a digital read of HIGH on an open circuit, so on /// button press we detect on failling edge (to LOW) /// </summary> private void Initialize() { _gpioPin.PinMode = GpioPinDriveMode.Input; _gpioPin.InputPullMode = GpioPinResistorPullMode.Off; _gpioPin.RegisterInterruptCallback(EdgeDetection.FallingEdge, OnPress); }
private void Initialize() { gpioPin.InputPullMode = GpioPinResistorPullMode.PullDown; gpioPin.PinMode = GpioPinDriveMode.Input; gpioPin.RegisterInterruptCallback(EdgeDetection.RisingAndFallingEdges, OnClick); }