OOKwiz
on/off-keying for ESP32 and a variety of supported radio modules
src
Pulsetrain.h
Go to the documentation of this file.
1
#
ifndef
_PULSETRAIN_H_
2
#
define
_PULSETRAIN_H_
3
4
#
include
<
Arduino
.
h
>
5
#
include
<
vector
>
6
#
include
"config.h"
7
8
class
RawTimings
;
9
class
Meaning
;
10
11
/// @brief Struct that holds information about a 'bin' in a Pulsetrain, a range of timings that are lumped together when converting RawTimings to a Pulsetrain.
12
typedef
struct
pulseBin
{
13
/// @brief shortest time in bin in µs
14
uint16_t
min
= 65535;
15
/// @brief longest time in bin in µs
16
uint16_t
max
= 0;
17
/// @brief average time in bin in µs
18
long
average
= 0;
// long bc used to store total time before averaging
19
/// @brief Number of intervals in this bin in Pulsetrain
20
uint16_t
count
= 0;
21
} pulseBin;
22
23
/// @brief Instances of Pulsetrain represent packets in a normalized way, meaning all intervals of similar length are made equal.
24
class
Pulsetrain
{
25
public
:
26
static
bool
maybe
(String str);
27
28
/// @brief std::vector with the bins, each a PulseBin struct
29
std
::
vector
<
pulseBin
>
bins
;
30
/// @brief std::vector with the transitions, each merely the pulsebin that transition is in
31
std
::
vector
<
uint8_t
>
transitions
;
32
/// @brief Total duration of this Pulsetrain in µs
33
uint32_t
duration
= 0;
34
/// @brief First seen at this time, in system microseconds
35
int64_t
first_at
= 0;
36
/// @brief Last seen at this time, in system microseconds
37
int64_t
last_at
= 0;
38
/// @brief Number of repetitions detected before either another packet came or `repeat_timeout` µs elapsed
39
uint16_t
repeats
= 0;
40
/// @brief Smallest gap between repeated transmissions
41
uint16_t
gap
= 0;
42
43
operator
bool
();
44
void
zap
();
45
bool
sameAs
(
const
Pulsetrain
&other_train);
46
bool
fromRawTimings
(
const
RawTimings
&raw);
47
RawTimings
toRawTimings
();
48
bool
fromMeaning
(
const
Meaning
&meaning);
49
Meaning
toMeaning
();
50
String
summary
()
const
;
51
bool
fromString
(String in);
52
String
toString
()
const
;
53
String
binList
();
54
String
visualizer
();
55
String
visualizer
(
int
base
);
56
57
private
:
58
void
addToBins(
int
time);
59
int
binFromTime(
int
time);
60
};
61
62
#
endif
Generated by
1.9.1