Exemple #1
0
        private void ProcessLoop()
        {
            while (_isRunning)
            {
                try
                {
                    var result   = _i2CWire.GetPinStatus((byte)_pinToMonitor);
                    var newState = result ? GpioPressState.Pressed : GpioPressState.NotPressed;

                    if (newState != _lastState)
                    {
                        _lastState = newState;
                        OnPressState(newState);
                        Debug.WriteLine($"State: {result}");
                    }
                }
                catch
                {
                    // Ignore
                }
                finally
                {
                    Thread.Sleep(50);
                }
            }
        }
Exemple #2
0
 protected virtual void OnPressState(GpioPressState e)
 {
     PressState?.Invoke(this, e);
 }