3-phase PV router
Loading...
Searching...
No Matches
config_types.h File Reference

What config.h is written with: its types, constants and helpers. More...

#include <stdint.h>
#include "type_traits.hpp"
#include "load_map.h"
#include "utils_bits.h"
Include dependency graph for config_types.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  BoostEntry< MaxPins >
 When a set of loads is boosted: a window and the targets. More...
 
struct  BoostLength
 How long a boost lasts, in minutes, or UNTIL_THE_END. More...
 
struct  BoostStart
 Where a boost starts: minutes after the start of the off-peak period, or before its end if fromEnd. More...
 
struct  BoostWindow
 When a load is boosted during the off-peak period. More...
 
struct  DeviceAddress
 Structure representing the address of a device. More...
 
struct  KeyIndexPair< MaxPins >
 Structure holding a pin and its associated index list. More...
 
struct  Minutes
 A number of minutes: the unit of the scheduled boosts, built with HOURS() or MINUTES(). More...
 
class  OverridePins< N, MaxPins >
 The override pins, as in config.h: each pin with the targets it forces. More...
 
struct  PinList< MaxPins >
 Wrapper for a list of pins, constructible from variadic arguments. More...
 
class  RelayEngine< N, D >
 The relays, as in config.h: the sliding average and the settings of each relay. More...
 
struct  RelaySetting
 The settings of one relay, as in config.h: { pin, surplus, import, minON, minOFF }. More...
 
class  RotationGroups< N, MaxPins >
 The rotation groups, as in config.h: the loads that take turns at the top of the priority list, one group per appliance (the elements of a 3-phase water heater). More...
 
class  RotationGroups< 0, MaxPins >
 No rotation group. More...
 
class  ScheduledBoosts< N, MaxPins >
 The scheduled boosts, as in config.h: each window with the targets it forces. More...
 
class  ScheduledBoosts< 0, MaxPins >
 No boost at all. More...
 
class  TemperatureSensing< N >
 The temperature sensors, as in config.h: the pin of the bus and the address of each sensor. More...
 
struct  RotationGroups< N, MaxPins >::Ten
 

Namespaces

namespace  TargetCode
 The codes LOAD(), RELAY() and ALL_...() put in a target list.
 

Typedefs

using RotationGroupTargets = PinList< 16 >
 

Enumerations

enum class  PcbVersion : uint8_t { OLD , NEW }
 
enum class  RotationModes : uint8_t { OFF , AUTO , PIN }
 
enum class  SerialOutputType { HumanReadable , IoT , JSON }
 

Functions

constexpr uint8_t ALL_LOADS ()
 Every load, local and remote.
 
constexpr uint8_t ALL_LOADS_AND_RELAYS ()
 Every load and every relay.
 
constexpr uint8_t ALL_LOCAL_LOADS ()
 Every local load.
 
constexpr uint8_t ALL_RELAYS ()
 Every relay (none without relay diversion).
 
constexpr uint8_t ALL_REMOTE_LOADS ()
 Every remote load.
 
constexpr BoostStart BEFORE_END (const Minutes m)
 A start m before the end of the off-peak period.
 
constexpr BoostWindow FIRST (const Minutes d)
 The first d of the off-peak period.
 
constexpr BoostLength FOR (const Minutes m)
 A boost lasting m.
 
constexpr BoostStart FROM_START (const Minutes m)
 A start m after the beginning of the off-peak period.
 
constexpr BoostWindow LAST (const Minutes d)
 The last d of the off-peak period, until the end.
 
constexpr uint8_t LOAD (const uint8_t loadNum)
 Load loadNum of physicalLoadPin[], local or remote (0, no load, if out of range).
 
constexpr uint8_t LOCAL_LOAD (const uint8_t loadNum)
 Same as LOAD(), for a load known to be local.
 
template<uint8_t MaxPins, uint8_t N>
 OverridePins (const KeyIndexPair< MaxPins >(&)[N]) -> OverridePins< N, MaxPins >
 Deduction guide: N and MaxPins from the list.
 
constexpr uint8_t RELAY (const uint8_t relayNum)
 Relay relayNum of relays (0, no relay, if out of range or without relay diversion).
 
template<uint8_t N>
 RelayEngine (const RelaySetting(&)[N]) -> RelayEngine< N, 10 >
 Deduction guide: the default sliding average.
 
template<uint8_t N, uint16_t D>
 RelayEngine (integral_constant< uint16_t, D >, const RelaySetting(&)[N]) -> RelayEngine< N, static_cast< uint8_t >(D) >
 Deduction guide: the sliding average from MINUTES().
 
template<uint8_t N, uint8_t D>
 RelayEngine (integral_constant< uint8_t, D >, const RelaySetting(&)[N]) -> RelayEngine< N, D >
 Deduction guide: the sliding average as an integral_constant< uint8_t >.
 
constexpr uint8_t REMOTE_LOAD (const uint8_t loadNum)
 The loadNum-th REMOTE load, counting remote loads only, in physicalLoadPin[] order.
 
 RotationGroups () -> RotationGroups< 0 >
 Deduction guides: the number of groups is the number of lists.
 
 RotationGroups (const RotationGroupTargets &) -> RotationGroups< 1 >
 
 RotationGroups (const RotationGroupTargets &, const RotationGroupTargets &) -> RotationGroups< 2 >
 
 RotationGroups (const RotationGroupTargets &, const RotationGroupTargets &, const RotationGroupTargets &) -> RotationGroups< 3 >
 
 RotationGroups (const RotationGroupTargets &, const RotationGroupTargets &, const RotationGroupTargets &, const RotationGroupTargets &) -> RotationGroups< 4 >
 
 RotationGroups (const RotationGroupTargets &, const RotationGroupTargets &, const RotationGroupTargets &, const RotationGroupTargets &, const RotationGroupTargets &) -> RotationGroups< 5 >
 
 RotationGroups (const RotationGroupTargets &, const RotationGroupTargets &, const RotationGroupTargets &, const RotationGroupTargets &, const RotationGroupTargets &, const RotationGroupTargets &) -> RotationGroups< 6 >
 
 RotationGroups (const RotationGroupTargets &, const RotationGroupTargets &, const RotationGroupTargets &, const RotationGroupTargets &, const RotationGroupTargets &, const RotationGroupTargets &, const RotationGroupTargets &) -> RotationGroups< 7 >
 
 RotationGroups (const RotationGroupTargets &, const RotationGroupTargets &, const RotationGroupTargets &, const RotationGroupTargets &, const RotationGroupTargets &, const RotationGroupTargets &, const RotationGroupTargets &, const RotationGroupTargets &) -> RotationGroups< 8 >
 
 RotationGroups (const RotationGroupTargets &, const RotationGroupTargets &, const RotationGroupTargets &, const RotationGroupTargets &, const RotationGroupTargets &, const RotationGroupTargets &, const RotationGroupTargets &, const RotationGroupTargets &, const RotationGroupTargets &) -> RotationGroups< 9 >
 
 RotationGroups (const RotationGroupTargets &, const RotationGroupTargets &, const RotationGroupTargets &, const RotationGroupTargets &, const RotationGroupTargets &, const RotationGroupTargets &, const RotationGroupTargets &, const RotationGroupTargets &, const RotationGroupTargets &, const RotationGroupTargets &) -> RotationGroups< 10 >
 
 ScheduledBoosts () -> ScheduledBoosts< 0 >
 Deduction guide: no argument, no boost.
 
template<uint8_t MaxPins, uint8_t N>
 ScheduledBoosts (const BoostEntry< MaxPins >(&)[N]) -> ScheduledBoosts< N, MaxPins >
 Deduction guide, as for OverridePins.
 

Variables

constexpr uint8_t TargetCode::ALL_LOADS { 0xF2 }
 
constexpr uint8_t TargetCode::ALL_LOADS_AND_RELAYS { 0xF4 }
 
constexpr uint8_t TargetCode::ALL_LOCAL_LOADS { 0xF0 }
 
constexpr uint8_t TargetCode::ALL_RELAYS { 0xF3 }
 
constexpr uint8_t TargetCode::ALL_REMOTE_LOADS { 0xF1 }
 
constexpr uint8_t TargetCode::LOAD { 0x40 }
 
constexpr uint8_t TargetCode::LOCAL_LOAD { 0x60 }
 
constexpr uint8_t LOCAL_MASK_BITS { 16 }
 
constexpr uint8_t TargetCode::MAX_LOADS { 32 }
 
constexpr uint8_t TargetCode::MAX_LOCAL_LOADS { 16 }
 
constexpr uint8_t TargetCode::MAX_RELAYS { 16 }
 
constexpr uint8_t TargetCode::RELAY { 0x70 }
 
constexpr uint8_t REMOTE_MASK_BITS { 8 }
 
constexpr uint8_t REMOTE_PIN_BASE { 128 }
 Base value for virtual pins representing remote loads.
 
constexpr uint16_t UNTIL_THE_END { UINT16_MAX }
 The length of a boost that only the meter ends: the end of the off-peak period stops it anyway.
 

Detailed Description

What config.h is written with: its types, constants and helpers.

Author
Frédéric Metrich (frede.nosp@m.ric..nosp@m.metri.nosp@m.ch@l.nosp@m.ive.f.nosp@m.r)
Version
1.0
Date
2026-11-26

config.h includes this file and nothing else. Nothing here depends on a setting, so config.h reads on its own, top to bottom, for the compiler as for the configurator. Nothing here depends on Arduino either: the native tests build it on the PC.

The settings types (RelayEngine, OverridePins, ScheduledBoosts, RotationGroups, TemperatureSensing) only hold what config.h says. The objects the firmware works with are built from them in config_derived.h, which the code includes instead of config.h.

Definition in file config_types.h.

Typedef Documentation

◆ RotationGroupTargets

the targets of one rotation group

Definition at line 601 of file config_types.h.

Enumeration Type Documentation

◆ PcbVersion

enum class PcbVersion : uint8_t
strong

Motherboard: each has its own analog inputs and ADC reference (adc_chain.h)

Enumerator
OLD 

the former 3-phase board: ADC reference AVCC (= VCC, 5 V or 3.3 V)

NEW 

the universal 3phaseDiverter board (rev. 6.0 and later): internal 1.1 V ADC reference

Definition at line 39 of file config_types.h.

◆ RotationModes

enum class RotationModes : uint8_t
strong

Rotation modes

Enumerator
OFF 

Off

AUTO 

Once a day

PIN 

Pin triggered

Definition at line 46 of file config_types.h.

◆ SerialOutputType

enum class SerialOutputType
strong

Enum for serial output types

Enumerator
HumanReadable 

Human-readable output for commissioning

IoT 

Output for HomeAssistant or similar

JSON 

Output in JSON format

Definition at line 31 of file config_types.h.

Function Documentation

◆ ALL_LOADS()

uint8_t ALL_LOADS ( )
constexpr

Every load, local and remote.

Definition at line 132 of file config_types.h.

Here is the caller graph for this function:

◆ ALL_LOADS_AND_RELAYS()

uint8_t ALL_LOADS_AND_RELAYS ( )
constexpr

Every load and every relay.

Definition at line 144 of file config_types.h.

Here is the caller graph for this function:

◆ ALL_LOCAL_LOADS()

uint8_t ALL_LOCAL_LOADS ( )
constexpr

Every local load.

Definition at line 120 of file config_types.h.

Here is the caller graph for this function:

◆ ALL_RELAYS()

uint8_t ALL_RELAYS ( )
constexpr

Every relay (none without relay diversion).

Definition at line 138 of file config_types.h.

Here is the caller graph for this function:

◆ ALL_REMOTE_LOADS()

uint8_t ALL_REMOTE_LOADS ( )
constexpr

Every remote load.

Definition at line 126 of file config_types.h.

Here is the caller graph for this function:

◆ BEFORE_END()

BoostStart BEFORE_END ( const Minutes m)
constexpr

A start m before the end of the off-peak period.

Definition at line 395 of file config_types.h.

Here is the caller graph for this function:

◆ FIRST()

BoostWindow FIRST ( const Minutes d)
constexpr

The first d of the off-peak period.

Definition at line 412 of file config_types.h.

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

◆ FOR()

BoostLength FOR ( const Minutes m)
constexpr

A boost lasting m.

Note
MINUTES(65535) would read as UNTIL_THE_END: it becomes 65534, which still ends after any off-peak period, so validation.h rejects it instead of boosting until the end.

Definition at line 406 of file config_types.h.

Here is the caller graph for this function:

◆ FROM_START()

BoostStart FROM_START ( const Minutes m)
constexpr

A start m after the beginning of the off-peak period.

Definition at line 389 of file config_types.h.

Here is the caller graph for this function:

◆ LAST()

BoostWindow LAST ( const Minutes d)
constexpr

The last d of the off-peak period, until the end.

Definition at line 418 of file config_types.h.

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

◆ LOAD()

uint8_t LOAD ( const uint8_t loadNum)
constexpr

Load loadNum of physicalLoadPin[], local or remote (0, no load, if out of range).

Definition at line 93 of file config_types.h.

Here is the caller graph for this function:

◆ LOCAL_LOAD()

uint8_t LOCAL_LOAD ( const uint8_t loadNum)
constexpr

Same as LOAD(), for a load known to be local.

Definition at line 99 of file config_types.h.

Here is the caller graph for this function:

◆ OverridePins()

template<uint8_t MaxPins, uint8_t N>
OverridePins ( const KeyIndexPair< MaxPins > (&)[N]) -> OverridePins< N, MaxPins >

Deduction guide: N and MaxPins from the list.

◆ RELAY()

uint8_t RELAY ( const uint8_t relayNum)
constexpr

Relay relayNum of relays (0, no relay, if out of range or without relay diversion).

Definition at line 114 of file config_types.h.

Here is the caller graph for this function:

◆ RelayEngine() [1/3]

template<uint8_t N>
RelayEngine ( const RelaySetting(&)[N]) -> RelayEngine< N, 10 >

Deduction guide: the default sliding average.

◆ RelayEngine() [2/3]

template<uint8_t N, uint16_t D>
RelayEngine ( integral_constant< uint16_t, D > ,
const RelaySetting(&)[N] ) -> RelayEngine< N, static_cast< uint8_t >(D) >

Deduction guide: the sliding average from MINUTES().

◆ RelayEngine() [3/3]

template<uint8_t N, uint8_t D>
RelayEngine ( integral_constant< uint8_t, D > ,
const RelaySetting(&)[N] ) -> RelayEngine< N, D >

Deduction guide: the sliding average as an integral_constant< uint8_t >.

◆ REMOTE_LOAD()

uint8_t REMOTE_LOAD ( const uint8_t loadNum)
constexpr

The loadNum-th REMOTE load, counting remote loads only, in physicalLoadPin[] order.

Returns
its virtual pin, REMOTE_PIN_BASE + loadNum (0, no load, from REMOTE_MASK_BITS on).

Definition at line 108 of file config_types.h.

◆ RotationGroups() [1/11]

RotationGroups ( ) -> RotationGroups< 0 >

Deduction guides: the number of groups is the number of lists.

◆ RotationGroups() [2/11]

RotationGroups ( const RotationGroupTargets & ) -> RotationGroups< 1 >

◆ RotationGroups() [3/11]

RotationGroups ( const RotationGroupTargets & ,
const RotationGroupTargets &  ) -> RotationGroups< 2 >

◆ RotationGroups() [4/11]

RotationGroups ( const RotationGroupTargets & ,
const RotationGroupTargets & ,
const RotationGroupTargets &  ) -> RotationGroups< 3 >

◆ RotationGroups() [5/11]

RotationGroups ( const RotationGroupTargets & ,
const RotationGroupTargets & ,
const RotationGroupTargets & ,
const RotationGroupTargets &  ) -> RotationGroups< 4 >

◆ RotationGroups() [6/11]

RotationGroups ( const RotationGroupTargets & ,
const RotationGroupTargets & ,
const RotationGroupTargets & ,
const RotationGroupTargets & ,
const RotationGroupTargets &  ) -> RotationGroups< 5 >

◆ RotationGroups() [7/11]

RotationGroups ( const RotationGroupTargets & ,
const RotationGroupTargets & ,
const RotationGroupTargets & ,
const RotationGroupTargets & ,
const RotationGroupTargets & ,
const RotationGroupTargets &  ) -> RotationGroups< 6 >

◆ RotationGroups() [8/11]

RotationGroups ( const RotationGroupTargets & ,
const RotationGroupTargets & ,
const RotationGroupTargets & ,
const RotationGroupTargets & ,
const RotationGroupTargets & ,
const RotationGroupTargets & ,
const RotationGroupTargets &  ) -> RotationGroups< 7 >

◆ RotationGroups() [9/11]

RotationGroups ( const RotationGroupTargets & ,
const RotationGroupTargets & ,
const RotationGroupTargets & ,
const RotationGroupTargets & ,
const RotationGroupTargets & ,
const RotationGroupTargets & ,
const RotationGroupTargets & ,
const RotationGroupTargets &  ) -> RotationGroups< 8 >

◆ RotationGroups() [10/11]

RotationGroups ( const RotationGroupTargets & ,
const RotationGroupTargets & ,
const RotationGroupTargets & ,
const RotationGroupTargets & ,
const RotationGroupTargets & ,
const RotationGroupTargets & ,
const RotationGroupTargets & ,
const RotationGroupTargets & ,
const RotationGroupTargets &  ) -> RotationGroups< 9 >

◆ RotationGroups() [11/11]

RotationGroups ( const RotationGroupTargets & ,
const RotationGroupTargets & ,
const RotationGroupTargets & ,
const RotationGroupTargets & ,
const RotationGroupTargets & ,
const RotationGroupTargets & ,
const RotationGroupTargets & ,
const RotationGroupTargets & ,
const RotationGroupTargets & ,
const RotationGroupTargets &  ) -> RotationGroups< 10 >

◆ ScheduledBoosts() [1/2]

ScheduledBoosts ( ) -> ScheduledBoosts< 0 >

Deduction guide: no argument, no boost.

◆ ScheduledBoosts() [2/2]

template<uint8_t MaxPins, uint8_t N>
ScheduledBoosts ( const BoostEntry< MaxPins > (&)[N]) -> ScheduledBoosts< N, MaxPins >

Deduction guide, as for OverridePins.

Variable Documentation

◆ LOCAL_MASK_BITS

uint8_t LOCAL_MASK_BITS { 16 }
inlineconstexpr

pins in a target's local mask (uint16_t): D0-D15

Definition at line 64 of file config_types.h.

◆ REMOTE_MASK_BITS

uint8_t REMOTE_MASK_BITS { 8 }
inlineconstexpr

remote loads in a target's remote mask (uint8_t)

Definition at line 65 of file config_types.h.

◆ REMOTE_PIN_BASE

uint8_t REMOTE_PIN_BASE { 128 }
inlineconstexpr

Base value for virtual pins representing remote loads.

Values >= REMOTE_PIN_BASE are virtual pins for remote loads. REMOTE_LOAD(0) returns 128, REMOTE_LOAD(1) returns 129, etc.

Definition at line 62 of file config_types.h.

◆ UNTIL_THE_END

uint16_t UNTIL_THE_END { UINT16_MAX }
inlineconstexpr

The length of a boost that only the meter ends: the end of the off-peak period stops it anyway.

Definition at line 373 of file config_types.h.