Skip to main content

DigitalSignal Class

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

DMA/timer-backed pulse-train I/O on a small set of pins. Capable of pulse counting (ReadPulse), high-resolution edge capture (Capture), and emitting pulse-width-modulated sequences (Generate). All three operations are mutually exclusive and run asynchronously — completion is reported via OnReadPulseFinished / OnCaptureFinished / OnGenerateFinished. Only specific pins are supported (currently 0, 1, and 19).

public class DigitalSignal : IDisposable

Constructors

DigitalSignal(GpioPin pin)

public DigitalSignal(GpioPin pin)

Opens a digital-signal session on a supported pin (0, 1, or 19).

ParameterTypeDescription
pinGpioPin

Properties

CanReadPulse

public bool CanReadPulse { get; }

True when no operation is in progress and ReadPulse may be called.

CanCapture

public bool CanCapture { get; }

True when no operation is in progress and Capture may be called.

CanGenerate

public bool CanGenerate { get; }

True when no operation is in progress and Generate may be called.

Methods

Dispose()

public void Dispose()

Releases the native pulse-train resources.

Dispose(bool disposing)

protected virtual void Dispose(bool disposing)

Dispose implementation.

ParameterTypeDescription
disposingbool

ReadPulse(uint pulseNum, GpioPinEdge edge, bool waitForEdge)

public void ReadPulse(uint pulseNum, GpioPinEdge edge, bool waitForEdge)

Counts up to pulseNum edges matching edge and measures the total elapsed time. Result is delivered via OnReadPulseFinished.

ParameterTypeDescription
pulseNumuintNumber of edges to count.
edgeGpioPinEdgeWhich edge(s) to count.
waitForEdgeboolWhen true, the timer starts on the first matching edge instead of immediately.

Capture(uint bufferSize, GpioPinEdge edge, bool waitForEdge)

public void Capture(uint bufferSize, GpioPinEdge edge, bool waitForEdge)

Captures inter-edge intervals. See full-parameter overload for buffer-layout details.

ParameterTypeDescription
bufferSizeuint
edgeGpioPinEdge
waitForEdgebool

Capture(uint count, GpioPinEdge edge, bool waitForEdge, TimeSpan timeout)

public void Capture(uint count, GpioPinEdge edge, bool waitForEdge, TimeSpan timeout)

Capture timestamps of count edges on the pin.

ParameterTypeDescription
countuint
edgeGpioPinEdge
waitForEdgebool
timeoutTimeSpan

Generate(uint[] data, uint offset, uint count)

public void Generate(uint[] data, uint offset, uint count)

Emits a pulse train described by data with default multiplier and starting high.

ParameterTypeDescription
datauint[]
offsetuint
countuint

Generate(uint[] data, uint offset, uint count, uint multiplier)

public void Generate(uint[] data, uint offset, uint count, uint multiplier)

Emits a pulse train with explicit multiplier and starting high.

ParameterTypeDescription
datauint[]
offsetuint
countuint
multiplieruint

Generate(uint[] data, uint offset, uint count, uint multiplier, GpioPinValue startingPolarity)

public void Generate(uint[] data, uint offset, uint count, uint multiplier, GpioPinValue startingPolarity)

Emits a pulse train: each data entry is a duration in timer ticks, alternating polarity starting from startingPolarity.

ParameterTypeDescription
datauint[]Buffer of segment durations.
offsetuintStarting index in data.
countuintNumber of entries to emit.
multiplieruintMultiplier applied to each duration entry (timer-tick scaling).
startingPolarityGpioPinValuePolarity of the first segment.

Abort()

public void Abort()

Aborts the running operation, if any.

Events

OnReadPulseFinished

public event PulseReadEventHandler OnReadPulseFinished

Raised when ReadPulse completes.

OnCaptureFinished

public event PulseCaptureEventHandler OnCaptureFinished

Raised when Capture completes.

OnGenerateFinished

public event PulseGenerateEventHandler OnGenerateFinished

Raised when Generate completes.