9 bool result = getDuration(flash, 1);
13 return getDuration(gap, 3) ? 1
14 : getDuration(gap, 1) ? 0
23int Nec1Decoder::decodeParameter(
const IrReader& irReader,
unsigned int index) {
25 for (
int i = 7; i >= 0; i--) {
29 sum = (sum << 1) + result;
35 unsigned int index = 0;
38 success = getDuration(irReader.
getDuration(index++), 16U);
41 success = getDuration(irReader.
getDuration(index++), 4U);
44 success = getDuration(irReader.
getDuration(index++), 1U);
53 strcpy(decode, nec1DittoLiteral);
55 success = getDuration(irReader.
getDuration(index++), 16U);
58 success = getDuration(irReader.
getDuration(index++), 8U);
61 D = decodeParameter(irReader, index);
65 S = decodeParameter(irReader, index);
69 F = decodeParameter(irReader, index);
73 int invF = decodeParameter(irReader, index);
76 if ((F ^ invF) != 0xFF)
80 success = getDuration(irReader.
getDuration(index++), 1U);
90 strcpy(decode,
"NEC1");
92 sprintf(junk,
" %d", D);
95 sprintf(junk,
" %d", S);
98 sprintf(junk,
" %d", F);
uint16_t microseconds_t
Type for durations in micro seconds.
Abstract base class for all decoder classes.
void setValid(bool valid_)
static constexpr int invalid
static bool isEnding(microseconds_t duration)
Tests if the argument is large enough to be considered an ending of a decodable signal.
bool printDecode(Stream &stream) const
If valid, prints the decode to the stream.
Abstract base class for all IR readers, capturing or receiving.
virtual size_t getDataLength() const =0
Returns the number of collected durations.
virtual microseconds_t getDuration(unsigned int index) const =0
Returns the index-th duration, if possible.
A decoder class for NEC1 signals.
static bool tryDecode(const IrReader &irReader, Stream &stream)
Convenience function; constructs an Nec1Decoder and calls its printDecode.