OOKwiz
on/off-keying for ESP32 and a variety of supported radio modules
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
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
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
30  /// @brief std::vector with the transitions, each merely the pulsebin that transition is in
32  /// @brief Total duration of this Pulsetrain in µs
34  /// @brief First seen at this time, in system microseconds
36  /// @brief Last seen at this time, in system microseconds
38  /// @brief Number of repetitions detected before either another packet came or `repeat_timeout` µs elapsed
40  /// @brief Smallest gap between repeated transmissions
42 
43  operator bool();
44  void zap();
45  bool sameAs(const Pulsetrain &other_train);
46  bool fromRawTimings(const RawTimings &raw);
48  bool fromMeaning(const Meaning &meaning);
50  String summary() const;
51  bool fromString(String in);
52  String toString() const;
53  String binList();
55  String visualizer(int base);
56 
57 private:
58  void addToBins(int time);
59  int binFromTime(int time);
60 };
61 
62 #endif