Infrared4Arduino
Nec1Decoder.h
Go to the documentation of this file.
1 #ifndef NEC1DECODER_H
2 #define NEC1DECODER_H
3 
4 #include "IrDecoder.h"
5 #include "IrReader.h"
6 
10 class Nec1Decoder : public IrDecoder {
11 private:
12  static const microseconds_t timebase = 564;
13  static const microseconds_t timebaseUpper = 650;
14  static const microseconds_t timebaseLower = 450;
15 
16  // NOTE: use a signed type to be able to return the value invalid.
17  int F;
18  int D;
19  int S;
20  bool ditto;
21 
22  char decode[17];
23 
24  static boolean getDuration(microseconds_t duration, unsigned int time) {
25  return duration <= time * timebaseUpper
26  && duration >= time * timebaseLower;
27  }
28  static int decodeParameter(const IrReader &irCapturer, unsigned int index);
29  static int decodeFlashGap(microseconds_t flash, microseconds_t gap);
30 
31 public:
32  Nec1Decoder();
33 
38  Nec1Decoder(const IrReader& irReader);
39  virtual ~Nec1Decoder() {};
40 
45  int getF() const {
46  return F;
47  }
48 
53  int getD() const {
54  return D;
55  }
56 
61  int getS() const {
62  return S;
63  }
64 
69  boolean isDitto() const {
70  return ditto;
71  };
72 
79  static boolean tryDecode(const IrReader &irReader, Stream& stream);
80 
81  const char *getDecode() const {
82  return decode;
83  };
84 
85 };
86 
87 #endif /* NEC1DECODER_H */
uint16_t microseconds_t
Type for durations in micro seconds.
Definition: InfraredTypes.h:16
int getD() const
Returns the D parameter, or -1 if invalid.
Definition: Nec1Decoder.h:53
int getS() const
Returns the S parameter, or -1 if invalid.
Definition: Nec1Decoder.h:61
boolean isDitto() const
Returns true if the signal received is a NEC1 ditto, i,e.
Definition: Nec1Decoder.h:69
const char * getDecode() const
Returns a textual description the decode for human consumption.
Definition: Nec1Decoder.h:81
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 getF() const
Returns the F parameter, or -1 if invalid.
Definition: Nec1Decoder.h:45
A decoder class for NEC1 signals.
Definition: Nec1Decoder.h:10
virtual ~Nec1Decoder()
Definition: Nec1Decoder.h:39
static boolean tryDecode(const IrReader &irReader, Stream &stream)
Convenience function; constructs an Nec1Decoder and calls its printDecode.
Definition: Nec1Decoder.cpp:20