private void OnButtonPress(object sender, PinValueChangedEventArgs pinValueChangedEventArgs) { //todo: extend this to support double click, on hold, etc if (pinValueChangedEventArgs.ChangeType == PinEventTypes.Falling) { pressedDown = DateTime.Now; } else { var e = new ButtonHandlerEventArgs() { pin = _pin }; var _holdTime = (DateTime.Now - pressedDown); if (_holdTime.Seconds > 1) { OnHeld(e); } else { OnClick(e); } } }
protected virtual void OnHeld(ButtonHandlerEventArgs e) { if (!_initialized) { throw new InvalidOperationException($"Not initialized {_pin}"); } Held?.Invoke(this, e); }