Remarks

CButton
Status Status badge: working
Source code GitHub
NuGet package NuGet 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

Characteristic Locus
Inheritance object PushButtonBase PushButton > CButton
Implements IButton ISensor<bool> IDisposable
Inherited Members PushButton.DefaultDebounceDuration PushButton.DefaultGlitchDuration PushButton.DebounceDuration PushButton.DigitalIn PushButtonBase.DefaultLongPressThreshold PushButtonBase.PressStarted PushButtonBase.PressEnded PushButtonBase.Clicked PushButtonBase.LongClicked PushButtonBase.ShouldDisposeInput PushButtonBase.ButtonPressStart PushButtonBase.LongClickedThreshold PushButtonBase.State PushButtonBase.GetNormalizedState(bool) PushButtonBase.UpdateEvents(bool) PushButtonBase.RaiseClicked() PushButtonBase.RaisePressStarted() PushButtonBase.RaisePressEnded() PushButtonBase.RaiseLongClicked() PushButtonBase.Read() PushButtonBase.Dispose() object.Equals(object) object.Equals(object, object) object.GetHashCode() object.GetType() object.MemberwiseClone() object.ReferenceEquals(object, object) object.ToString()
Namespace Meadow.Foundation.mikroBUS.Sensors.Buttons
Assembly CButton.dll

Syntax

public class CButton : PushButton, IButton, ISensor<bool>, IDisposable

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

Remarks

CButton
Status Status badge: working
Source code GitHub
NuGet package NuGet 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

CButton(IPwmPort, IDigitalInterruptPort)

Creates a new CButton object

Declaration
public CButton(IPwmPort ledPwmPort, IDigitalInterruptPort buttonInterruptPort)

Parameters

Type Name Description
IPwmPort ledPwmPort

Led PWM port

IDigitalInterruptPort buttonInterruptPort

Button interrupt port

Remarks

CButton
Status Status badge: working
Source code GitHub
NuGet package NuGet 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

Properties

Brightness

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

Declaration
public float Brightness { get; set; }

Property Value

Type Description
float

Remarks

CButton
Status Status badge: working
Source code GitHub
NuGet package NuGet 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

IsOn

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

Declaration
public bool IsOn { get; set; }

Property Value

Type Description
bool

true if is on; otherwise, false.

Remarks

CButton
Status Status badge: working
Source code GitHub
NuGet package NuGet 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

Methods

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 = 1, float lowBrightness = 0)

Parameters

Type Name Description
TimeSpan onDuration
TimeSpan offDuration
float highBrightness
float lowBrightness
CButton
Status Status badge: working
Source code GitHub
NuGet package NuGet 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

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.

Declaration
public void StartPulse(TimeSpan pulseDuration, float highBrightness, float lowBrightness = 0.15)

Parameters

Type Name Description
TimeSpan pulseDuration
float highBrightness
float lowBrightness

Remarks

CButton
Status Status badge: working
Source code GitHub
NuGet package NuGet 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

StopAnimation()

Stops any running animations

Declaration
public void StopAnimation()

Remarks

CButton
Status Status badge: working
Source code GitHub
NuGet package NuGet 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