Skip to content

Commit

Permalink
Merge pull request #1101 from WildernessLabs/bug/rotary-encoder
Browse files Browse the repository at this point in the history
don't try to fire events to null delegates
  • Loading branch information
adrianstevens authored Dec 17, 2024
2 parents a01518c + aeea214 commit f7acad1
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,22 @@ public class RotaryEncoderWithButton : RotaryEncoder, IRotaryEncoderWithButton
/// <summary>
/// Raised when the button circuit is re-opened after it has been closed
/// </summary>
public event EventHandler Clicked = default!;
public event EventHandler? Clicked;

/// <summary>
/// Raised when a press ends
/// </summary>
public event EventHandler PressEnded = default!;
public event EventHandler? PressEnded;

/// <summary>
/// Raised when a press starts
/// </summary>
public event EventHandler PressStarted = default!;
public event EventHandler? PressStarted;

/// <summary>
/// Raised when the button circuit is pressed for LongPressDuration
/// </summary>
public event EventHandler LongClicked = default!;
public event EventHandler? LongClicked;

/// <summary>
/// The minimum duration for a long press
Expand Down Expand Up @@ -70,7 +70,7 @@ public RotaryEncoderWithButton(IPin aPhasePin, IPin bPhasePin, IPin buttonPin, R

private void ButtonLongClicked(object sender, EventArgs e)
{
LongClicked(this, e);
LongClicked?.Invoke(this, e);
}

/// <summary>
Expand All @@ -80,7 +80,7 @@ private void ButtonLongClicked(object sender, EventArgs e)
/// <param name="e">event arguments</param>
protected void ButtonClicked(object sender, EventArgs e)
{
Clicked(this, e);
Clicked?.Invoke(this, e);
}

/// <summary>
Expand All @@ -90,7 +90,7 @@ protected void ButtonClicked(object sender, EventArgs e)
/// <param name="e">event arguments</param>
protected void ButtonPressEnded(object sender, EventArgs e)
{
PressEnded(this, e);
PressEnded?.Invoke(this, e);
}

/// <summary>
Expand All @@ -100,7 +100,7 @@ protected void ButtonPressEnded(object sender, EventArgs e)
/// <param name="e">event arguments</param>
protected void ButtonPressStarted(object sender, EventArgs e)
{
PressStarted(this, e);
PressStarted?.Invoke(this, e);
}

/// <summary>
Expand Down

0 comments on commit f7acad1

Please sign in to comment.