Treehopper C# API
Button Class Reference

Pushbutton attached to DigitalIn More...

Inheritance diagram for Button:

Classes

class  ButtonPressedEventArgs
 
class  ButtonReleasedEventArgs
 

Public Member Functions

delegate void ButtonPressedEventHandler (object sender, ButtonPressedEventArgs e)
 
delegate void ButtonReleasedEventHandler (object sender, ButtonReleasedEventArgs e)
 
 Button (DigitalIn input, bool activeLow=true)
 Construct a new Button attached to a DigitalIn input. More...
 
async Task< bool > AwaitButtonChangedAsync ()
 Wait for the button to change state More...
 
override string ToString ()
 Gets a string representing of whether the button is pressed or not More...
 

Public Attributes

bool Pressed => Input.DigitalValue ^ activeLow
 Determines whether the button is pressed (by reading Input.DigitalValue) More...
 

Properties

DigitalIn Input [get]
 Gets the underlying DigitalIn input. More...
 

Events

ButtonPressedEventHandler OnPressed
 Fired whenever the button is pressed More...
 
ButtonReleasedEventHandler OnReleased
 Fired whenever the button is released More...
 
PropertyChangedEventHandler PropertyChanged
 

Detailed Description

Pushbutton attached to DigitalIn

Constructor & Destructor Documentation

◆ Button()

Button ( DigitalIn  input,
bool  activeLow = true 
)

Construct a new Button attached to a DigitalIn input.

Parameters
inputThe DigitalIn the button is attached to
activeLowWhether the button is active-low (true, default). If the button is active-high, set to false.

Member Function Documentation

◆ ButtonPressedEventHandler()

delegate void ButtonPressedEventHandler ( object  sender,
ButtonPressedEventArgs  e 
)

◆ ButtonReleasedEventHandler()

delegate void ButtonReleasedEventHandler ( object  sender,
ButtonReleasedEventArgs  e 
)

◆ AwaitButtonChangedAsync()

async Task<bool> AwaitButtonChangedAsync ( )

Wait for the button to change state

Returns
An awaitable Task that returns a bool indicating if the button is pressed

◆ ToString()

override string ToString ( )

Gets a string representing of whether the button is pressed or not

Returns

Member Data Documentation

◆ Pressed

bool Pressed => Input.DigitalValue ^ activeLow

Determines whether the button is pressed (by reading Input.DigitalValue)

Property Documentation

◆ Input

DigitalIn Input
get

Gets the underlying DigitalIn input.

Event Documentation

◆ OnPressed

Fired whenever the button is pressed

◆ OnReleased

Fired whenever the button is released

◆ PropertyChanged

PropertyChangedEventHandler PropertyChanged

The documentation for this class was generated from the following file: