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