Table of Contents

Class Switch<TLine>

Namespace
Pamoja.Gpio
Assembly
Pamoja.Gpio.dll

A two-state output over any line, with its polarity said once: a relay, an LED, a solenoid valve, a buzzer. Set(true) asserts it, which drives the line low for an active-low part, so no call site inverts a level by hand.

public sealed class Switch<TLine> where TLine : IOutputLine

Type Parameters

TLine

The line the part is wired to.

Inheritance
Switch<TLine>
Inherited Members

Constructors

Switch(TLine, PinPolarity)

Wraps a line, starting deasserted. Nothing is driven until Set(bool).

public Switch(TLine line, PinPolarity polarity)

Parameters

line TLine

The line the part is wired to.

polarity PinPolarity

How the part is wired.

Properties

IsAsserted

Whether the part was last set on.

public bool IsAsserted { get; }

Property Value

bool

Polarity

How the part is wired.

public PinPolarity Polarity { get; }

Property Value

PinPolarity

Methods

Release()

Hands the line back, for a test to read what was driven or a program to reuse it.

public TLine Release()

Returns

TLine

The line.

Set(bool)

Turns the part on or off, driving whichever level that means for its wiring.

public void Set(bool asserted)

Parameters

asserted bool

true to turn it on.

Exceptions

Exception

Whatever the line throws when it cannot be driven.