Remarks
PushButton | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
The PushButton class represents a simple push button, such as a tactile momentary button. To get notified when it’s clicked, subscribe to the Clicked event. If you need to know when the button is held down, subscribe to the PressStarted and PressEnded events.
Code Example
public class MeadowApp : App<F7Micro, MeadowApp>
{
public MeadowApp()
{
PushButton pushButton;
// Initialize by passing a IDigitalInputPort
//IDigitalInputPort digitalInputPort = Device.CreateDigitalInputPort(
// Device.Pins.D08,
// InterruptMode.EdgeBoth,
// ResistorMode.InternalPullUp, 20);
//pushButton = new PushButton(digitalInputPort);
// Initialize by sending Device and Pins
pushButton = new PushButton(
Device,
Device.Pins.D08,
ResistorMode.InternalPullUp
);
pushButton.PressStarted += PushButtonPressStarted;
pushButton.PressEnded += PushButtonPressEnded;
}
void PushButtonPressStarted(object sender, EventArgs e)
{
Console.WriteLine("Press Started...");
}
void PushButtonPressEnded(object sender, EventArgs e)
{
Console.WriteLine("Press Ended...");
}
}
Sample projects available on GitHub
Wiring Example
<img src="../../API_Assets/Meadow.Foundation.Sensors.Buttons.PushButton/PushButton_Fritzing.svg"
Syntax
public class PushButton : PushButtonBase, IButton, ISensor<bool>, IDisposable
Constructors
PushButton(IDigitalInterruptPort)
Creates PushButton with a pre-configured input port
Declaration
public PushButton(IDigitalInterruptPort inputPort)
Parameters
Type | Name | Description |
---|---|---|
IDigitalInterruptPort | inputPort |
Remarks
PushButton | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
The PushButton class represents a simple push button, such as a tactile momentary button. To get notified when it’s clicked, subscribe to the Clicked event. If you need to know when the button is held down, subscribe to the PressStarted and PressEnded events.
Code Example
public class MeadowApp : App<F7Micro, MeadowApp>
{
public MeadowApp()
{
PushButton pushButton;
// Initialize by passing a IDigitalInputPort
//IDigitalInputPort digitalInputPort = Device.CreateDigitalInputPort(
// Device.Pins.D08,
// InterruptMode.EdgeBoth,
// ResistorMode.InternalPullUp, 20);
//pushButton = new PushButton(digitalInputPort);
// Initialize by sending Device and Pins
pushButton = new PushButton(
Device,
Device.Pins.D08,
ResistorMode.InternalPullUp
);
pushButton.PressStarted += PushButtonPressStarted;
pushButton.PressEnded += PushButtonPressEnded;
}
void PushButtonPressStarted(object sender, EventArgs e)
{
Console.WriteLine("Press Started...");
}
void PushButtonPressEnded(object sender, EventArgs e)
{
Console.WriteLine("Press Ended...");
}
}
Sample projects available on GitHub
Wiring Example
<img src="../../API_Assets/Meadow.Foundation.Sensors.Buttons.PushButton/PushButton_Fritzing.svg"
PushButton(IPin, ResistorMode)
Creates PushButton with a digital input pin connected on a IIOdevice, specifying if its using an Internal or External PullUp/PullDown resistor.
Declaration
public PushButton(IPin inputPin, ResistorMode resistorMode = ResistorMode.InternalPullUp)
Parameters
Type | Name | Description |
---|---|---|
IPin | inputPin | The pin used to create the button port |
ResistorMode | resistorMode | The resistor mode |
Remarks
PushButton | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
The PushButton class represents a simple push button, such as a tactile momentary button. To get notified when it’s clicked, subscribe to the Clicked event. If you need to know when the button is held down, subscribe to the PressStarted and PressEnded events.
Code Example
public class MeadowApp : App<F7Micro, MeadowApp>
{
public MeadowApp()
{
PushButton pushButton;
// Initialize by passing a IDigitalInputPort
//IDigitalInputPort digitalInputPort = Device.CreateDigitalInputPort(
// Device.Pins.D08,
// InterruptMode.EdgeBoth,
// ResistorMode.InternalPullUp, 20);
//pushButton = new PushButton(digitalInputPort);
// Initialize by sending Device and Pins
pushButton = new PushButton(
Device,
Device.Pins.D08,
ResistorMode.InternalPullUp
);
pushButton.PressStarted += PushButtonPressStarted;
pushButton.PressEnded += PushButtonPressEnded;
}
void PushButtonPressStarted(object sender, EventArgs e)
{
Console.WriteLine("Press Started...");
}
void PushButtonPressEnded(object sender, EventArgs e)
{
Console.WriteLine("Press Ended...");
}
}
Sample projects available on GitHub
Wiring Example
<img src="../../API_Assets/Meadow.Foundation.Sensors.Buttons.PushButton/PushButton_Fritzing.svg"
PushButton(IPin, ResistorMode, TimeSpan)
Creates PushButton with a digital input pin connected on a IIOdevice, specifying if its using an Internal or External PullUp/PullDown resistor.
Declaration
public PushButton(IPin inputPin, ResistorMode resistorMode, TimeSpan debounceDuration)
Parameters
Type | Name | Description |
---|---|---|
IPin | inputPin | The pin used to create the button port |
ResistorMode | resistorMode | The resistor mode |
TimeSpan | debounceDuration | The interrupt debounce duration |
Remarks
PushButton | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
The PushButton class represents a simple push button, such as a tactile momentary button. To get notified when it’s clicked, subscribe to the Clicked event. If you need to know when the button is held down, subscribe to the PressStarted and PressEnded events.
Code Example
public class MeadowApp : App<F7Micro, MeadowApp>
{
public MeadowApp()
{
PushButton pushButton;
// Initialize by passing a IDigitalInputPort
//IDigitalInputPort digitalInputPort = Device.CreateDigitalInputPort(
// Device.Pins.D08,
// InterruptMode.EdgeBoth,
// ResistorMode.InternalPullUp, 20);
//pushButton = new PushButton(digitalInputPort);
// Initialize by sending Device and Pins
pushButton = new PushButton(
Device,
Device.Pins.D08,
ResistorMode.InternalPullUp
);
pushButton.PressStarted += PushButtonPressStarted;
pushButton.PressEnded += PushButtonPressEnded;
}
void PushButtonPressStarted(object sender, EventArgs e)
{
Console.WriteLine("Press Started...");
}
void PushButtonPressEnded(object sender, EventArgs e)
{
Console.WriteLine("Press Ended...");
}
}
Sample projects available on GitHub
Wiring Example
<img src="../../API_Assets/Meadow.Foundation.Sensors.Buttons.PushButton/PushButton_Fritzing.svg"
Fields
DefaultDebounceDuration
Default Debounce used on the PushButton Input if an InputPort is auto-created
Declaration
public static readonly TimeSpan DefaultDebounceDuration
Field Value
Type | Description |
---|---|
TimeSpan |
Remarks
PushButton | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
The PushButton class represents a simple push button, such as a tactile momentary button. To get notified when it’s clicked, subscribe to the Clicked event. If you need to know when the button is held down, subscribe to the PressStarted and PressEnded events.
Code Example
public class MeadowApp : App<F7Micro, MeadowApp>
{
public MeadowApp()
{
PushButton pushButton;
// Initialize by passing a IDigitalInputPort
//IDigitalInputPort digitalInputPort = Device.CreateDigitalInputPort(
// Device.Pins.D08,
// InterruptMode.EdgeBoth,
// ResistorMode.InternalPullUp, 20);
//pushButton = new PushButton(digitalInputPort);
// Initialize by sending Device and Pins
pushButton = new PushButton(
Device,
Device.Pins.D08,
ResistorMode.InternalPullUp
);
pushButton.PressStarted += PushButtonPressStarted;
pushButton.PressEnded += PushButtonPressEnded;
}
void PushButtonPressStarted(object sender, EventArgs e)
{
Console.WriteLine("Press Started...");
}
void PushButtonPressEnded(object sender, EventArgs e)
{
Console.WriteLine("Press Ended...");
}
}
Sample projects available on GitHub
Wiring Example
<img src="../../API_Assets/Meadow.Foundation.Sensors.Buttons.PushButton/PushButton_Fritzing.svg"
DefaultGlitchDuration
Default Glitch Filter used on the PushButton Input if an InputPort is auto-created
Declaration
public static readonly TimeSpan DefaultGlitchDuration
Field Value
Type | Description |
---|---|
TimeSpan |
Remarks
PushButton | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
The PushButton class represents a simple push button, such as a tactile momentary button. To get notified when it’s clicked, subscribe to the Clicked event. If you need to know when the button is held down, subscribe to the PressStarted and PressEnded events.
Code Example
public class MeadowApp : App<F7Micro, MeadowApp>
{
public MeadowApp()
{
PushButton pushButton;
// Initialize by passing a IDigitalInputPort
//IDigitalInputPort digitalInputPort = Device.CreateDigitalInputPort(
// Device.Pins.D08,
// InterruptMode.EdgeBoth,
// ResistorMode.InternalPullUp, 20);
//pushButton = new PushButton(digitalInputPort);
// Initialize by sending Device and Pins
pushButton = new PushButton(
Device,
Device.Pins.D08,
ResistorMode.InternalPullUp
);
pushButton.PressStarted += PushButtonPressStarted;
pushButton.PressEnded += PushButtonPressEnded;
}
void PushButtonPressStarted(object sender, EventArgs e)
{
Console.WriteLine("Press Started...");
}
void PushButtonPressEnded(object sender, EventArgs e)
{
Console.WriteLine("Press Ended...");
}
}
Sample projects available on GitHub
Wiring Example
<img src="../../API_Assets/Meadow.Foundation.Sensors.Buttons.PushButton/PushButton_Fritzing.svg"
Properties
DebounceDuration
This duration controls the debounce filter. It also has the effect of rate limiting clicks. Decrease this time to allow users to click more quickly.
Declaration
public TimeSpan DebounceDuration { get; set; }
Property Value
Type | Description |
---|---|
TimeSpan |
Remarks
PushButton | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
The PushButton class represents a simple push button, such as a tactile momentary button. To get notified when it’s clicked, subscribe to the Clicked event. If you need to know when the button is held down, subscribe to the PressStarted and PressEnded events.
Code Example
public class MeadowApp : App<F7Micro, MeadowApp>
{
public MeadowApp()
{
PushButton pushButton;
// Initialize by passing a IDigitalInputPort
//IDigitalInputPort digitalInputPort = Device.CreateDigitalInputPort(
// Device.Pins.D08,
// InterruptMode.EdgeBoth,
// ResistorMode.InternalPullUp, 20);
//pushButton = new PushButton(digitalInputPort);
// Initialize by sending Device and Pins
pushButton = new PushButton(
Device,
Device.Pins.D08,
ResistorMode.InternalPullUp
);
pushButton.PressStarted += PushButtonPressStarted;
pushButton.PressEnded += PushButtonPressEnded;
}
void PushButtonPressStarted(object sender, EventArgs e)
{
Console.WriteLine("Press Started...");
}
void PushButtonPressEnded(object sender, EventArgs e)
{
Console.WriteLine("Press Ended...");
}
}
Sample projects available on GitHub
Wiring Example
<img src="../../API_Assets/Meadow.Foundation.Sensors.Buttons.PushButton/PushButton_Fritzing.svg"
DigitalIn
Returns digital input port
Declaration
protected IDigitalInterruptPort DigitalIn { get; set; }
Property Value
Type | Description |
---|---|
IDigitalInterruptPort |
Remarks
PushButton | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
The PushButton class represents a simple push button, such as a tactile momentary button. To get notified when it’s clicked, subscribe to the Clicked event. If you need to know when the button is held down, subscribe to the PressStarted and PressEnded events.
Code Example
public class MeadowApp : App<F7Micro, MeadowApp>
{
public MeadowApp()
{
PushButton pushButton;
// Initialize by passing a IDigitalInputPort
//IDigitalInputPort digitalInputPort = Device.CreateDigitalInputPort(
// Device.Pins.D08,
// InterruptMode.EdgeBoth,
// ResistorMode.InternalPullUp, 20);
//pushButton = new PushButton(digitalInputPort);
// Initialize by sending Device and Pins
pushButton = new PushButton(
Device,
Device.Pins.D08,
ResistorMode.InternalPullUp
);
pushButton.PressStarted += PushButtonPressStarted;
pushButton.PressEnded += PushButtonPressEnded;
}
void PushButtonPressStarted(object sender, EventArgs e)
{
Console.WriteLine("Press Started...");
}
void PushButtonPressEnded(object sender, EventArgs e)
{
Console.WriteLine("Press Ended...");
}
}
Sample projects available on GitHub
Wiring Example
<img src="../../API_Assets/Meadow.Foundation.Sensors.Buttons.PushButton/PushButton_Fritzing.svg"