Infrared4Arduino 1.2.3
Loading...
Searching...
No Matches
IrDecoder.h
Go to the documentation of this file.
1#pragma once
2
3#include "InfraredTypes.h"
4
8class IrDecoder {
9public:
11
12#ifndef DOXYGEN
13 IrDecoder(const IrDecoder&) = delete;
14 IrDecoder(IrDecoder&&) = delete;
15 IrDecoder& operator=(const IrDecoder&) = delete;
16 IrDecoder& operator=(IrDecoder&&) = delete;
17#endif // ! DOXYGEN
18
19 virtual ~IrDecoder() {}
20
25 virtual const char *getDecode() const = 0;
26
31 virtual bool isValid() const {
32 return valid;
33 }
34
39 operator bool() const {
40 return isValid();
41 }
42
48 bool printDecode(Stream& stream) const {
49 if (isValid())
50 stream.println(getDecode());
51 return isValid();
52 }
53
54private:
55 static constexpr uint32_t endingMin = 20000UL;
56 bool valid = false;
57
58protected:
59 constexpr static int invalid = -1;
60 void setValid(bool valid_) {
61 valid = valid_;
62 }
63
69 static bool isEnding(microseconds_t duration) {
70 return duration > endingMin;
71 }
72};
This file defines some general data types that are used in the library.
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
virtual bool isValid() const
Returns true if the decode was successful.
Definition: IrDecoder.h:31
void setValid(bool valid_)
Definition: IrDecoder.h:60
static constexpr int invalid
Definition: IrDecoder.h:59
static bool isEnding(microseconds_t duration)
Tests if the argument is large enough to be considered an ending of a decodable signal.
Definition: IrDecoder.h:69
virtual ~IrDecoder()
Definition: IrDecoder.h:19
bool printDecode(Stream &stream) const
If valid, prints the decode to the stream.
Definition: IrDecoder.h:48
IrDecoder()
Definition: IrDecoder.h:10
virtual const char * getDecode() const =0
Returns a textual description the decode for human consumption.