Skip to main content

Meadow.Foundation.mikroBUS.Sensors.Buttons.CButton

CButton
StatusStatus badge: working
Source codeGitHub
NuGet packageNuGet Gallery for Meadow.Foundation.mikroBUS.Sensors.Buttons.CButton

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

Class CButton

Represents a mikroBUS Button G,R,Y Click board

Assembly: CButton.dll
View Source
Declaration
public class CButton : PushButton, IButton, ISensor<bool>, ISensor, IDisposable

Inheritance: System.Object -> Meadow.Foundation.Sensors.Buttons.PushButtonBase -> Meadow.Foundation.Sensors.Buttons.PushButton

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

Properties

IsOn

Gets or sets a value indicating whether the LED is on.

View Source
Declaration
public bool IsOn { get; set; }

Brightness

Gets the brightness of the LED, controlled by a PWM signal

View Source
Declaration
public float Brightness { get; set; }

Methods

StartBlink(TimeSpan, TimeSpan, float, float)

Start the Blink animation which sets the brightness of the LED alternating between a low and high brightness setting, using the durations provided.

View Source
Declaration
public void StartBlink(TimeSpan onDuration, TimeSpan offDuration, float highBrightness = 1, float lowBrightness = 0)
Parameters
TypeName
System.TimeSpanonDuration
System.TimeSpanoffDuration
System.SinglehighBrightness
System.SinglelowBrightness

StartPulse(TimeSpan, float, float)

Start the Pulse animation which gradually alternates the brightness of the LED between a low and high brightness setting, using the durations provided.

View Source
Declaration
public void StartPulse(TimeSpan pulseDuration, float highBrightness, float lowBrightness = 0.15)
Parameters
TypeName
System.TimeSpanpulseDuration
System.SinglehighBrightness
System.SinglelowBrightness

StopAnimation()

Stops any running animations

View Source
Declaration
public void StopAnimation()

Implements

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