Skip to content

Add basic support for duinoNodes shift register handling via IOExpander#501

Open
logicallysynced wants to merge 2 commits into
DCC-EX:masterfrom
logicallysynced:master
Open

Add basic support for duinoNodes shift register handling via IOExpander#501
logicallysynced wants to merge 2 commits into
DCC-EX:masterfrom
logicallysynced:master

Conversation

@logicallysynced
Copy link
Copy Markdown

I have been tinkering with a personal fork of the EX-IOExpander codebase to see if I could add shift-register support.

My primary objective was to add support for duinoNodes (DNIN8, DNOU8, etc.) directly connected to an Arduino running EX-IOExpander.

This is the CommandStation-EX portion of the codebase, please use it for reference as needed. For the EX-IOExpander code, please visit this PR:
DCC-EX/EX-IOExpander#64

Adds a new IODevice implementation that exposes DuinoNodes-style shift-register nodes via an EX-IOExpander device.

  1. Introduces IO_DNShiftExpander, an IODevice subclass that bridges VPIN-based configuration (HAL config) <-> EX-IOExpander shift commands (I2C).

  2. The device is configured with:

  • A VPIN range for the logical DN node (e.g. 201–232).
  • 3x EX-IOExpander-backed VPINs for clk, latch & data.
  • Input vs Output mode, plus optional per-bit remapping (pinMap) to match DNIN8/DNOU8 board bit ordering.
  1. At runtime:
  • Input mode: Periodically polls the expander using shiftInBytes() and updates the local bitmap. _read() serves per-VPIN state from that bitmap.
  • Output mode: _write() updates the bitmap and marks transmit pending. _loop() flushes via shiftOutBytes() when needed.
  1. Includes some basic checks to ensure the 3x control VPINs all belong to the same EX-IOExpander instance and are within its VPIN range.

  2. Adds a _display() implementation so the device is identified in diagnostics as a DNIN/DNOU node “via EXIO” instead of showing up as an unknown device.

To simplify the implementation, I created new device classes called IO_DNIN8V, IO_DNIN8KV & IO_DNOU8V which can be used to reference a duinoNode on an IOExpander. For example:

HAL(EXIOExpander, 401, 16, 0x65)
HAL(IO_DNIN8V, 201, 32, 409, 410, 411)

The above example defines an EX-IOExpander and assigned a DNIN8 duinoNode at VPIN 409, 410 & 411 on that Expander.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant