|
| constexpr | RemoteLoadCore ()=default |
| |
| constexpr bool | isPending (uint8_t unitIdx) const |
| | True if a transmission is due for that unit.
|
| |
| constexpr uint8_t | payloadOf (uint8_t unitIdx) const |
| | Current payload of a unit, whether or not it has been sent.
|
| |
| void | reset () |
| | Return every unit to its power-on state.
|
| |
| template<uint8_t NumIds, typename Send> |
| void | sendPending (const uint8_t(&nodeIds)[NumIds], Send &&send) |
| | Hand every pending payload to send, addressed to its unit's node ID.
|
| |
| bool | takePending (uint8_t unitIdx, uint8_t &payload) |
| | Claim a pending transmission for one unit.
|
| |
| template<const auto & Map, uint8_t NumLoads> |
| void | updateLoads (const LoadStates(&loadStates)[NumLoads]) |
| | Rebuild every unit's payload from the current load states.
|
| |
template<uint8_t NumUnits>
class RemoteLoadCore< NumUnits >
Builds and schedules the RF payloads of every remote unit.
- Template Parameters
-
| NumUnits | Number of remote units, 0 to MAX_REMOTE_UNITS. |
The load map is a template argument of updateLoads() rather than read from the physicalLoadPin[] global: the tests pass maps of their own, and the compiler resolves every load's unit and payload bit, so the ISR only tests states and ORs bits.
The default constructor is constexpr and every member carries a brace-or-equal initialiser, so an instance at namespace scope is constant-initialized: it lands in .bss with no .init_array entry, and is dropped altogether by --gc-sections when unused.
Definition at line 100 of file remote_loads_core.h.
template<uint8_t NumUnits>
template<const auto & Map, uint8_t Unit, uint8_t I, uint8_t NumLoads>
template<uint8_t NumUnits>
template<uint8_t NumIds, typename Send>
| void RemoteLoadCore< NumUnits >::sendPending |
( |
const uint8_t(&) | nodeIds[NumIds], |
|
|
Send && | send ) |
|
inline |
Hand every pending payload to send, addressed to its unit's node ID.
Unit n (index n-1) goes to nodeIds[n-1]. The radio stays out of this class: the firmware passes a lambda around RFM69::send(), the native tests one that records what would have been sent.
- Parameters
-
| nodeIds | Node ID table, unit 1 first; at least NumUnits entries. |
| send | Callable as send(uint8_t nodeId, uint8_t payload). |
Definition at line 173 of file remote_loads_core.h.
template<uint8_t NumUnits>
| bool RemoteLoadCore< NumUnits >::takePending |
( |
uint8_t | unitIdx, |
|
|
uint8_t & | payload ) |
|
inline |
Claim a pending transmission for one unit.
Clears the pending flag, so a second call returns false until the state changes again or the refresh period elapses. Safe to call from loop() without disabling interrupts: flag and payload are single bytes, and if the ISR updates them in between, the newer payload is sent and the flag stays set, so at worst the same byte goes out twice.
- Parameters
-
| unitIdx | Zero-based unit index (unit number - 1). |
| payload | Receives the bitmask to transmit. |
- Returns
- true if a transmission is due.
Definition at line 149 of file remote_loads_core.h.
template<uint8_t NumUnits>
template<const auto & Map, uint8_t NumLoads>
Rebuild every unit's payload from the current load states.
Called once per mains cycle, from the ADC ISR. Local entries of the map are skipped, as is any entry naming a unit beyond NumUnits.
The map is a template argument, so the unit and the payload bit of every load are resolved at compile time: what is left at run time is, per remote load, one state test and one OR into a register.
- Template Parameters
-
| Map | The packed load map; must have static storage (a namespace-scope or static constexpr array). |
- Parameters
-
| loadStates | The current state of each load, in the same index space. |
Definition at line 126 of file remote_loads_core.h.