Skip to main content

SignalCapture Class

Namespace: GHIElectronics.TinyCLR.Devices.Signals · Assembly: GHIElectronics.TinyCLR.Devices.Signals

Samples a digital input and records the durations between successive edges — the inverse of SignalGenerator. Useful for capturing IR-remote codes, decoding bit-banged protocols, or measuring pulse widths.

public class SignalCapture : IDisposable

Constructors

SignalCapture(GpioPin pin)

public SignalCapture(GpioPin pin)

Opens a capture session on the given pin.

ParameterTypeDescription
pinGpioPin

Properties

DisableInterrupts

public bool DisableInterrupts { get; set; }

When true, capture runs with interrupts disabled.

Timeout

public TimeSpan Timeout { get; set; }

Maximum total time the capture will wait before returning.

DriveMode

public GpioPinDriveMode DriveMode { get; set; }

Drive mode applied to the capture pin (typically input or input-pull-up).

Methods

Dispose()

public void Dispose()

Returns the pin to high-impedance input.

Read()

public GpioPinValue Read()

Samples the current level of the pin without waiting.

Returns GpioPinValue

Read(out GpioPinValue initialState, TimeSpan[] buffer)

public int Read(out GpioPinValue initialState, TimeSpan[] buffer)

Captures up to buffer.Length inter-edge intervals starting now.

ParameterTypeDescription
initialStateout GpioPinValueReceives the level of the pin at the moment capture began.
bufferTimeSpan[]Receives inter-edge intervals.

Returns int — Number of intervals captured.

Read(GpioPinValue waitForState, TimeSpan[] buffer)

public int Read(GpioPinValue waitForState, TimeSpan[] buffer)

Waits for the pin to reach waitForState, then captures inter-edge intervals.

ParameterTypeDescription
waitForStateGpioPinValueLevel the capture should be armed by.
bufferTimeSpan[]Receives inter-edge intervals.

Returns int — Number of intervals captured.

Read(out GpioPinValue initialState, TimeSpan[] buffer, int offset, int count)

public extern int Read(out GpioPinValue initialState, TimeSpan[] buffer, int offset, int count)

Captures a slice of inter-edge intervals.

ParameterTypeDescription
initialStateout GpioPinValue
bufferTimeSpan[]
offsetint
countint

Returns int

Read(GpioPinValue waitForState, TimeSpan[] buffer, int offset, int count)

public extern int Read(GpioPinValue waitForState, TimeSpan[] buffer, int offset, int count)

Captures a slice of inter-edge intervals after waiting for waitForState.

ParameterTypeDescription
waitForStateGpioPinValue
bufferTimeSpan[]
offsetint
countint

Returns int