Infrared4Arduino
IrDecoder.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "InfraredTypes.h"
4 
8 class IrDecoder {
9 public:
11  valid = false;
12  }
13 
14  virtual ~IrDecoder() {}
15 
20  virtual const char *getDecode() const = 0;
21 
26  virtual bool isValid() const {
27  return valid;
28  }
29 
35  bool printDecode(Stream& stream) const {
36  if (isValid())
37  stream.println(getDecode());
38  return isValid();
39  }
40 
41 private:
42  const static uint32_t endingMin = 20000U;
43  bool valid;
44 
45 protected:
46  static const int invalid = -1;
47  void setValid(bool valid_) {
48  valid = valid_;
49  }
50 
56  static bool isEnding(microseconds_t duration) {
57  return duration > endingMin;
58  }
59 };
uint16_t microseconds_t
Type for durations in micro seconds.
Definition: InfraredTypes.h:15
virtual bool isValid() const
Returns true if the decode was successful.
Definition: IrDecoder.h:26
IrDecoder()
Definition: IrDecoder.h:10
static const int invalid
Definition: IrDecoder.h:46
void setValid(bool valid_)
Definition: IrDecoder.h:47
Abstract base class for all decoder classes.
Definition: IrDecoder.h:8
virtual const char * getDecode() const =0
Returns a textual description the decode for human consumption.
static bool isEnding(microseconds_t duration)
Tests if the argument is large enough to be considered an ending of a decodable signal.
Definition: IrDecoder.h:56
This file defines some general data types that are used in the library.
bool printDecode(Stream &stream) const
If valid, prints the decode to the stream.
Definition: IrDecoder.h:35
virtual ~IrDecoder()
Definition: IrDecoder.h:14