Ejemplo n.º 1
0
        private void OnButtonPress(uint data1, uint data2, DateTime time)
        {
            if (!_ready)
            {
                return;          // pressing the button before the unit is ready will do nothing
            }
            if (_handlingButtonPress)
            {
                return;                        // if this gets called multiple times in succession, ignore the repeats
            }
            lock (_lock)
            {
                _handlingButtonPress = true;
                _button.Interrupt    = Port.InterruptMode.InterruptNone; // does this suppress further interrupts?

                Recording = !Recording;                                  // Flip the recording flag
                if (Recording)
                {
                    StatusLed.Flash();
                }
                else
                {
                    StatusLed.Off();
                }

                Thread.Sleep(250); // glitch filtering
                _button.Interrupt    = Port.InterruptMode.InterruptEdgeHigh;
                _handlingButtonPress = false;
            }
        }