public void SetEdge(Cpu.Pin pin, Port.InterruptMode interruptMode) { String interrupt = "none"; Console.WriteLine(interruptMode); switch (interruptMode) { case Port.InterruptMode.InterruptNone: break; case Port.InterruptMode.InterruptEdgeLow: interrupt = "falling"; break; case Port.InterruptMode.InterruptEdgeLevelLow: throw new Exception(); case Port.InterruptMode.InterruptEdgeLevelHigh: throw new Exception(); case Port.InterruptMode.InterruptEdgeHigh: interrupt = "rising"; break; case Port.InterruptMode.InterruptEdgeBoth: interrupt = "both"; break; } File.WriteAllText(GPIO_PATH + "gpio" + ((int)pin) + "/edge", interrupt.ToLower()); }
private SpotDigitalInterrupt(Cpu.Pin pin, string name = null, Port.ResistorMode internalResistorMode = Port.ResistorMode.Disabled, Port.InterruptMode interruptMode = Port.InterruptMode.InterruptNone, int debounceMilliseconds = -1) { _interrupt = new InterruptPort(pin, false, internalResistorMode, interruptMode); _interrupt.OnInterrupt += ProxyToUserHandler; _name = name ?? "DigitalInterrupt-" + pin; _debounceMilliseconds = debounceMilliseconds; }
/// <summary> /// Constructor /// </summary> /// <param name="pin">Pin connected to the PIR</param> /// <param name="glitchFilter">Input debouncing filter (default is true)</param> /// <param name="resistor">The resistor mode that establishes a default state for the port (default is Disabled)</param> /// <param name="interrupt">Defines the type of edge-change triggering the interrupt (default is InterruptEdgeBoth)</param> /// <param name="enabled">Intial Pir enable state</param> public Pir(Cpu.Pin pin, bool glitchFilter = true, Port.ResistorMode resistor = Port.ResistorMode.Disabled, Port.InterruptMode interrupt = Port.InterruptMode.InterruptEdgeBoth, bool enabled = true) { this.intPort = new InterruptPort(pin, glitchFilter, resistor, interrupt); this.intPort.OnInterrupt += new NativeEventHandler(intPort_OnInterrupt); this.Enabled = enabled; }
/// <summary>Constructs a new button definition</summary> /// <remarks> /// The resistor mode can influence the detection of an up/down press. /// Setting it incorrectly can cause unexpected results. Check with the /// hardware design schematics or documentation for best results. /// </remarks> /// <param name="Button">The button value to assign to the GPIO pin.</param> /// <param name="AutoRepeat">Boolean flag to indicate if this button should auto-repeat</param> /// <param name="ResistorMode"> /// Resistor mode to configure for the GPIO pin [may be ignored on hardware that /// does not support dynamic configuration ] /// </param> /// <param name="InterruptMode"> /// Interrupt mode to configure for the GPIO pin [may be ignored on hardware that /// does not support dynamic configuration ] /// </param> public ButtonDefinition(Microsoft.SPOT.Hardware.Button Button , bool AutoRepeat , Port.ResistorMode ResistorMode , Port.InterruptMode InterruptMode ) { this._Button = Button; this._Pin = Pin; this._AutoRepeat = AutoRepeat; this._ResistorMode = ResistorMode; this._InterruptMode = InterruptMode; }
/// <summary> /// The interrupt fires on a high edge when the button is pressed by default. /// If using a button other than the built-in one, you should connect pull-down resistors to the switch. /// Lady Ada has an excellent tutorial on this subject: http://www.ladyada.net/learn/arduino/lesson5.html /// </summary> /// <param name="pin">A digital pin connected to the actual push-button.</param> /// <param name="intMode">Defines the type of edge-change triggering the interrupt.</param> /// <param name="target">The event handler called when an interrupt occurs.</param> /// <param name="resistorMode">Internal pullup resistor configuration</param> /// <param name="glitchFilter">Input debouncing filter</param> public PushButton( Cpu.Pin pin, Port.InterruptMode intMode = Port.InterruptMode.InterruptEdgeBoth, NativeEventHandler target = null, Port.ResistorMode resistorMode = Port.ResistorMode.Disabled, bool glitchFilter = true ) { Input = new InterruptPort(pin, glitchFilter, resistorMode, intMode); if (target == null) { Input.OnInterrupt += InternalInterruptHandler; } else { Input.OnInterrupt += target; } Input.EnableInterrupt(); }
public ButtonPad(GPIOButtonInputProvider sink, Button button, Cpu.Pin pin, Port.InterruptMode mode) { _sink = sink; _button = button; _buttonDevice = InputManager.CurrentInputManager.ButtonDevice; _port = new InterruptPort(pin, true, Port.ResistorMode.PullUp, mode); _port.OnInterrupt += new NativeEventHandler(this.Interrupt); }