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, uint32_t *pool, RelayType type=RE_NON_LATCHING, uint16_t pdur=0)
 Zero-heap pool constructor.
 
 ~XPoint ()
 Destructor. Frees pool only when built with the heap constructor.
 
 XPoint (const XPoint &)=delete
 
XPointoperator= (const XPoint &)=delete
 
void setDriver (XPointDriver *drv)
 Attach a driver backend. Must be called before begin().
 
void begin ()
 Initialize hardware via drv->begin(). Call once after setDriver().
 
bool connect (uint8_t row, uint8_t col)
 Connect row to column.
 
bool disconnect (uint8_t row, uint8_t col)
 Disconnect row from column.
 
bool setLevel (uint8_t row, uint8_t col, uint16_t level)
 Analog-level connect / disconnect for PWM drivers.
 
void clearAll ()
 Disconnect all nodes, zeroing the state section of the pool.
 
void lockRows (uint8_t rowA, uint8_t rowB)
 Prevent rowA and rowB from sharing a 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.
 

Static Public Member Functions

static uint16_t poolWords (uint8_t rows, uint8_t cols)
 Number of uint32_t words needed for a pool of the given dimensions.
 

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 one BitPool large enough for state, ilock, and excl sections; freed in the destructor.

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

◆ XPoint() [2/3]

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

Zero-heap pool constructor.

pool must point to at least poolWords(rows, cols) uint32_t elements and must outlive this object. The destructor does not free it.

Parameters
[in]rowsNumber of matrix rows.
[in]colsNumber of matrix columns.
[in]poolCaller-owned word array; use poolWords() to size it.
[in]typeRelay operating mode.
[in]pdurCoil pulse duration in ms.

◆ ~XPoint()

XPoint::~XPoint ( )

Destructor. Frees pool only when built with the heap constructor.

◆ XPoint() [3/3]

XPoint::XPoint ( const XPoint )
delete

Member Function Documentation

◆ begin()

void XPoint::begin ( )

Initialize hardware via drv->begin(). Call once after setDriver().

◆ clearAll()

void XPoint::clearAll ( )

Disconnect all nodes, zeroing the state section of the pool.

For RE_LATCHING_DUAL_COIL pulses the RESET coil on each connected node. In-flight SET pulses are cancelled before registering RESET pulses so freed slots remain available. Nodes beyond MAX_PULSES are silently skipped.

◆ connect()

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

Connect row to column.

Applies interlock and exclusive-input rules. For RE_LATCHING_DUAL_COIL returns false while a coil pulse is in-flight for this node.

Returns
true if connected (or was already connected), false if blocked.

◆ disconnect()

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

Disconnect row from column.

For RE_LATCHING_DUAL_COIL returns false while a coil pulse is in-flight.

Returns
true if disconnected (or was already disconnected), false if blocked.

◆ exclusiveInput()

void XPoint::exclusiveInput ( uint8_t  col)

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

◆ lockRows()

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

Prevent rowA and rowB from sharing a column simultaneously.

Symmetric; lockRows(0,1) and lockRows(1,0) are equivalent.

◆ operator=()

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

◆ poolWords()

static uint16_t XPoint::poolWords ( uint8_t  rows,
uint8_t  cols 
)
inlinestatic

Number of uint32_t words needed for a pool of the given dimensions.

Use this to size the array passed to the pool constructor or XPointStatic.

Parameters
[in]rowsRow count.
[in]colsColumn count.
Returns
Word count, or 0 for degenerate (0-dim) matrices.

◆ setDriver()

void XPoint::setDriver ( XPointDriver drv)

Attach a driver backend. Must be called before begin().

◆ setLevel()

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

Analog-level connect / disconnect for PWM drivers.

level > 0: connecting path — interlock and exclusive rules apply. level == 0: disconnecting path — rules are bypassed.

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. No-op for RE_NON_LATCHING matrices.


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