nanoFramework.Iot.Device.Button
1.2.631
Prefix Reserved
See the version list below for details.
dotnet add package nanoFramework.Iot.Device.Button --version 1.2.631
NuGet\Install-Package nanoFramework.Iot.Device.Button -Version 1.2.631
<PackageReference Include="nanoFramework.Iot.Device.Button" Version="1.2.631" />
paket add nanoFramework.Iot.Device.Button --version 1.2.631
#r "nuget: nanoFramework.Iot.Device.Button, 1.2.631"
// Install nanoFramework.Iot.Device.Button as a Cake Addin #addin nuget:?package=nanoFramework.Iot.Device.Button&version=1.2.631 // Install nanoFramework.Iot.Device.Button as a Cake Tool #tool nuget:?package=nanoFramework.Iot.Device.Button&version=1.2.631
Button
The ButtonBase
class is a base implementation for buttons that is hardware independent and can be used across devices.
The GpioButton
is a GPIO implementation of the button and inherits from the ButtonBase
class. This implementation has been tested on an ESP32 platform, specifically on the M5StickC Plus.
Documentation
Documentation for the M5StickC Plus, including pin mapping, can be found here. Information regarding standard mouse events, used as inspiration for the button events, can be found here.
Usage
You can find an example in the samples directory.
// Initialize a new button with the corresponding button pin
GpioButton button = new GpioButton(buttonPin: 37);
Debug.WriteLine("Button is initialized, starting to read state");
// Enable or disable holding or doublepress events
button.IsDoublePressEnabled = true;
button.IsHoldingEnabled = true;
// Write to debug if the button is down
button.ButtonDown += (sender, e) =>
{
Debug.WriteLine($"buttondown IsPressed={button.IsPressed}");
};
// Write to debug if the button is up
button.ButtonUp += (sender, e) =>
{
Debug.WriteLine($"buttonup IsPressed={button.IsPressed}");
};
// Write to debug if the button is pressed
button.Press += (sender, e) =>
{
Debug.WriteLine($"Press");
};
// Write to debug if the button is double pressed
button.DoublePress += (sender, e) =>
{
Debug.WriteLine($"Double press");
};
// Write to debug if the button is held and released
button.Holding += (sender, e) =>
{
switch (e.HoldingState)
{
case ButtonHoldingState.Started:
Debug.WriteLine($"Holding Started");
break;
case ButtonHoldingState.Completed:
Debug.WriteLine($"Holding Completed");
break;
}
};
Thread.Sleep(Timeout.Infinite);
Expected output
Button is initialized, starting to read state
buttondown IsPressed=True
buttonup IsPressed=False
Press
buttondown IsPressed=True
buttonup IsPressed=False
Press
Double press
buttondown IsPressed=True
Holding Started
buttonup IsPressed=False
Press
Holding Completed
Testing
The unit test project can be found in the tests directory. You can simply run them using the VS2019 built-in test capabilites:
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net is compatible. |
-
- nanoFramework.CoreLibrary (>= 1.15.5)
- nanoFramework.Runtime.Events (>= 1.11.18)
- nanoFramework.System.Device.Gpio (>= 1.1.41)
NuGet packages (10)
Showing the top 5 NuGet packages that depend on nanoFramework.Iot.Device.Button:
Package | Downloads |
---|---|
nanoFramework.M5Core2
This package includes the nanoFramework.M5Core2 assembly for .NET nanoFramework C# projects. |
|
nanoFramework.M5StickC
This package includes the nanoFramework.M5StickC assembly for .NET nanoFramework C# projects. |
|
nanoFramework.M5Core
This package includes the nanoFramework.M5Core assembly for .NET nanoFramework C# projects. |
|
nanoFramework.M5StickCPlus
This package includes the nanoFramework.M5StickCPlus assembly for .NET nanoFramework C# projects. |
|
nanoFramework.AtomLite
This package includes the nanoFramework.AtomLite assembly for .NET nanoFramework C# projects. |
GitHub repositories (3)
Showing the top 3 popular GitHub repositories that depend on nanoFramework.Iot.Device.Button:
Repository | Stars |
---|---|
nanoframework/Samples
🍬 Code samples from the nanoFramework team used in testing, proof of concepts and other explorational endeavours
|
|
nanoframework/nanoFramework.IoT.Device
📦 This repo includes .NET nanoFramework implementations for various sensors, chips, displays, hats and drivers
|
|
nanoframework/nanoFramework.M5Stack
:package: Board support package for M5Stack, M5StickC and M5StickCPlus for .NET nanoFramework
|
Version | Downloads | Last updated |
---|---|---|
1.2.718 | 47 | 12/30/2024 |
1.2.696 | 660 | 12/16/2024 |
1.2.673 | 1,250 | 10/23/2024 |
1.2.631 | 2,607 | 8/28/2024 |
1.2.570 | 2,690 | 6/14/2024 |
1.2.560 | 571 | 5/29/2024 |
1.2.552 | 288 | 5/17/2024 |
1.2.548 | 455 | 5/15/2024 |
1.2.536 | 914 | 4/15/2024 |
1.2.514 | 1,155 | 3/22/2024 |
1.2.436 | 3,021 | 11/10/2023 |
1.2.329 | 7,118 | 5/26/2023 |
1.2.313 | 1,728 | 5/12/2023 |
1.2.308 | 1,144 | 5/11/2023 |
1.2.302 | 793 | 5/10/2023 |
1.2.297 | 1,296 | 5/3/2023 |
1.2.273 | 4,206 | 3/17/2023 |
1.2.215 | 13,601 | 1/6/2023 |
1.2.203 | 3,374 | 12/28/2022 |
1.2.153 | 8,033 | 11/5/2022 |
1.2.141 | 8,479 | 10/25/2022 |
1.2.122 | 4,286 | 10/12/2022 |
1.2.114 | 3,402 | 10/8/2022 |
1.2.95 | 8,773 | 9/22/2022 |
1.2.87 | 8,916 | 9/15/2022 |
1.2.73 | 3,548 | 9/8/2022 |
1.2.32 | 19,296 | 8/2/2022 |
1.1.113.2032 | 37,868 | 6/23/2022 |
1.1.58.10097 | 33,504 | 5/23/2022 |
1.1.43.5388 | 8,898 | 5/5/2022 |
1.1.16 | 1,019 | 4/19/2022 |
1.1.1 | 30,765 | 4/14/2022 |
1.0.300 | 12,022 | 3/31/2022 |
1.0.289-preview.6 | 191 | 3/25/2022 |
1.0.289-preview.1 | 153 | 3/24/2022 |
1.0.288-preview.99 | 185 | 3/18/2022 |
1.0.288-preview.98 | 140 | 3/18/2022 |
1.0.288-preview.93 | 202 | 3/15/2022 |
1.0.288-preview.86 | 220 | 3/8/2022 |
1.0.288-preview.65 | 236 | 2/18/2022 |
1.0.288-preview.48 | 256 | 2/4/2022 |
1.0.288-preview.29 | 257 | 1/28/2022 |
1.0.288-preview.20 | 237 | 1/27/2022 |
1.0.288-preview.19 | 158 | 1/27/2022 |
1.0.288-preview.5 | 204 | 1/24/2022 |
1.0.288-preview.3 | 173 | 1/21/2022 |
1.0.288-preview.1 | 168 | 1/21/2022 |
1.0.272 | 296 | 1/10/2022 |
1.0.259 | 1,558 | 12/9/2021 |
1.0.218 | 383 | 10/18/2021 |
1.0.214 | 826 | 10/15/2021 |
1.0.207 | 849 | 10/11/2021 |
1.0.196 | 814 | 10/5/2021 |