|
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, 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 | |
| XPoint & | operator= (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. | |
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 one BitPool large enough for state, ilock, and excl sections; freed in the destructor.
| [in] | rows | Number of matrix rows (1–255). |
| [in] | cols | Number of matrix columns (1–255). |
| [in] | type | Relay operating mode. |
| [in] | pdur | Coil pulse duration in ms (RE_LATCHING_DUAL_COIL only). |
| 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.
| [in] | rows | Number of matrix rows. |
| [in] | cols | Number of matrix columns. |
| [in] | pool | Caller-owned word array; use poolWords() to size it. |
| [in] | type | Relay operating mode. |
| [in] | pdur | Coil pulse duration in ms. |
| XPoint::~XPoint | ( | ) |
Destructor. Frees pool only when built with the heap constructor.
|
delete |
| void XPoint::begin | ( | ) |
Initialize hardware via drv->begin(). Call once after setDriver().
| 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.
| 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.
| 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.
| void XPoint::exclusiveInput | ( | uint8_t | col | ) |
Mark column col as exclusive: at most one row may connect at a time.
| 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.
|
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.
| [in] | rows | Row count. |
| [in] | cols | Column count. |
| void XPoint::setDriver | ( | XPointDriver * | drv | ) |
Attach a driver backend. Must be called before begin().
| 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.
| 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.