Skip to main content

Class Pcx857x

Represents a Pcx857x I2C IO Expander

Assembly: Pcx857x.dll
View Source
public abstract class Pcx857x : IDigitalOutputController, IDigitalInputController, IDigitalInterruptController, IPinController, II2cPeripheral, IDisposable

Derived:
Meadow.Foundation.ICs.IOExpanders.Pcx8574, Meadow.Foundation.ICs.IOExpanders.Pcx8575

Implements:
Meadow.Hardware.IDigitalOutputController, Meadow.Hardware.IDigitalInputController, Meadow.Hardware.IDigitalInterruptController, Meadow.Hardware.IPinController, Meadow.Hardware.II2cPeripheral, System.IDisposable

Properties

NumberOfPins

The number of IO pins available on the device

View Source
public abstract int NumberOfPins { get; }

DefaultI2cAddress

The default I2C address for the peripheral

View Source
public byte DefaultI2cAddress { get; }

IsDisposed

Is the object disposed

View Source
public bool IsDisposed { get; }

Fields

createdPorts

Did we create the port(s) used by the peripheral

View Source
protected bool createdPorts

i2cComms

The I2C Communications object

View Source
protected readonly II2cCommunications i2cComms

Methods

GetAddressFromPins(bool, bool, bool, bool)

Helper method to get address from address pin configuration

View Source
public static byte GetAddressFromPins(bool pinA0, bool pinA1, bool pinA2, bool isATypeDevice = false)
Returns

System.Byte: The device address

Parameters
TypeNameDescription
System.BooleanpinA0State of A0 address pin - true if high
System.BooleanpinA1State of A1 address pin - true if high
System.BooleanpinA2State of A2 address pin - true if high
System.BooleanisATypeDeviceIs an A hardware variant, this shifts the address returned by 24

CreateDigitalOutputPort(IPin, bool, OutputType)

Creates an IDigitalOutputPort on the specified pin.

View Source
public IDigitalOutputPort CreateDigitalOutputPort(IPin pin, bool initialState = false, OutputType initialOutputType = OutputType.PushPull)
Returns

Meadow.Hardware.IDigitalOutputPort

Parameters
TypeNameDescription
Meadow.Hardware.IPinpinThe pin on which to create the port.
System.BooleaninitialStateThe default initial state of the port,
either LOW (false), or HIGH (true).
Meadow.Hardware.OutputTypeinitialOutputTypeWhether the port is initially configured
as PushPull or OpenDrain. PushPull by default.

CreateDigitalInputPort(IPin, ResistorMode)

Creates an IDigitalInputPort on the specified pin.

View Source
public IDigitalInputPort CreateDigitalInputPort(IPin pin, ResistorMode resistorMode)
Returns

Meadow.Hardware.IDigitalInputPort

Parameters
TypeNameDescription
Meadow.Hardware.IPinpinThe pin on which to create the port.
Meadow.Hardware.ResistorModeresistorModeThe ResistorMode specifying whether an
        external pull-up/pull-down resistor is used, or an internal pull-up/pull-down
        resistor should be configured for default state. |

CreateDigitalInterruptPort(IPin, InterruptMode, ResistorMode)

Creates a new DigitalInputPort using the specified pin

View Source
public IDigitalInterruptPort CreateDigitalInterruptPort(IPin pin, InterruptMode interruptMode = InterruptMode.None, ResistorMode resistorMode = ResistorMode.Disabled)
Returns

Meadow.Hardware.IDigitalInterruptPort: IDigitalInterruptPort

Parameters
TypeNameDescription
Meadow.Hardware.IPinpinThe pin representing the port
Meadow.Hardware.InterruptModeinterruptModeThe port interrupt mode
Meadow.Hardware.ResistorModeresistorModeThe port resistor mode

CreateDigitalInterruptPort(IPin, InterruptMode, ResistorMode, TimeSpan)

Creates a new DigitalInputPort using the specified pin

View Source
public IDigitalInterruptPort CreateDigitalInterruptPort(IPin pin, InterruptMode interruptMode, ResistorMode resistorMode, TimeSpan debounceDuration)
Returns

Meadow.Hardware.IDigitalInterruptPort: IDigitalInterruptPort

Parameters
TypeNameDescription
Meadow.Hardware.IPinpinThe pin representing the port
Meadow.Hardware.InterruptModeinterruptModeThe port interrupt mode
Meadow.Hardware.ResistorModeresistorModeThe port resistor mode
System.TimeSpandebounceDurationThe debounce duration

CreateDigitalInterruptPort(IPin, InterruptMode, ResistorMode, TimeSpan, TimeSpan)

Creates a new DigitalInputPort using the specified pin

View Source
public IDigitalInterruptPort CreateDigitalInterruptPort(IPin pin, InterruptMode interruptMode, ResistorMode resistorMode, TimeSpan debounceDuration, TimeSpan glitchDuration)
Returns

Meadow.Hardware.IDigitalInterruptPort: IDigitalInterruptPort

Parameters
TypeNameDescription
Meadow.Hardware.IPinpinThe pin representing the port
Meadow.Hardware.InterruptModeinterruptModeThe port interrupt mode
Meadow.Hardware.ResistorModeresistorModeThe port resistor mode
System.TimeSpandebounceDurationThe debounce duration
System.TimeSpanglitchDurationThe glitch duration - not configurable on Mcpxxxx

GetPin(string)

View Source
public abstract IPin GetPin(string pinName)
Returns

Meadow.Hardware.IPin

Parameters
TypeName
System.StringpinName

IsValidPin(IPin)

Checks if a pin exists on the Pcx857x

View Source
protected abstract bool IsValidPin(IPin pin)
Returns

System.Boolean

Parameters
TypeName
Meadow.Hardware.IPinpin

ReadState()

Reads the peripheral state register for 8 pin devices

View Source
protected abstract ushort ReadState()
Returns

System.UInt16

WriteState(ushort)

Writes to the peripheral state register

View Source
protected abstract void WriteState(ushort state)
Parameters
TypeName
System.UInt16state

SetState(ushort)

Writes to the peripheral state register and saves internal output state

View Source
protected abstract void SetState(ushort state)
Parameters
TypeName
System.UInt16state

SetPinDirection(bool, byte)

Set the pin direction

View Source
protected abstract void SetPinDirection(bool input, byte pinKey)
Parameters
TypeNameDescription
System.Booleaninputtrue for input, false for output
System.BytepinKeyThe pin key value

AllOff()

Convenience method to turn all outputs off

View Source
public void AllOff()

AllOn()

Convenience method to turn all outputs on

View Source
public void AllOn()

GetPinState(IPin)

Retrieves the state of a pin

View Source
protected abstract bool GetPinState(IPin pin)
Returns

System.Boolean

Parameters
TypeNameDescription
Meadow.Hardware.IPinpinThe pin to query

SetPinState(IPin, bool)

Sets the state of a pin

View Source
protected abstract void SetPinState(IPin pin, bool state)
Parameters
TypeNameDescription
Meadow.Hardware.IPinpinThe pin to affect
System.Booleanstate<b>True</b> to set the pin state high, <b>False</b> to set it low

Dispose(bool)

Dispose of the object

View Source
protected virtual void Dispose(bool disposing)
Parameters
TypeNameDescription
System.BooleandisposingIs disposing

Dispose()

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

View Source
public void Dispose()

Implements

  • Meadow.Hardware.IDigitalOutputController
  • Meadow.Hardware.IDigitalInputController
  • Meadow.Hardware.IDigitalInterruptController
  • Meadow.Hardware.IPinController
  • Meadow.Hardware.II2cPeripheral
  • System.IDisposable