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