3-phase PV router
Loading...
Searching...
No Matches
types.h
Go to the documentation of this file.
1
12
13#ifndef TYPES_H
14#define TYPES_H
15
16#include <Arduino.h>
17
18#include "type_traits.hpp"
19
20#include "config_types.h" // the enums of config.h (SerialOutputType, PcbVersion, RotationModes)
21
22#include "constants.h"
23#include "load_map.h" // LoadStates and the packed load-map encoding
24#include "load_priorities.h" // loadStateMask, loadStateOnBit
25
26// -------------------------------
27// definitions of enumerated types
28
29//--------------------------------------------------------------------------------------------------
31enum class Polarities : uint8_t
32{
35};
36
38enum class OutputModes : uint8_t
39{
42};
43
44// LoadStates lives in load_map.h, so that the load-map logic stays Arduino-free.
45
52template< uint8_t N = 3, uint8_t S = 0 > class PayloadTx_struct
53{
54public:
55 int16_t power{ 0 };
56 int16_t power_L[N]{};
57 uint16_t Vrms_L_x100[N]{};
58 int16_t temperature_x100[S]{};
59};
60
67template< typename _Tp, size_t _Nm > constexpr size_t size(const _Tp (& /*__array*/)[_Nm]) noexcept
68{
69 return _Nm;
70}
71
77template< typename _Tp > constexpr size_t size(const _Tp (& /*__array*/)[0]) noexcept
78{
79 return 0;
80}
81
82template< class... Ts >
83constexpr uint8_t ival(Ts... Vs)
84{
85 char vals[sizeof...(Vs)]{ Vs... };
86 uint8_t result{ 0 };
87 for (uint8_t i = 0; i < sizeof...(Vs); i++)
88 {
89 result *= 10;
90 result += vals[i] - '0';
91 }
92 return result;
93}
94
95template< char... Vs >
96constexpr integral_constant< uint8_t, ival(Vs...) > operator""_i()
97{
98 return {};
99}
100
101// MINUTES(): in type_traits.hpp, shared with the scheduled boosts
102
103#endif // TYPES_H
container for datalogging
Definition types.h:53
int16_t power_L[N]
Definition types.h:56
int16_t temperature_x100[S]
Definition types.h:58
uint16_t Vrms_L_x100[N]
Definition types.h:57
int16_t power
Definition types.h:55
What config.h is written with: its types, constants and helpers.
Some constants.
uint8_t i
Encoding of the load map: one packed byte per dump load.
The load priority state machine: which load to switch at each mains cycle.
Some useful but missing stl functions templates.
constexpr uint8_t ival(Ts... Vs)
Definition types.h:83
Polarities
Definition types.h:32
@ NEGATIVE
Definition types.h:33
@ POSITIVE
Definition types.h:34
constexpr size_t size(const _Tp(&)[_Nm]) noexcept
Helper function to retrieve the dimension of a C-array.
Definition types.h:67
OutputModes
Definition types.h:39
@ ANTI_FLICKER
Definition types.h:40