Infrared4Arduino
MultiDecoder.cpp
Go to the documentation of this file.
1 #include "MultiDecoder.h"
2 #include "Nec1Decoder.h"
3 #include "Rc5Decoder.h"
4 #include <string.h>
5 
7  if (IrReader.isEmpty()) {
8  type = timeout;
9  strcpy(decode, ".");
10  return;
11  }
12 
13  if (IrReader.getDataLength() < 3) {
14  type = noise;
15  strcpy(decode, ":");
16  return;
17  }
18 
19  Nec1Decoder nec1decoder(IrReader);
20  if (nec1decoder.isValid()) {
21  strcpy(decode, nec1decoder.getDecode());
22  type = nec1decoder.isDitto() ? nec_ditto : nec;
23  setValid(true);
24  return;
25  }
26 
27  Rc5Decoder rc5decoder(IrReader);
28  if (rc5decoder.isValid()) {
29  strcpy(decode, rc5decoder.getDecode());
30  type = rc5;
31  setValid(true);
32  return;
33  }
34 
35  // Giving up
36  strcpy(decode, "***");
37  type = undecoded;
38 }
MultiDecoder(const IrReader &irReader)
Constructs a MultiDecoder from an IrReader, containing data.
Definition: MultiDecoder.cpp:6
A decoder class for RC5 signals.
Definition: Rc5Decoder.h:9
nothing sensible found
Definition: MultiDecoder.h:16
virtual bool isValid() const
Returns true if the decode was successful.
Definition: IrDecoder.h:26
const char * getDecode() const
Returns a textual description the decode for human consumption.
Definition: Rc5Decoder.cpp:57
Abstract base class for all IR readers, capturing or receiving.
Definition: IrReader.h:30
void setValid(bool valid_)
Definition: IrDecoder.h:47
virtual size_t getDataLength() const =0
Returns the number of collected durations.
decoding failed
Definition: MultiDecoder.h:17
A decoder class for NEC1 signals.
Definition: Nec1Decoder.h:9
RC5 signal (= repeat sequence)
Definition: MultiDecoder.h:20
NEC1 intro.
Definition: MultiDecoder.h:18
bool isDitto() const
Returns true if the signal received is a NEC1 ditto, i,e.
Definition: Nec1Decoder.h:68
beginTimeout reached
Definition: MultiDecoder.h:15
virtual bool isEmpty() const
Definition: IrReader.h:126
const char * getDecode() const
Returns a textual description the decode for human consumption.
Definition: Nec1Decoder.h:80