3-phase PV router
Loading...
Searching...
No Matches
utils_override_helpers.h
Go to the documentation of this file.
1
16
17#ifndef UTILS_OVERRIDE_HELPERS_H
18#define UTILS_OVERRIDE_HELPERS_H
19
20#include "utils_override.h"
21
27constexpr uint8_t LOAD(uint8_t loadNum)
28{
29 return physicalLoadPin[loadNum];
30}
31
38constexpr uint8_t RELAY(uint8_t relayNum)
39{
40 return relays.get_relay(relayNum).get_pin();
41}
42
47constexpr uint16_t ALL_LOADS()
48{
49 uint16_t mask{ 0 };
50 for (uint8_t i = 0; i < NO_OF_DUMPLOADS; ++i)
51 {
53 }
54 return mask;
55}
56
61constexpr uint16_t ALL_RELAYS()
62{
63 if constexpr (RELAY_DIVERSION)
64 {
65 uint16_t mask{ 0 };
66 for (uint8_t i = 0; i < relays.size(); ++i)
67 {
68 bit_set(mask, relays.get_relay(i).get_pin());
69 }
70 return mask;
71 }
72 else
73 {
74 return 0;
75 }
76}
77
82constexpr uint16_t ALL_LOADS_AND_RELAYS()
83{
84 return ALL_LOADS() | ALL_RELAYS();
85}
86
87#endif /* UTILS_OVERRIDE_HELPERS_H */
constexpr bool RELAY_DIVERSION
Definition config.h:51
constexpr RelayEngine relays
Definition config.h:126
constexpr uint8_t physicalLoadPin[NO_OF_DUMPLOADS]
Definition config.h:92
constexpr uint8_t NO_OF_DUMPLOADS
Definition config.h:42
uint8_t i
Definition test_main.cpp:92
constexpr void bit_set(T &_dest, const uint8_t bit)
Set the specified bit to 1.
Definition utils_bits.h:27
Compile-time utilities for managing override pins and index-to-bitmask mapping.
constexpr uint16_t ALL_RELAYS()
Returns a bitmask representing all relay pins.
constexpr uint16_t ALL_LOADS()
Returns a bitmask representing all load pins.
constexpr uint8_t LOAD(uint8_t loadNum)
Returns the pin number for a given load index at compile time.
constexpr uint8_t RELAY(uint8_t relayNum)
Returns the pin number for a given relay index at compile time.
constexpr uint16_t ALL_LOADS_AND_RELAYS()
Returns a bitmask representing all loads and all relays.