|
XPoint 0.1.0
Hardware-agnostic crosspoint matrix routing library
|
Hardware-agnostic crosspoint matrix connection manager. More...
#include <XPoint.h>
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 | |
| XPoint & | operator= (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. | |
Hardware-agnostic crosspoint matrix connection manager.
| 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.
| [in] | rows | Number of matrix rows (1–255). |
| [in] | cols | Number of matrix columns (1–255). |
| [in] | type | Relay operating mode (default RE_NON_LATCHING). |
| [in] | pdur | Coil pulse duration in ms for RE_LATCHING_DUAL_COIL (default 0). |
| 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.
| [in] | rows | Number of matrix rows. |
| [in] | cols | Number of matrix columns. |
| [in] | state | Caller-owned array of rows * cols bools. |
| [in] | ilock | Caller-owned array of rows * rows bools (symmetric interlock map). |
| [in] | excl | Caller-owned array of cols bools (exclusive-input flags). |
| [in] | type | Relay operating mode. |
| [in] | pdur | Coil pulse duration in ms. |
| XPoint::~XPoint | ( | ) |
Destructor. Frees heap buffers only when constructed with the heap constructor.
|
delete |
| void XPoint::begin | ( | ) |
Initialize hardware by calling drv->begin().
Call once after setDriver() and before any connect / disconnect calls.
| 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.
| 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.
| [in] | row | Row index (zero-based). |
| [in] | col | Column index (zero-based). |
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. | 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.
| [in] | row | Row index. |
| [in] | col | Column index. |
true — node is now disconnected (or was already disconnected). false — out of range, or a latching-relay pulse is still in-flight. | void XPoint::exclusiveInput | ( | uint8_t | col | ) |
Mark column col as exclusive: at most one row may connect at a time.
| [in] | col | Column index. |
| 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.
| [in] | rowA | First row index. |
| [in] | rowB | Second row index. |
| void XPoint::setDriver | ( | XPointDriver * | drv | ) |
Attach a driver backend.
Must be called before begin(). XPoint does not take ownership of drv.
| [in] | drv | Pointer to a concrete XPointDriver implementation. |
| 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.
| [in] | row | Row index. |
| [in] | col | Column index. |
| [in] | level | Drive level 0x0000 (off) to 0xFFFF (full on). |
true on success, false if blocked or out of range. | 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.