Infrared4Arduino 1.2.3
Loading...
Searching...
No Matches
Nec1Decoder.h
Go to the documentation of this file.
1#pragma once
2
3#include "IrDecoder.h"
4#include "IrReader.h"
5
9class Nec1Decoder : public IrDecoder {
10private:
11 static constexpr microseconds_t timebase = 564U;
12 static constexpr microseconds_t timebaseUpper = 650U;
13 static constexpr microseconds_t timebaseLower = 450U;
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 static constexpr const char *nec1DittoLiteral = "NEC1 ditto";
30
31public:
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 bool isDitto() const {
70 return ditto;
71 };
72
79 static bool tryDecode(const IrReader &irReader, Stream& stream);
80
81 const char *getDecode() const {
82 return decode;
83 };
84
85};
uint16_t microseconds_t
Type for durations in micro seconds.
Definition: InfraredTypes.h:15
Abstract base class for all decoder classes.
Definition: IrDecoder.h:8
Abstract base class for all IR readers, capturing or receiving.
Definition: IrReader.h:30
A decoder class for NEC1 signals.
Definition: Nec1Decoder.h:9
static bool tryDecode(const IrReader &irReader, Stream &stream)
Convenience function; constructs an Nec1Decoder and calls its printDecode.
Definition: Nec1Decoder.cpp:18
int getF() const
Returns the F parameter, or -1 if invalid.
Definition: Nec1Decoder.h:45
int getD() const
Returns the D parameter, or -1 if invalid.
Definition: Nec1Decoder.h:53
bool isDitto() const
Returns true if the signal received is a NEC1 ditto, i,e.
Definition: Nec1Decoder.h:69
virtual ~Nec1Decoder()
Definition: Nec1Decoder.h:39
const char * getDecode() const
Returns a textual description the decode for human consumption.
Definition: Nec1Decoder.h:81
int getS() const
Returns the S parameter, or -1 if invalid.
Definition: Nec1Decoder.h:61