Skip to main content

Class KeyScanButton

Represents a AS1115 key scan button

Assembly: As1115.dll
View Source
public class KeyScanButton : IButton, ISensor<bool>, ISensor

Implements:
Meadow.Peripherals.Sensors.Buttons.IButton, Meadow.Peripherals.Sensors.ISensor<System.Boolean>, Meadow.Peripherals.Sensors.ISensor

Properties

LongClickedThreshold

Get or set the long click threshold

View Source
public TimeSpan LongClickedThreshold { get; set; }

State

Get current button state

View Source
public bool State { get; }

Fields

buttonPressStart

Maximum DateTime value when the button was just pushed

View Source
protected DateTime buttonPressStart

Methods

Update(bool)

Update the button state true for pressed, false for released

View Source
public void Update(bool state)
Parameters
TypeName
System.Booleanstate

RaiseClicked()

Raised when the button circuit is re-opened after it has been closed (at the end of a �press�).

View Source
protected virtual void RaiseClicked()

RaisePressStarted()

Raised when a press starts (the button is pushed down; circuit is closed).

View Source
protected virtual void RaisePressStarted()

RaisePressEnded()

Raised when a press ends (the button is released; circuit is opened).

View Source
protected virtual void RaisePressEnded()

RaiseLongClicked()

Raised when the button circuit is pressed for at least 500ms.

View Source
protected virtual void RaiseLongClicked()

Read()

Convenience method to get the current sensor reading

View Source
public Task<bool> Read()
Returns

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

Events

PressStarted

Raised when a press starts (the button is pushed down)

View Source
public event EventHandler PressStarted
Event Type

System.EventHandler

PressEnded

Raised when a press ends (the button is released)

View Source
public event EventHandler PressEnded
Event Type

System.EventHandler

Clicked

Raised when the button circuit is re-opened after it has been closed (at the end of a press)

View Source
public event EventHandler Clicked
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

  • Meadow.Peripherals.Sensors.Buttons.IButton
  • Meadow.Peripherals.Sensors.ISensor<System.Boolean>
  • Meadow.Peripherals.Sensors.ISensor