public ButtonInputController(IISRPiFaceDevice piface, byte inputPin, int gateDuration = 20, int maxDoubleClickDuration = 300, int holdTime = 1000)
     : base(piface, inputPin, gateDuration)
 {
     _holdTimer = new Timer(holdTime)
     {
         AutoReset = false, Enabled = false
     };
     _holdTimer.Elapsed         += _holdTimer_Elapsed;
     this.MaxDoubleClickDuration = TimeSpan.FromMilliseconds(maxDoubleClickDuration);
 }
Exemple #2
0
        /// <summary>
        /// Creates an instance of InputPinController.
        /// </summary>
        /// <param name="piface">PiFace device. Must be ISR enabled.</param>
        /// <param name="inputPinMask">Input pin mask to track changes.</param>
        /// <param name="PinGroupMode">Any: at least one pin means group is set; All: all pins of the group must be set.</param>
        /// <param name="gateDuration">Gate time in miliseconds in within further changes are ignored (antibeat function, default 20ms)</param>
        public InputPinGroupController(IISRPiFaceDevice piface, byte inputPinMask, PinGroupMode pinGroupMode, int gateDuration = 20)
            : base(piface)
        {
            if (gateDuration < 0)
            {
                throw new ArgumentOutOfRangeException("gateDuration", "gateDuration must be positive");
            }
            if (!piface.IsISREnabled)
            {
                throw new ArgumentOutOfRangeException("piface", "piface must be ISR enabled");
            }
            this._inputPinMask = inputPinMask;
            this._pinGroupMode = pinGroupMode;
            this._gateDuration = gateDuration;
            byte currentStates = piface.GetInputPinStates();

            this._state           = getState(currentStates);
            piface.InputsChanged += PiFace_InputsChanged;
        }
Exemple #3
0
 /// <summary>
 /// Creates an instance of InputPinController.
 /// </summary>
 /// <param name="piface">PiFace device. Must be ISR enabled.</param>
 /// <param name="inputPin">Input pin to track changes.</param>
 /// <param name="gateDuration">Gate time in miliseconds in within further changes are ignored (antibeat function, default 20ms)</param>
 public InputPinController(IISRPiFaceDevice piface, byte inputPin, int gateDuration = 20)
     : base(piface)
 {
     if (inputPin > 7)
     {
         throw new ArgumentOutOfRangeException("inputPin", "inputPin must be in the range 0-7");
     }
     if (gateDuration < 0)
     {
         throw new ArgumentOutOfRangeException("gateDuration", "gateDuration must be positive");
     }
     if (!piface.IsISREnabled)
     {
         throw new ArgumentOutOfRangeException("piface", "piface must be ISR enabled");
     }
     this._inputPin        = inputPin;
     this._gateDuration    = gateDuration;
     this._state           = piface.GetInputPinState(inputPin);
     piface.InputsChanged += PiFace_InputsChanged;
 }