Infrared4Arduino 1.2.3
Loading...
Searching...
No Matches
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) {
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}
virtual bool isValid() const
Returns true if the decode was successful.
Definition: IrDecoder.h:31
void setValid(bool valid_)
Definition: IrDecoder.h:60
Abstract base class for all IR readers, capturing or receiving.
Definition: IrReader.h:30
virtual size_t getDataLength() const =0
Returns the number of collected durations.
@ nec
NEC1 intro.
Definition: MultiDecoder.h:18
@ undecoded
decoding failed
Definition: MultiDecoder.h:17
@ noise
nothing sensible found
Definition: MultiDecoder.h:16
@ nec_ditto
NEC1 repeat.
Definition: MultiDecoder.h:19
@ timeout
beginTimeout reached
Definition: MultiDecoder.h:15
@ rc5
RC5 signal (= repeat sequence)
Definition: MultiDecoder.h:20
MultiDecoder(const IrReader &irReader)
Constructs a MultiDecoder from an IrReader, containing data.
Definition: MultiDecoder.cpp:6
A decoder class for NEC1 signals.
Definition: Nec1Decoder.h:9
bool 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
A decoder class for RC5 signals.
Definition: Rc5Decoder.h:9
const char * getDecode() const
Returns a textual description the decode for human consumption.
Definition: Rc5Decoder.cpp:55