Skip to main content

Class RotaryEncoderWithButton

Digital rotary encoder that uses two-bit Gray Code to encode rotation and has an integrated push button

Assembly: Meadow.Foundation.dll
View Source
public class RotaryEncoderWithButton : RotaryEncoder, IDisposable, IRotaryEncoderWithButton, IRotaryEncoder, IButton, ISensor<bool>, ISensor

Inheritance: System.Object -> Meadow.Foundation.Sensors.Rotary.RotaryEncoder

Implements:
System.IDisposable, Meadow.Peripherals.Sensors.Rotary.IRotaryEncoderWithButton, Meadow.Peripherals.Sensors.Rotary.IRotaryEncoder, Meadow.Peripherals.Sensors.Buttons.IButton, Meadow.Peripherals.Sensors.ISensor<System.Boolean>, Meadow.Peripherals.Sensors.ISensor

Properties

Button

Returns the PushButton that represents the integrated button

View Source
public PushButton Button { get; }

State

Returns the push button's state

View Source
public bool State { get; }

LongClickedThreshold

The minimum duration for a long press

View Source
public TimeSpan LongClickedThreshold { get; set; }

Methods

ButtonClicked(object, EventArgs)

Method when button is clicked (down then up)

View Source
protected void ButtonClicked(object sender, EventArgs e)
Parameters
TypeNameDescription
System.Objectsendersender object
System.EventArgseevent arguments

ButtonPressEnded(object, EventArgs)

Method called when button press is started (up state)

View Source
protected void ButtonPressEnded(object sender, EventArgs e)
Parameters
TypeNameDescription
System.Objectsendersender object
System.EventArgseevent arguments

ButtonPressStarted(object, EventArgs)

Method called when button press is started (down state)

View Source
protected void ButtonPressStarted(object sender, EventArgs e)
Parameters
TypeNameDescription
System.Objectsendersender object
System.EventArgseevent arguments

Read()

Convenience method to get the current sensor reading

View Source
public Task<bool> Read()
Returns

System.Threading.Tasks.Task<System.Boolean>

Events

Clicked

Raised when the button circuit is re-opened after it has been closed

View Source
public event EventHandler Clicked
Event Type

System.EventHandler

PressEnded

Raised when a press ends

View Source
public event EventHandler PressEnded
Event Type

System.EventHandler

PressStarted

Raised when a press starts

View Source
public event EventHandler PressStarted
Event Type

System.EventHandler

LongClicked

Raised when the button circuit is pressed for LongPressDuration

View Source
public event EventHandler LongClicked
Event Type

System.EventHandler

Implements

  • System.IDisposable
  • Meadow.Peripherals.Sensors.Rotary.IRotaryEncoderWithButton
  • Meadow.Peripherals.Sensors.Rotary.IRotaryEncoder
  • Meadow.Peripherals.Sensors.Buttons.IButton
  • Meadow.Peripherals.Sensors.ISensor<System.Boolean>
  • Meadow.Peripherals.Sensors.ISensor