Skip to main content

Class Pcx857x

Represents a Pcx857x I2C IO Expander

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

Derived:
Meadow.Foundation.ICs.IOExpanders.Pcx8574

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​
Declaration
public abstract int NumberOfPins { get; }

DefaultI2cAddress​

The default I2C address for the peripheral

View Source​
Declaration
public byte DefaultI2cAddress { get; }

IsDisposed​

Is the object disposed

View Source​
Declaration
public bool IsDisposed { get; }

Fields​

createdPorts​

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

View Source​
Declaration
protected bool createdPorts

i2cComms​

The I2C Communications object

View Source​
Declaration
protected readonly II2cCommunications i2cComms

Methods​

CreateDigitalOutputPort(IPin, bool, OutputType)​

Creates an IDigitalOutputPort on the specified pin.

View Source​
Declaration
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​
Declaration
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​
Declaration
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​
Declaration
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​
Declaration
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​
Declaration
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​
Declaration
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​
Declaration
protected abstract ushort ReadState()
Returns​

System.UInt16

WriteState(ushort)​

Writes to the peripheral state register

View Source​
Declaration
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​
Declaration
protected abstract void SetState(ushort state)
Parameters​
TypeName
System.UInt16state

SetPinDirection(bool, byte)​

Set the pin direction

View Source​
Declaration
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​
Declaration
public void AllOff()

AllOn()​

Convenience method to turn all outputs on

View Source​
Declaration
public void AllOn()

GetPinState(IPin)​

Retrieves the state of a pin

View Source​
Declaration
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​
Declaration
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​
Declaration
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​
Declaration
public void Dispose()

Implements​

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