Infrared4Arduino
Rc5Decoder.h
Go to the documentation of this file.
1 #ifndef RC5DECODER_H
2 #define RC5DECODER_H
3 
4 #include "IrDecoder.h"
5 #include "IrReader.h"
6 
10 class Rc5Decoder : public IrDecoder {
11 public:
12  static const char *format;
13 
18  Rc5Decoder(const IrReader& irReader);
19 
20  virtual ~Rc5Decoder() {
21  }
22 
27  int getF() const {
28  return F;
29  }
30 
35  int getD() const {
36  return D;
37  }
38 
43  int getT() const {
44  return T;
45  }
46 
53  static boolean tryDecode(const IrReader& irReader, Stream& stream);
54 
55  const char *getDecode() const;
56 
57 private:
58  char decode[13];
59  const static microseconds_t timebase = 889U;
60  const static microseconds_t timebaseLower = 800U;
61  const static microseconds_t timebaseUpper = 1000U;
62  static boolean getDuration(microseconds_t duration, unsigned int time) {
63  return duration <= time * timebaseUpper
64  && duration >= time * timebaseLower;
65  }
66  int F;
67  int D;
68  int T;
69 
70  enum Length {
71  invalid = 0,
72  half = 1,
73  full = 2
74  };
75 
76  static Length decodeDuration(microseconds_t t);
77  static unsigned int decodeFlashGap(microseconds_t flash, microseconds_t gap);
78 };
79 
80 #endif /* RC5DECODER_H */
virtual ~Rc5Decoder()
Definition: Rc5Decoder.h:20
A decoder class for RC5 signals.
Definition: Rc5Decoder.h:10
uint16_t microseconds_t
Type for durations in micro seconds.
Definition: InfraredTypes.h:16
static const char * format
Definition: Rc5Decoder.h:12
int getT() const
Returns the T parameter, or -1 if invalid.
Definition: Rc5Decoder.h:43
int getF() const
Returns the F parameter, or -1 if invalid.
Definition: Rc5Decoder.h:27
Rc5Decoder(const IrReader &irReader)
Constructs a Rc5Decoder from an IrReader, containing data.
Definition: Rc5Decoder.cpp:29
Abstract base class for all IR readers, capturing or receiving.
Definition: IrReader.h:30
Abstract base class for all decoder classes.
Definition: IrDecoder.h:9
int getD() const
Returns the D parameter, or -1 if invalid.
Definition: Rc5Decoder.h:35
const char * getDecode() const
Returns a textual description the decode for human consumption.
Definition: Rc5Decoder.cpp:57
static boolean tryDecode(const IrReader &irReader, Stream &stream)
Convenience function; constructs an Rc5Decoder and calls its printDecode.
Definition: Rc5Decoder.cpp:24