مشاركة عبر


GpioChangeCounter Class

Definition

Counts changes of a specified polarity on a general-purpose I/O (GPIO) pin.

public ref class GpioChangeCounter sealed : IClosable
/// [Windows.Foundation.Metadata.Activatable(Windows.Devices.Gpio.IGpioChangeCounterFactory, 196608, "Windows.Devices.DevicesLowLevelContract")]
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Devices.DevicesLowLevelContract, 196608)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class GpioChangeCounter final : IClosable
[Windows.Foundation.Metadata.Activatable(typeof(Windows.Devices.Gpio.IGpioChangeCounterFactory), 196608, "Windows.Devices.DevicesLowLevelContract")]
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Devices.DevicesLowLevelContract), 196608)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class GpioChangeCounter : System.IDisposable
function GpioChangeCounter(pin)
Public NotInheritable Class GpioChangeCounter
Implements IDisposable
Inheritance
Object Platform::Object IInspectable GpioChangeCounter
Attributes
Implements

Windows requirements

Device family
Windows 10 Creators Update (introduced in 10.0.15063.0)
API contract
Windows.Devices.DevicesLowLevelContract (introduced in v3.0)

Remarks

When the pin is an input, interrupts are used to detect pin changes. Interrupts for the pin are enabled for the specified polarity, and the count is incremented when an interrupt occurs.

When the pin is an output, the count will increment whenever the specified transition occurs on the pin. For example, if the pin is configured as an output and counting is enabled for rising edges, writing a 0 and then a 1 will cause the count to be incremented.

Constructors

GpioChangeCounter(GpioPin)

Creates a new GpioChangeCounter associated with the specified pin. Only a single GpioChangeCounter may be associated with a pin at any given time.

Properties

IsStarted

Gets whether pin change counting is currently active.

Polarity

Gets or sets the polarity of transitions that will be counted. The polarity may only be changed when pin counting is not started.

Methods

Close()

Closes the change counter, disassociating it from its pin.

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Read()

Reads the current count of polarity changes. Before counting has been started, this will return 0.

Reset()

Resets the count to 0 and returns the previous count.

Start()

Starts counting changes in pin polarity. This method may only be called when change counting is not already active.

Stop()

Stop counting changes in pin polarity. This method may only be called when change counting is currently active.

Applies to