Inheritance: NativeEventDispatcher
コード例 #1
0
ファイル: RelayPort.cs プロジェクト: mbaldini/NovaOS
 public RelayPort(Cpu.Pin pin, bool initialState, bool glitchFilter, Port.ResistorMode resistor, int timeout)
     : base(pin, initialState, glitchFilter, resistor)
 {
     currentstate = initialState;
     relayThread = new Thread(new ThreadStart(RelayLoop));
     relayThread.Start();
 }
コード例 #2
0
        public AnalogInputPin (Cpu.AnalogChannel pin, double updateFrequency = DefaultUpdateFrequency)
            : base (updateFrequency)
		{
            input = new AnalogInput (pin, -1);

            var initialValue = input.Read ();
            
            Analog = AddPort ("Analog", Units.Ratio, initialValue);
        }
コード例 #3
0
ファイル: Switch.cs プロジェクト: VIDGuide/PandaPinball
        public Switch(string switchName, FEZ_Pin.Interrupt IOport, string downScript, string upScript, Port.InterruptMode ActivateState)
        {
            SwitchName = switchName;
            IOPort = IOport;
            DownScript = downScript;
            UpScript = upScript;

            InterruptPort IntButton = new InterruptPort((Cpu.Pin)IOPort, false, Port.ResistorMode.PullUp, ActivateState);
            IntButton.OnInterrupt += new NativeEventHandler(this.Press);
        }
コード例 #4
0
            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);
            }
コード例 #5
0
        public DigitalInputPin (Cpu.Pin pin, bool glitchFilter = false)
		{
            port = new InterruptPort (pin, glitchFilter, HWPort.ResistorMode.Disabled, HWPort.InterruptMode.InterruptEdgeBoth);

            var initialValue = port.Read () ? 1 : 0;
            
            Output = AddPort ("Output", Units.Digital, initialValue);

            port.OnInterrupt += port_OnInterrupt;
		}
コード例 #6
0
ファイル: Ultrasonic.cs プロジェクト: ppatierno/uplibrary
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="pin">Pin connected to the Ultrasonic sensor</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="period">Period for distance measure</param>
        public Ultrasonic(Cpu.Pin pin,
            bool glitchFilter = true,
            Port.ResistorMode resistor = Port.ResistorMode.Disabled,
            int period = 5000)
        {
            this.trPort = new TristatePort(pin, false, glitchFilter, resistor);
            this.period = period;

            // set duetime as period
            this.timer = new Timer(DistanceMeasureCallback, null, this.period, this.period);
        }
コード例 #7
0
ファイル: Pir.cs プロジェクト: ppatierno/uplibrary
        /// <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;
        }
コード例 #8
0
ファイル: PushButton.cs プロジェクト: ltj/ixdlib
        /// <summary>
        /// PushButton constructor.
        /// </summary>
        /// <param name="pin">GPIO input pin</param>
        /// <param name="callback">Callback delegate</param>
        /// <param name="resmode">Resistor mode</param>
        public PushButton(Cpu.Pin pin, NativeEventHandler callback, Port.ResistorMode resmode)
        {
            Port.InterruptMode imode = resmode == Port.ResistorMode.PullUp ?
                Port.InterruptMode.InterruptEdgeLow : Port.InterruptMode.InterruptEdgeHigh;
            m_interruptPort = new InterruptPort(pin, true, resmode, imode);

            if (callback != null) {
                m_interruptPort.OnInterrupt += callback;
            }
            // default behavior is to always clear interrupt
            m_interruptPort.OnInterrupt += new NativeEventHandler((uint port, uint state, DateTime time) => {
                m_interruptPort.ClearInterrupt();
            });
        }
コード例 #9
0
        private float temp; // Temperature

        #endregion Fields

        #region Constructors

        ///PullUpResistor pullUp)
        // Instantiated via derived class
        protected DhtSensor(Cpu.Pin pin1, Cpu.Pin pin2, Port.ResistorMode pullUp)
        {
            var resistorMode = (Port.ResistorMode)pullUp;

            portIn = new InterruptPort(pin2, false, resistorMode, Port.InterruptMode.InterruptEdgeLow);
            portIn.OnInterrupt += new NativeEventHandler(portIn_OnInterrupt);
            portIn.DisableInterrupt();  // Enabled automatically in the previous call

            portOut = new TristatePort(pin1, true, false, resistorMode);

            if (!CheckPins())
            {
                throw new InvalidOperationException("DHT sensor pins are not connected together.");
            }
        }
コード例 #10
0
ファイル: Pulsante.cs プロジェクト: gamondue/GrowBox-5F-16
 /// <summary>
 /// Parte l'evento dell'interruzione quando il livello del segnale di interruzione è alto (ovvero quando il pulsante viene premuto).
 /// Se si usa un bottone diverso dal built-in, è necessario collegare delle resistenze di pull-down per l'interruttore .
 /// Lady Ada è un eccelente tutorial su questo argomento: http://www.ladyada.net/learn/arduino/lesson5.html
 /// </summary>
 /// <param name="pin">Un pin digitale collegato al pulsante.</param>
 /// <param name="intMode">Definisce il tipo di cambio di livello innescando l'evento dell'interrupt.</param>
 /// <param name="target">Il gestore di eventi viene invocato quando si verifica un interrupt.</param>
 /// <param name="resistorMode">Configurazione interna della resistenza di pullup.</param>
 /// <param name="glitchFilter">Ingresso filtro antirimbalzo.</param>
 public Pulsante(Cpu.Pin pin, Port.InterruptMode intMode = Port.InterruptMode.InterruptEdgeLow, 
                 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();
 }
コード例 #11
0
 public static bool AttemptSetTristatePort(
     Cpu.Pin portID, bool initialState, bool glitchFilter, Port.ResistorMode resistor)
 {
     if (triPort == null)
     {
         try
         {
             triPort = new TristatePort(portID, initialState, glitchFilter, resistor);
             return true;
         }
         catch (Exception e)
         {
             Debug.Print("Setting triport request failed:\n" + e);
             return false;
         }
     }
     else
     {
         return false;
     }
 }
コード例 #12
0
ファイル: IgnitionRelay.cs プロジェクト: mbaldini/NovaOS
 public IgnitionRelay(Cpu.Pin pin, bool initialState, bool glitchFilter, Port.ResistorMode resistor, Sensors.Tachometer tach)
     : base(pin, initialState, glitchFilter, resistor, -1)
 {
     Tachometer = tach;
 }
コード例 #13
0
 /// <summary>
 /// Creates a new IRQ Port
 /// </summary>
 /// <param name="Pin">The pin number</param>
 /// <param name="GlitchFilter">Turns on or off the glitchfilter</param>
 /// <param name="ResistorMode">Selects the resistor mode</param>
 public IntegratedIRQ(Cpu.Pin Pin, bool GlitchFilter = false, Port.ResistorMode ResistorMode = Port.ResistorMode.Disabled)
 {
     this._Port = new InterruptPort(Pin, GlitchFilter, ResistorMode, Port.InterruptMode.InterruptEdgeBoth);
     this._Port.OnInterrupt += new NativeEventHandler(_Port_OnInterrupt);
 }
コード例 #14
0
ファイル: OneCoreInterruptPort.cs プロジェクト: A-KL/onecore
 public OneCoreInterruptPort(int cpuPort, bool initialState, Port.ResistorMode resistorMode, Port.InterruptMode interruptMode)
 {
     this.port = new InterruptPort((Cpu.Pin)cpuPort, initialState, resistorMode, interruptMode);
     this.port.OnInterrupt += this.InvokeOnOnInterrupt;
 }
コード例 #15
0
ファイル: StarterRelay.cs プロジェクト: mbaldini/NovaOS
 public StarterRelay(Cpu.Pin pin, bool initialState, bool glitchFilter, Port.ResistorMode resistor, int timeout, Sensors.Tachometer tach)
     : base(pin, initialState, glitchFilter, resistor, timeout)
 {
     Tachometer = tach;
 }
コード例 #16
0
ファイル: Pins.cs プロジェクト: JakeLardinois/NetMF.Toolbox
 /// <summary>
 /// Configures the pin as digital input
 /// </summary>
 /// <param name="GlitchFilter">Enables the glitch filter</param>
 /// <param name="Resistor">Enables resistor modes</param>
 public void ConfigureInput(bool GlitchFilter = false, Port.ResistorMode Resistor = Port.ResistorMode.Disabled)
 {
     this.ReleasePin();
     this._In = new InputPort(this.Pin, GlitchFilter, Resistor);
     this.Type = PortType.Input;
 }
コード例 #17
0
 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());
 }
コード例 #18
0
ファイル: Button.cs プロジェクト: ungood/hellevator
 public Button(FEZ_Pin.Digital pin, Port.ResistorMode mode = Port.ResistorMode.PullUp)
 {
     interrupt = new InputPort((Cpu.Pin) pin, false, mode);
     thread  = new Thread(Run);
     thread.Start();
 }
コード例 #19
0
 /// <summary>
 /// Creates a new GPI Port
 /// </summary>
 /// <param name="Pin">The pin number</param>
 /// <param name="GlitchFilter">Turns on or off the glitchfilter</param>
 /// <param name="ResistorMode">Selects the resistor mode</param>
 public IntegratedGPI(Cpu.Pin Pin, bool GlitchFilter = false, Port.ResistorMode ResistorMode = Port.ResistorMode.Disabled)
 {
     this._Port = new InputPort(Pin, GlitchFilter, ResistorMode);
 }
コード例 #20
0
ファイル: CJackdepart.cs プロジェクト: eleurent/eurobot-emx
 public void InitJackdepart(Cpu.Pin numInterrupt, Port.InterruptMode front)
 {
     InterruptPort jack = new InterruptPort((Cpu.Pin)numInterrupt, true, Port.ResistorMode.PullUp, front);
     jack.OnInterrupt += new NativeEventHandler(AttendreJack);
 }
コード例 #21
0
 /// <summary>Creates a new Bidirectional port</summary>
 /// <param name="PortId">Pin identifier for the GPIO pin</param>
 /// <param name="InitialState">Initial state of the pin</param>
 /// <param name="GlitchFilter">flag to indicate if glitch filtering should be used</param>
 /// <param name="Resistor">Resistor mode to use if supported by underlying hardware</param>
 BidirectionalPort(Cpu.Pin PortId, bool InitialState, bool GlitchFilter, Port.ResistorMode Resistor)
     : this(new TristatePort(PortId, InitialState, GlitchFilter, Resistor))
 {
 }
コード例 #22
0
 /// <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;
 }
コード例 #23
0
        /// <summary>
        /// Create and open an instance of an input port,
        /// with embedded auto-repeat capabilities
        /// </summary>
        /// <param name="port">The I/O pin selected for the input</param>
        /// <param name="resistor">The resistor wired-logic easing</param>
        /// <param name="activeLevel">The level on which the input has to be considered active</param>
        public AutoRepeatInputPort(
            Cpu.Pin port,
            Port.ResistorMode resistor,
            bool activeLevel)
            : base(port, false, resistor)
        {
            this.ActiveLevel = activeLevel;

            //create, then start the working thread
            this._workingThread = new Thread(this.Worker);
            this._workingThread.Start();
        }
コード例 #24
0
ファイル: CPUInputPort.cs プロジェクト: gflerm/NetCNC
 public CPUInputPort(Cpu.Pin inputPin, bool glitchFilter, Port.ResistorMode resister)
 {
     this.inputPut = new InputPort(inputPin, glitchFilter, resister);
 }