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