GpioChangeCounter GpioChangeCounter GpioChangeCounter GpioChangeCounter GpioChangeCounter Class

Definition

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

public : sealed class GpioChangeCounter : IClosable
struct winrt::Windows::Devices::Gpio::GpioChangeCounter : IClosable
public sealed class GpioChangeCounter : IDisposable
Public NotInheritable Class GpioChangeCounter Implements IDisposable
var gpioChangeCounter = new gpioChangeCounter(pin);
Attributes

Windows 10 requirements

Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Devices.DevicesLowLevelContract (introduced v3)

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) GpioChangeCounter(GpioPin) GpioChangeCounter(GpioPin) GpioChangeCounter(GpioPin) 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 IsStarted IsStarted IsStarted IsStarted

Gets whether pin change counting is currently active.

Polarity Polarity Polarity Polarity 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() Close() Close() Close() Close()

Closes the change counter, disassociating it from its pin.

Dispose() Dispose() Dispose() Dispose() Dispose()

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

Read() Read() Read() Read() Read()

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

Reset() Reset() Reset() Reset() Reset()

Resets the count to 0 and returns the previous count.

Start() Start() Start() Start() Start()

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

Stop() Stop() Stop() Stop() Stop()

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