3-phase PV router
Loading...
Searching...
No Matches
types.h
Go to the documentation of this file.
1
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
25enum class Polarities : uint8_t
26{
27 NEGATIVE,
29};
30
32enum class OutputModes : uint8_t
33{
35 NORMAL
36};
37
39enum class LoadStates : uint8_t
40{
41 LOAD_OFF,
42 LOAD_ON
43};
44// enum loadStates {LOAD_ON, LOAD_OFF}; /**< for use if loads are active low (original PCB) */
45
46inline constexpr uint8_t loadStateOnBit{ 0x80U };
47inline constexpr uint8_t loadStateMask{ 0x7FU };
50enum class RotationModes : uint8_t
51{
52 OFF,
53 AUTO,
54 PIN
55};
56
63template< uint8_t N = 3, uint8_t S = 0 > class PayloadTx_struct
64{
65public:
66 int16_t power;
67 int16_t power_L[N];
68 int16_t Vrms_L_x100[N];
69 int16_t temperature_x100[S];
70};
71
78template< typename _Tp, size_t _Nm > constexpr size_t size(const _Tp (& /*__array*/)[_Nm]) noexcept
79{
80 return _Nm;
81}
82
88template< typename _Tp > constexpr size_t size(const _Tp (& /*__array*/)[0]) noexcept
89{
90 return 0;
91}
92
93template< class... Ts >
94constexpr uint8_t ival(Ts... Vs)
95{
96 char vals[sizeof...(Vs)] = { Vs... };
97 uint8_t result = 0;
98 for (uint8_t i = 0; i < sizeof...(Vs); i++)
99 {
100 result *= 10;
101 result += vals[i] - '0';
102 }
103 return result;
104}
105
106template< char... Vs >
107constexpr integral_constant< uint8_t, ival(Vs...) > operator""_i()
108{
109 return {};
110}
111
112#endif // TYPES_H
container for datalogging
Definition: types.h:64
int16_t Vrms_L_x100[N]
Definition: types.h:68
int16_t power_L[N]
Definition: types.h:67
int16_t temperature_x100[S]
Definition: types.h:69
int16_t power
Definition: types.h:66
Some constants.
uint8_t i
Definition: test_main.cpp:94
Some useful but missing stl functions templates.
RotationModes
Definition: types.h:51
constexpr uint8_t ival(Ts... Vs)
Definition: types.h:94
Polarities
Definition: types.h:26
constexpr size_t size(const _Tp(&)[_Nm]) noexcept
Helper function to retrieve the dimension of a C-array.
Definition: types.h:78
constexpr uint8_t loadStateMask
Definition: types.h:47
constexpr uint8_t loadStateOnBit
Definition: types.h:46
LoadStates
Definition: types.h:40
OutputModes
Definition: types.h:33