public PulseFeedback(GpioController gpioController, int pulsePinNumber, int echoPinNumber, PulseFeedbackMode mode) { if (!(gpioController.Provider is Gpio.Provider.GpioControllerApiWrapper p)) { throw new NotSupportedException(); } this.DisableInterrupts = false; this.Timeout = TimeSpan.FromMilliseconds(100); this.PulseLength = TimeSpan.FromMilliseconds(20); this.PulsePinValue = GpioPinValue.High; this.EchoPinValue = GpioPinValue.High; this.PulsePinDriveMode = GpioPinDriveMode.Input; this.EchoPinDriveMode = GpioPinDriveMode.Input; this.mode = mode; this.gpioApi = p.Api.Implementation; this.pulsePinNumber = pulsePinNumber; this.echoPinNumber = echoPinNumber; this.pulsePin = gpioController.OpenPin(pulsePinNumber); if (this.pulsePinNumber != this.echoPinNumber) { this.echoPin = gpioController.OpenPin(echoPinNumber); } this.pulsePin.SetDriveMode(GpioPinDriveMode.Input); this.echoPin?.SetDriveMode(GpioPinDriveMode.Input); }
public PulseFeedback(GpioPin pulsePin, GpioPin echoPin, PulseFeedbackMode mode) { this.DisableInterrupts = false; this.Timeout = TimeSpan.FromMilliseconds(100); this.PulseLength = TimeSpan.FromMilliseconds(20); this.PulseValue = GpioPinValue.High; this.EchoValue = GpioPinValue.High; this.mode = mode; this.pulsePin = pulsePin; this.echoPin = echoPin; this.pulsePinNumber = pulsePin.PinNumber; this.echoPinNumber = echoPin != null ? echoPin.PinNumber : -1; if (mode == PulseFeedbackMode.DrainDuration) { if (this.echoPin != null || this.pulsePin == null) { throw new ArgumentException(); } } else { if (this.echoPin == null || this.pulsePin == null) { throw new ArgumentException(); } } this.pulsePin.SetDriveMode(GpioPinDriveMode.Input); this.echoPin?.SetDriveMode(GpioPinDriveMode.Input); }
public PulseFeedback(GpioController gpioController, int pinNumber, PulseFeedbackMode mode) : this(gpioController, pinNumber, pinNumber, mode) { }
public PulseFeedback(int pulsePinNumber, int echoPinNumber, PulseFeedbackMode mode) : this(GpioController.GetDefault(), pulsePinNumber, echoPinNumber, mode) { }
public PulseFeedback(GpioPin pin, PulseFeedbackMode mode) : this(pin, null, mode) { }