36static_assert(
DATALOG_PERIOD_IN_SECONDS <= 30,
"**** Data log duration is too long and will lead to overflow ! 30 s at most. ****");
38static_assert(
Energy::isValidCalibration(
f_powerCal),
"******** Wrong power calibration ! Each value of f_powerCal must be positive and below 8. Please check your calibration.h ! ********");
40static_assert(
lpf_gain == 0.0F ||
alpha == 0.0F ||
CtFilter::isAccurate(
lpf_gain,
alpha),
"******** Wrong CT filter settings ! alpha must be from 0.00005 to below 0.0625 and lpf_gain from 0 to below 64. Please check your calibration.h ! ********");
50static_assert(!(
DUAL_TARIFF & (
ul_OFF_PEAK_DURATION > 12)),
"******** Off-peak duration cannot last more than 12 hours. Please check your config.h ! ********");
70static_assert(!
DUAL_TARIFF ||
check_boost_windows(),
"******** A scheduled boost starts or ends outside the off-peak period, or lasts 0 minutes. Please check scheduledBoosts in your config.h ! ********");
78static_assert(!
RELAY_DIVERSION | (
relays.filterDelay() * 60 /
DATALOG_PERIOD_IN_SECONDS <= UINT8_MAX),
"******** RELAY_FILTER_DELAY too long for DATALOG_PERIOD_IN_SECONDS: the filter can span at most 255 datalog periods (21 minutes at 5 s) ! Please check your config.h ! ********");
80static_assert(
NO_OF_DUMPLOADS > 0,
"Number of dump loads must be greater than 0");
90static_assert(
ROTATION_AFTER_SECONDS > 0,
"******** ROTATION_AFTER_SECONDS must be greater than 0 ! ********");
92static_assert(
ROTATION_AFTER_SECONDS < UINT16_MAX,
"******** ROTATION_AFTER_SECONDS cannot exceed 65534 seconds (about 18 hours) ! ********");
117constexpr bool claimPin(uint32_t &used,
const uint8_t pin)
119 const uint8_t bit{ pin > 31 ?
static_cast< uint8_t
>(31) : pin };
120 const bool free{ !
bit_read(used, bit) };
127 uint32_t used_pins{ 0 };
206 const auto relayPin =
relayDiverter.get_relay(idx).get_pin();
216 return {
true, used_pins };
222 uint16_t _enum_val{ 0 };
245template<
typename List >
248 uint16_t outputs{ 0 };
262 for (uint8_t
i = 0;
i != list.size(); ++
i)
264 if (list.getLocalBitmask(
i) & ~outputs)
280template<
typename List >
291 for (uint8_t
i = 0;
i != list.size(); ++
i)
293 if (list.getRemoteBitmask(
i) & ~existing)
326 bool pins_ok{
true };
330 const auto relayPin =
relayDiverter.get_relay(idx).get_pin();
361static_assert(
Load::isValidMap(
physicalLoadPin),
"******** Wrong load map ! Each local load needs a pin in 2..13. Please check physicalLoadPin in your config.h ! ********");
367static_assert(
check_load_priorities(),
"******** Load Priorities wrong ! Please check your config ! ********");
368static_assert(PRIORITY_ROTATION ==
RotationModes::OFF ||
rotationGroups.size() != 0,
"******** Priority rotation is on but rotationGroups is empty ! Please check rotationGroups in your config.h ! ********");
369static_assert(PRIORITY_ROTATION !=
RotationModes::OFF ||
rotationGroups.size() == 0,
"******** rotationGroups is set but priority rotation is OFF ! Please check rotationGroups in your config.h ! ********");
374static_assert(
check_pins().
unique,
"******** Duplicate pin definition ! Please check your config ! ********");
375static_assert((
check_pins().
used & B00000011) == 0,
"******** Pins 0 & 1 are reserved for RX/TX ! Please check your config ! ********");
376static_assert((
check_pins().
used & 0xFFFFC000UL) == 0,
"******** Pins 14 and above cannot be used (A0 to A5 are the analog inputs) ! Please check your config ! ********");
377static_assert(
check_relay_pins(),
"******** Wrong pin(s) configuration for relay(s) ********");
378static_assert(
check_relay_minimum_times(),
"******** A relay's minimum ON or OFF time cannot exceed 1092 minutes (about 18 hours) ! Please check relays in your config.h ! ********");
379static_assert(
check_override_targets(),
"******** An override pin forces a pin that is neither a local load nor a relay (REMOTE_LOAD() goes up to 7) ! Please check overridePins in your config.h ! ********");
380static_assert(
check_override_remote_targets(),
"******** An override pin forces a remote load that does not exist ! REMOTE_LOAD(n) counts from 0. Please check overridePins in your config.h ! ********");
381static_assert(!
DUAL_TARIFF ||
targetsAreOutputs(
boostSchedule),
"******** A scheduled boost forces something that is neither a local load nor a relay (is relay diversion on? REMOTE_LOAD() goes up to 7). Please check scheduledBoosts in your config.h ! ********");
382static_assert(!
DUAL_TARIFF ||
targetsAreRemoteLoads(
boostSchedule),
"******** A scheduled boost forces a remote load that does not exist (REMOTE_LOAD() counts from 0). Please check scheduledBoosts in your config.h ! ********");
384static_assert(!(
RF_CHIP_PRESENT && ((
check_pins().
used & 0x3C04) != 0)),
"******** Pins from RF chip are reserved ! Please check your config ! ********");
constexpr uint8_t loadPrioritiesAtStartup[NO_OF_DUMPLOADS]
constexpr bool ROUTER_OFF_PIN_PRESENT
constexpr ScheduledBoosts scheduledBoosts
constexpr bool RELAY_DIVERSION
constexpr bool OVERRIDE_PIN_PRESENT
constexpr uint32_t ROTATION_AFTER_SECONDS
constexpr uint8_t dualTariffPin
constexpr TemperatureSensing temperatureSensing
constexpr RelayEngine relays
constexpr uint8_t physicalLoadPin[NO_OF_DUMPLOADS]
constexpr bool DUAL_TARIFF
constexpr uint8_t diversionPin
constexpr OverridePins overridePins
constexpr RotationGroups rotationGroups
constexpr uint8_t NO_OF_DUMPLOADS
constexpr uint8_t ul_OFF_PEAK_DURATION
constexpr bool TEMP_SENSOR_PRESENT
constexpr int16_t iTemperatureThreshold
constexpr uint8_t routerOffPin
constexpr bool WATCHDOG_PIN_PRESENT
constexpr uint8_t BOOST_TEMP_SENSOR
constexpr bool DIVERSION_PIN_PRESENT
constexpr uint8_t rotationPin
constexpr uint8_t watchDogPin
The configuration as the firmware uses it: the settings, and what is built from them.
constexpr float f_voltageCal[NO_OF_PHASES]
constexpr uint8_t NO_OF_REMOTE_UNITS
constexpr BoostSchedule boostSchedule
constexpr RelayDiverter relayDiverter
constexpr float f_powerCal[NO_OF_PHASES]
constexpr OverrideTable overrideTable
constexpr uint8_t NO_OF_REMOTE_LOADS
Basic configuration values to be set by the end-user.
constexpr int16_t REQUIRED_EXPORT_IN_WATTS
constexpr conditional< DATALOG_PERIOD_IN_SECONDS *SUPPLY_FREQUENCY >=UINT8_MAX, uint16_t, uint8_t >::type DATALOG_PERIOD_IN_MAINS_CYCLES
constexpr uint8_t DATALOG_PERIOD_IN_SECONDS
constexpr uint8_t SUPPLY_FREQUENCY
constexpr int16_t DIVERSION_START_THRESHOLD_WATTS
The CT filter: a low-pass of the current added back with a gain, one per phase.
Integer arithmetic of the datalog: power and RMS voltage per phase.
constexpr int16_t TEMP_RANGE_LOW
constexpr int16_t TEMP_RANGE_HIGH
Integer arithmetic of the energy bucket.
constexpr uint8_t MAX_LOADS_PER_UNIT
constexpr uint8_t invalidRemoteUnitEntry
The entry Load::remote() returns for a unit outside 1..MAX_REMOTE_UNITS.
constexpr bool isAccurate(const float gain, const float alpha)
Whether the settings fit the fixed point, the coefficients within 1 % of them.
constexpr uint16_t vrmsFactor(const uint8_t datalogPeriodInSeconds)
Scaling of the datalog voltage, Vrms_L_x100.
constexpr bool isValidVoltageCalibration(const uint16_t factor, const float(&cal)[N])
Check that the voltage calibration values can be represented.
constexpr bool isValidCalibration(const float(&cal)[N])
Check that the calibration values can be represented.
constexpr bool isLocal(uint8_t entry)
True if the entry describes a locally driven load.
constexpr uint8_t maxLoadsPerUnit(const uint8_t(&map)[N])
Largest number of loads assigned to any single remote unit.
constexpr uint8_t pinOf(uint8_t entry)
The pin of the entry: TRIAC pin if local, status LED (0 = none) if remote.
constexpr bool isValidMap(const uint8_t(&map)[N])
Check that every entry of a load map designates a usable pin.
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 uint8_t ROUTER_NODE_ID
constexpr uint8_t REMOTE_NODE_ID[]
Node ID of each remote load unit, unit 1 first (only if REMOTE_LOADS_PRESENT=true)
constexpr uint8_t NETWORK_ID
constexpr bool noLoadTwice(const RotationGroups< NG, MaxPins > &groups, const uint8_t(&loadMap)[NL])
No load is named twice, within a group or across groups.
constexpr bool targetsAreLoads(const RotationGroups< NG, MaxPins > &groups, const uint8_t(&loadMap)[NL])
Every code of every group stands for at least one load.
constexpr bool groupsHaveTwoLoads(const RotationGroups< NG, MaxPins > &groups, const uint8_t(&loadMap)[NL])
Every group holds at least 2 loads.
constexpr bool groupsAreConsistent(const RotationGroups< NG, MaxPins > &groups, const uint8_t(&loadMap)[NL])
In each group, every load is local, or every load is on the same remote unit.
constexpr bool fitsInPeriod(const uint8_t noOfSensors, const uint8_t supplyFrequency, const uint16_t periodCycles)
Whether a round ends within its datalog period.
constexpr bool areValidNodeIds(const uint8_t(&nodeIds)[NumIds], uint8_t numUnits, uint8_t routerId)
Check the node IDs of the first numUnits remote units.
When a load is boosted during the off-peak period.
Result of check_pins(): whether every pin is used once, and the pins used.
Which 1-Wire transaction of the temperature sensors runs on which mains cycle.
constexpr void bit_set(T &_dest, const uint8_t bit)
Set the specified bit to 1.
constexpr uint8_t bit_read(const T &_src, const uint8_t bit)
Read the specified bit.
constexpr uint8_t unused_pin
Some utility functions for pins manipulation.
RF module support for RFM69.
constexpr bool RF_CHIP_PRESENT
constexpr uint16_t check_relay_pins()
constexpr bool targetsAreOutputs(const List &list)
Overrides and boosts reach the outputs through the load states and the relay engine only,...
constexpr bool check_load_priorities()
constexpr bool targetsAreRemoteLoads(const List &list)
Each REMOTE_LOAD(n) target of an entry of list must be an existing remote load.
constexpr bool check_boost_windows()
Every scheduled boost lies within the off-peak period and lasts: otherwise, it never runs (LAST(HOURS...
constexpr bool claimPin(uint32_t &used, const uint8_t pin)
Marks pin as used in used.
constexpr bool check_override_targets()
Each override pin may only force local loads and relays.
constexpr bool check_override_remote_targets()
Each REMOTE_LOAD(n) target of an override pin must be an existing remote load.
constexpr bool check_relay_minimum_times()
Each relay's minimum ON and OFF times fit in 16 bits of seconds: 1092 minutes at most.
constexpr PinCheck check_pins()