Remarks
CButton | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
Code Example
CButton ledButton;
public MeadowApp()
{
Console.WriteLine("Initializing ...");
ledButton = new CButton(Device.Pins.D03, Device.Pins.D04);
ledButton.StartPulse(TimeSpan.FromSeconds(2), 0.75f, 0);
ledButton.Clicked += (s, e) =>
{
Console.WriteLine("Button clicked");
ledButton.IsOn = !ledButton.IsOn;
};
}
Sample project(s) available on GitHub
Syntax
public class CButton : PushButton, IDisposable, IPwmLed
Constructors
CButton(IPin, IPin)
Creates a new CButton object
Declaration
public CButton(IPin ledPin, IPin buttonPin)
Parameters
Type | Name | Description |
---|---|---|
IPin | ledPin | Led pin |
IPin | buttonPin | Button pin |
CButton(IPwmPort, IDigitalInputPort)
Creates a new CButton object
Declaration
public CButton(IPwmPort ledPwmPort, IDigitalInputPort buttonInterruptPort)
Parameters
Type | Name | Description |
---|---|---|
IPwmPort | ledPwmPort | Led PWM port |
IDigitalInputPort | buttonInterruptPort | Button interrupt port |
Properties
Brightness
Gets the brightness of the LED, controlled by a PWM signal
Declaration
public float Brightness { get; set; }
Property Value
Type | Description |
---|---|
System.Single |
IsOn
Gets or sets a value indicating whether the LED is on.
Declaration
public bool IsOn { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Methods
StartBlink(TimeSpan, TimeSpan, Single, Single)
Start the Blink animation which sets the brightness of the LED alternating between a low and high brightness setting, using the durations provided.
Declaration
public void StartBlink(TimeSpan onDuration, TimeSpan offDuration, float highBrightness = 1F, float lowBrightness = 0F)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | onDuration | |
TimeSpan | offDuration | |
System.Single | highBrightness | |
System.Single | lowBrightness |
StartPulse(TimeSpan, Single, Single)
Start the Pulse animation which gradually alternates the brightness of the LED between a low and high brightness setting, using the durations provided.
Declaration
public void StartPulse(TimeSpan pulseDuration, float highBrightness, float lowBrightness = 0.15F)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | pulseDuration | |
System.Single | highBrightness | |
System.Single | lowBrightness |
Stop()
Stops any running animations
Declaration
public void Stop()