39 __attribute__((always_inline))
static void switched(
const uint8_t pin,
const bool on)
43 statusln(on ? F(
"Relay turned ON!") : F(
"Relay turned OFF!"));
67 info(F(
"\tRelay configuration: #"));
70 info(F(
"\t\tPin is "));
73 info(F(
"\t\tSurplus threshold: "));
76 info(F(
"\t\tImport threshold: "));
80 infoln(F(
" (import mode)"));
84 info(F(
" (surplus mode: turn OFF when surplus < "));
89 info(F(
"\t\tMinimum working time in minutes: "));
92 info(F(
"\t\tMinimum stop time in minutes: "));
110template< u
int8_t N, u
int8_t D = 10 >
144 template< u
int16_t V >
148 static_assert(V <= UINT8_MAX,
"******** RELAY_FILTER_DELAY cannot exceed 255 minutes ! Please check your config.h ! ********");
149 static_assert(V == D,
"******** The MINUTES() given to RelayDiverter differs from its template parameter D (RELAY_FILTER_DELAY) ! Please check your config.h ! ********");
170 infoln(F(
"*** Relay(s) configuration ***"));
171 info(F(
"\tSliding average: "));
174 for (uint8_t
i = 0;
i < N; ++
i)
181 template< uint8_t... I >
184 relays.get_relay(I).minON,
relays.get_relay(I).minOFF }... })
193template< u
int8_t N, u
int8_t D >
196template< u
int8_t N, u
int16_t D >
199template< u
int8_t N, u
int8_t D >
Manages a collection of relays and their behavior based on surplus and import thresholds.
constexpr RelayDiverter(integral_constant< uint8_t, D >, const relayOutput(&ref)[N])
Construct a list of relays with a custom sliding average.
constexpr RelayDiverter(integral_constant< uint16_t, V >, const relayOutput(&ref)[N])
Construct a list of relays with a custom sliding average, given with MINUTES().
constexpr RelayDiverter(const relayOutput(&ref)[N])
Construct a list of relays.
void printRelayEngineConfiguration() const
Print the configuration of each relay.
constexpr RelayDiverter(const RelayEngine< N, D > &relays)
The relays of config.h.
RelayLogic::Engine< relayOutput, N, D > Base
constexpr RelayDiverter(const RelayEngine< N, D > &relays, index_sequence< I... >)
The relays, as in config.h: the sliding average and the settings of each relay.
A collection of relays, switched one at a time from a sliding average.
const relayOutput relay[N]
The state of one relay, and its decisions.
constexpr auto get_minON() const
constexpr auto get_minOFF() const
constexpr auto get_surplusThreshold() const
constexpr auto get_importThreshold() const
constexpr auto get_pin() const
Represents a single relay configuration and its behavior.
void printRelayConfiguration(uint8_t idx) const
Print the configuration of the current relay-diversion.
constexpr RelayEngine relays
The text output: informational messages (info) and debug messages (debug)
void infoln(const Args &... args)
Print an informational message and a line end, as Serial.println() does.
void statusln(const Args &... args)
Print a status message and a line end, as Serial.println() does (human-readable output only).
void info(const Args &... args)
Print an informational message, as Serial.print() does.
typename make_index_sequence_impl< N >::type make_index_sequence
index_sequence< 0, 1, ..., N - 1 >.
Decisions of the relay diversion: which relay switches, and when.
The output of a relay in the firmware: its pin, and a status message.
static void switched(const uint8_t pin, const bool on)
Called on each change of a relay, before its state changes.
The indexes I..., as a type.
Some useful but missing stl functions templates.
Some basics classes/types.
Some utility functions for pins manipulation.
void setPinState(const uint8_t pin, const bool bState)
Set the Pin state for the specified pin.
RelayDiverter(const relayOutput(&)[N]) -> RelayDiverter< N, 10 >