3-phase PV router
Loading...
Searching...
No Matches
Load Namespace Reference

Authoring and decoding helpers for the packed load map. More...

Classes

struct  OverrideMasks
 Override bit of each load, in the local or in the remote override bitmask. More...
 

Functions

template<uint8_t N>
constexpr uint8_t bitOf (const uint8_t(&map)[N], uint8_t loadNum)
 Rank of a load among the loads of its own unit, in ascending map order.
 
template<uint8_t N>
constexpr uint8_t countRemoteLoads (const uint8_t(&map)[N])
 Number of entries of the map that are driven remotely.
 
template<uint8_t N>
constexpr uint8_t countUnits (const uint8_t(&map)[N])
 Highest remote unit number appearing in the map (0 if fully local).
 
template<uint8_t N>
constexpr bool hasValidRemoteUnits (const uint8_t(&map)[N])
 Check that every remote load of a map was declared with a unit from 1 to 3.
 
constexpr bool isLocal (uint8_t entry)
 True if the entry describes a locally driven load.
 
template<uint8_t N>
constexpr bool isValidMap (const uint8_t(&map)[N])
 Check that every entry of a load map designates a usable pin.
 
constexpr uint8_t local (uint8_t pin)
 Declares a load driven locally by the router.
 
template<uint8_t N>
constexpr uint8_t maxLoadsPerUnit (const uint8_t(&map)[N])
 Largest number of loads assigned to any single remote unit.
 
template<uint8_t N>
constexpr OverrideMasks< N > overrideMasks (const uint8_t(&map)[N])
 Build the override bits of a load map.
 
constexpr uint8_t pinOf (uint8_t entry)
 The pin of the entry: TRIAC pin if local, status LED (0 = none) if remote.
 
constexpr uint8_t remote (uint8_t unit, uint8_t ledPin=0)
 Declares a load driven by a remote unit over RF.
 
template<uint8_t N>
constexpr uint8_t remoteOrdinal (const uint8_t(&map)[N], uint8_t loadNum)
 Rank of a remote load among the remote loads, in ascending map order.
 
constexpr uint8_t unitOf (uint8_t entry)
 The owning unit of the entry: 0 for a local load, 1..3 for a remote one.
 

Detailed Description

Authoring and decoding helpers for the packed load map.

Function Documentation

◆ bitOf()

template<uint8_t N>
uint8_t Load::bitOf ( const uint8_t(&) map[N],
uint8_t loadNum )
constexpr

Rank of a load among the loads of its own unit, in ascending map order.

This is the bit position of the load inside its unit's RF payload.

Definition at line 195 of file load_map.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ countRemoteLoads()

template<uint8_t N>
uint8_t Load::countRemoteLoads ( const uint8_t(&) map[N])
constexpr

Number of entries of the map that are driven remotely.

Definition at line 127 of file load_map.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ countUnits()

template<uint8_t N>
uint8_t Load::countUnits ( const uint8_t(&) map[N])
constexpr

Highest remote unit number appearing in the map (0 if fully local).

Definition at line 110 of file load_map.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hasValidRemoteUnits()

template<uint8_t N>
bool Load::hasValidRemoteUnits ( const uint8_t(&) map[N])
constexpr

Check that every remote load of a map was declared with a unit from 1 to 3.

Load::remote() returns invalidRemoteUnitEntry otherwise: see there.

Definition at line 288 of file load_map.h.

Here is the caller graph for this function:

◆ isLocal()

bool Load::isLocal ( uint8_t entry)
constexpr

True if the entry describes a locally driven load.

Definition at line 89 of file load_map.h.

Here is the caller graph for this function:

◆ isValidMap()

template<uint8_t N>
bool Load::isValidMap ( const uint8_t(&) map[N])
constexpr

Check that every entry of a load map designates a usable pin.

A local load needs a real TRIAC pin, 2..13 (0 and 1 are the serial interface, 14 and above do not exist). A remote load needs no pin, but its optional status LED, when present, obeys the same range.

This is also what catches an entry left at unused_pin: 0xFF decodes as unit 3 / pin 63, which is out of range.

Definition at line 258 of file load_map.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ local()

uint8_t Load::local ( uint8_t pin)
constexpr

Declares a load driven locally by the router.

Parameters
pinThe digital pin of the TRIAC output.

Definition at line 68 of file load_map.h.

Here is the caller graph for this function:

◆ maxLoadsPerUnit()

template<uint8_t N>
uint8_t Load::maxLoadsPerUnit ( const uint8_t(&) map[N])
constexpr

Largest number of loads assigned to any single remote unit.

Definition at line 144 of file load_map.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ overrideMasks()

template<uint8_t N>
OverrideMasks< N > Load::overrideMasks ( const uint8_t(&) map[N])
constexpr

Build the override bits of a load map.

An entry out of range (rejected by isValidMap() and the remote load count checks) gets no bit, so that the error reported is that one.

Parameters
mapThe load map.

Definition at line 230 of file load_map.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pinOf()

uint8_t Load::pinOf ( uint8_t entry)
constexpr

The pin of the entry: TRIAC pin if local, status LED (0 = none) if remote.

Definition at line 101 of file load_map.h.

Here is the caller graph for this function:

◆ remote()

uint8_t Load::remote ( uint8_t unit,
uint8_t ledPin = 0 )
constexpr

Declares a load driven by a remote unit over RF.

Parameters
unitThe remote unit number (1..3).
ledPinOptional status LED pin on the router, 0 for none.
Returns
The packed entry, or invalidRemoteUnitEntry if the unit is not 1..MAX_REMOTE_UNITS.

Definition at line 79 of file load_map.h.

Here is the caller graph for this function:

◆ remoteOrdinal()

template<uint8_t N>
uint8_t Load::remoteOrdinal ( const uint8_t(&) map[N],
uint8_t loadNum )
constexpr

Rank of a remote load among the remote loads, in ascending map order.

This is the ordinal used by the virtual-pin space of the override subsystem (REMOTE_PIN_BASE + ordinal) and by bit 16+ordinal of the ALL_REMOTE_LOADS() bitmask.

Parameters
mapThe load map.
loadNumIndex into the map, which must designate a remote load.

Definition at line 176 of file load_map.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ unitOf()

uint8_t Load::unitOf ( uint8_t entry)
constexpr

The owning unit of the entry: 0 for a local load, 1..3 for a remote one.

Definition at line 95 of file load_map.h.

Here is the caller graph for this function: