1-phase PV router
Loading...
Searching...
No Matches
Mk2_fasterControl_Full
types.h
Go to the documentation of this file.
1
11
12
#ifndef TYPES_H
13
#define TYPES_H
14
15
#include <Arduino.h>
16
17
#include "
type_traits.hpp
"
18
19
#include "
constants.h
"
20
21
// -------------------------------
22
// definitions of enumerated types
23
25
enum class
SerialOutputType
26
{
27
HumanReadable
,
28
IoT
,
29
JSON
30
};
31
33
enum class
Polarities
: uint8_t
34
{
35
NEGATIVE
,
36
POSITIVE
37
};
38
40
enum class
OutputModes
: uint8_t
41
{
42
ANTI_FLICKER
,
43
NORMAL
44
};
45
47
enum class
LoadStates
: uint8_t
48
{
49
LOAD_OFF
,
50
LOAD_ON
51
};
52
// enum loadStates {LOAD_ON, LOAD_OFF}; /**< for use if loads are active low (original PCB) */
53
54
inline
constexpr
uint8_t
loadStateMask
{ 0x7FU };
55
inline
constexpr
uint8_t
loadStateOnBit
{ (uint8_t)(~
loadStateMask
) };
56
58
enum class
RotationModes
: uint8_t
59
{
60
OFF
,
61
AUTO
,
62
PIN
63
};
64
66
enum class
DisplayType
: uint8_t
67
{
68
NONE
,
69
OLED
,
70
SEG
,
71
SEG_HW
,
72
};
73
79
template
< u
int
8_t S = 0 >
class
PayloadTx_struct
80
{
81
public
:
82
int16_t
powerGrid
;
83
int16_t
powerDiverted
;
84
int16_t
Vrms_L_x100
;
85
int16_t
temperature_x100
[S];
86
};
87
94
template
<
typename
_Tp,
size_t
_Nm >
constexpr
size_t
size
(
const
_Tp (&
/*__array*/
)[_Nm])
noexcept
95
{
96
return
_Nm;
97
}
98
104
template
<
typename
_Tp >
constexpr
size_t
size
(
const
_Tp (&
/*__array*/
)[0]) noexcept
105
{
106
return
0;
107
}
108
109
template
<
class
... Ts >
110
constexpr
uint8_t
ival
(Ts... Vs)
111
{
112
char
vals[
sizeof
...(Vs)] = { Vs... };
113
uint8_t result = 0;
114
for
(uint8_t
i
= 0;
i
<
sizeof
...(Vs);
i
++)
115
{
116
result *= 10;
117
result += vals[
i
] -
'0'
;
118
}
119
return
result;
120
}
121
122
template
<
char
... Vs >
123
constexpr
integral_constant
< uint8_t,
ival
(Vs...) >
operator
""
_i()
124
{
125
return
{};
126
}
127
128
#endif
// TYPES_H
PayloadTx_struct
Container for datalogging.
Definition
types.h:80
PayloadTx_struct::powerDiverted
int16_t powerDiverted
Definition
types.h:83
PayloadTx_struct::temperature_x100
int16_t temperature_x100[S]
Definition
types.h:85
PayloadTx_struct::Vrms_L_x100
int16_t Vrms_L_x100
Definition
types.h:84
PayloadTx_struct::powerGrid
int16_t powerGrid
Definition
types.h:82
constants.h
Some constants.
integral_constant
Definition
integral_constant.hpp:8
i
uint8_t i
Definition
test_main.cpp:119
type_traits.hpp
Some useful but missing stl functions templates.
RotationModes
RotationModes
Definition
types.h:59
RotationModes::PIN
@ PIN
Definition
types.h:62
RotationModes::AUTO
@ AUTO
Definition
types.h:61
ival
constexpr uint8_t ival(Ts... Vs)
Definition
types.h:110
Polarities
Polarities
Definition
types.h:34
Polarities::NEGATIVE
@ NEGATIVE
Definition
types.h:35
Polarities::POSITIVE
@ POSITIVE
Definition
types.h:36
size
constexpr size_t size(const _Tp(&)[_Nm]) noexcept
Helper function to retrieve the dimension of a C-array.
Definition
types.h:94
SerialOutputType
SerialOutputType
Definition
types.h:26
SerialOutputType::JSON
@ JSON
Definition
types.h:29
SerialOutputType::IoT
@ IoT
Definition
types.h:28
SerialOutputType::HumanReadable
@ HumanReadable
Definition
types.h:27
loadStateMask
constexpr uint8_t loadStateMask
Definition
types.h:54
loadStateOnBit
constexpr uint8_t loadStateOnBit
Definition
types.h:55
LoadStates
LoadStates
Definition
types.h:48
LoadStates::LOAD_OFF
@ LOAD_OFF
Definition
types.h:49
LoadStates::LOAD_ON
@ LOAD_ON
Definition
types.h:50
OutputModes
OutputModes
Definition
types.h:41
OutputModes::ANTI_FLICKER
@ ANTI_FLICKER
Definition
types.h:42
OutputModes::NORMAL
@ NORMAL
Definition
types.h:43
DisplayType
DisplayType
Definition
types.h:67
DisplayType::OLED
@ OLED
Definition
types.h:69
DisplayType::NONE
@ NONE
Definition
types.h:68
DisplayType::SEG_HW
@ SEG_HW
Definition
types.h:71
DisplayType::SEG
@ SEG
Definition
types.h:70
OFF
constexpr uint8_t OFF
Definition
utils_display.h:190
Generated by
1.13.2