XPoint 0.1.0
Hardware-agnostic crosspoint matrix routing library
Loading...
Searching...
No Matches
XPoint Class Reference

Hardware-agnostic crosspoint matrix connection manager. More...

#include <XPoint.h>

Inheritance diagram for XPoint:
XPointStatic< ROWS, COLS >

Public Member Functions

 XPoint (uint8_t rows, uint8_t cols, RelayType type=RE_NON_LATCHING, uint16_t pdur=0)
 Heap-allocating constructor.
 
 XPoint (uint8_t rows, uint8_t cols, bool *state, bool *ilock, bool *excl, RelayType type=RE_NON_LATCHING, uint16_t pdur=0)
 Zero-heap buffer constructor.
 
 ~XPoint ()
 Destructor. Frees heap buffers only when constructed with the heap constructor.
 
 XPoint (const XPoint &)=delete
 
XPointoperator= (const XPoint &)=delete
 
void setDriver (XPointDriver *drv)
 Attach a driver backend.
 
void begin ()
 Initialize hardware by calling drv->begin().
 
bool connect (uint8_t row, uint8_t col)
 Connect row row to column col.
 
bool disconnect (uint8_t row, uint8_t col)
 Disconnect row row from column col.
 
bool setLevel (uint8_t row, uint8_t col, uint16_t level)
 analog-level connect / disconnect (PWM drivers).
 
void clearAll ()
 Disconnect all connected nodes and zero the state table.
 
void lockRows (uint8_t rowA, uint8_t rowB)
 Prevent rowA and rowB from connecting to the same column simultaneously.
 
void exclusiveInput (uint8_t col)
 Mark column col as exclusive: at most one row may connect at a time.
 
void update ()
 Expire latching-relay coil pulses and call releaseNode() as needed.
 

Detailed Description

Hardware-agnostic crosspoint matrix connection manager.

See also
XPointStatic for the zero-heap template variant.

Constructor & Destructor Documentation

◆ XPoint() [1/3]

XPoint::XPoint ( uint8_t  rows,
uint8_t  cols,
RelayType  type = RE_NON_LATCHING,
uint16_t  pdur = 0 
)

Heap-allocating constructor.

Allocates rows*cols + rows² + cols bytes via new[]; freed in the destructor. Avoid on AVR with limited SRAM; prefer XPointStatic or the buffer constructor to eliminate heap use and fragmentation risk.

Parameters
[in]rowsNumber of matrix rows (1–255).
[in]colsNumber of matrix columns (1–255).
[in]typeRelay operating mode (default RE_NON_LATCHING).
[in]pdurCoil pulse duration in ms for RE_LATCHING_DUAL_COIL (default 0).

◆ XPoint() [2/3]

XPoint::XPoint ( uint8_t  rows,
uint8_t  cols,
bool *  state,
bool *  ilock,
bool *  excl,
RelayType  type = RE_NON_LATCHING,
uint16_t  pdur = 0 
)

Zero-heap buffer constructor.

All three arrays must be sized as specified and must outlive this object. The destructor does not free them.

Parameters
[in]rowsNumber of matrix rows.
[in]colsNumber of matrix columns.
[in]stateCaller-owned array of rows * cols bools.
[in]ilockCaller-owned array of rows * rows bools (symmetric interlock map).
[in]exclCaller-owned array of cols bools (exclusive-input flags).
[in]typeRelay operating mode.
[in]pdurCoil pulse duration in ms.

◆ ~XPoint()

XPoint::~XPoint ( )

Destructor. Frees heap buffers only when constructed with the heap constructor.

◆ XPoint() [3/3]

XPoint::XPoint ( const XPoint )
delete

Member Function Documentation

◆ begin()

void XPoint::begin ( )

Initialize hardware by calling drv->begin().

Call once after setDriver() and before any connect / disconnect calls.

◆ clearAll()

void XPoint::clearAll ( )

Disconnect all connected nodes and zero the state table.

For RE_LATCHING_DUAL_COIL, pulses the RESET coil on each connected node and registers pulse events (up to MAX_PULSES; excess nodes are silently skipped — their hardware timeout must de-energize any excess coils). Any stale in-flight SET-coil pulses are cancelled before registering the RESET pulses so freed slots remain available.

◆ connect()

bool XPoint::connect ( uint8_t  row,
uint8_t  col 
)

Connect row row to column col.

Applies interlock and exclusive-input rules before connecting. For RE_LATCHING_DUAL_COIL, returns false while a coil pulse is in-flight for this node — call update() each loop() to free pulse slots.

Parameters
[in]rowRow index (zero-based).
[in]colColumn index (zero-based).
Returns
true — node is now connected (or was already connected).
false — out of range, blocked by interlock / exclusive rule, or a latching-relay pulse is still in-flight.

◆ disconnect()

bool XPoint::disconnect ( uint8_t  row,
uint8_t  col 
)

Disconnect row row from column col.

For RE_LATCHING_DUAL_COIL, returns false while a coil pulse is in-flight for this node — call update() each loop() to free pulse slots.

Parameters
[in]rowRow index.
[in]colColumn index.
Returns
true — node is now disconnected (or was already disconnected).
false — out of range, or a latching-relay pulse is still in-flight.

◆ exclusiveInput()

void XPoint::exclusiveInput ( uint8_t  col)

Mark column col as exclusive: at most one row may connect at a time.

Parameters
[in]colColumn index.

◆ lockRows()

void XPoint::lockRows ( uint8_t  rowA,
uint8_t  rowB 
)

Prevent rowA and rowB from connecting to the same column simultaneously.

The interlock is symmetric; calling lockRows(0,1) and lockRows(1,0) are equivalent. Safe to call multiple times.

Parameters
[in]rowAFirst row index.
[in]rowBSecond row index.

◆ operator=()

XPoint & XPoint::operator= ( const XPoint )
delete

◆ setDriver()

void XPoint::setDriver ( XPointDriver drv)

Attach a driver backend.

Must be called before begin(). XPoint does not take ownership of drv.

Parameters
[in]drvPointer to a concrete XPointDriver implementation.

◆ setLevel()

bool XPoint::setLevel ( uint8_t  row,
uint8_t  col,
uint16_t  level 
)

analog-level connect / disconnect (PWM drivers).

  • level > 0: connecting path — interlock and exclusive-input rules apply.
  • level == 0: disconnecting path — rules are not checked.

The default setNodeLevel() delegates to setNodeHardware(), so binary drivers treat any non-zero level as "on" and 0 as "off". PWM-capable drivers (TLC59711) use the full 16-bit range.

Parameters
[in]rowRow index.
[in]colColumn index.
[in]levelDrive level 0x0000 (off) to 0xFFFF (full on).
Returns
true on success, false if blocked or out of range.

◆ update()

void XPoint::update ( )

Expire latching-relay coil pulses and call releaseNode() as needed.

Must be called every loop() iteration when using RE_LATCHING_DUAL_COIL. Returns immediately (no overhead) for RE_NON_LATCHING matrices. Calls commitPhysicalUpdates() once if any pulses were released.


The documentation for this class was generated from the following files: