Infrared4Arduino 1.2.3
Loading...
Searching...
No Matches
Rc5Decoder.h
Go to the documentation of this file.
1#pragma once
2
3#include "IrDecoder.h"
4#include "IrReader.h"
5
9class Rc5Decoder : public IrDecoder {
10public:
11
16 Rc5Decoder(const IrReader& irReader);
17
18 virtual ~Rc5Decoder() {
19 }
20
25 int getF() const {
26 return F;
27 }
28
33 int getD() const {
34 return D;
35 }
36
41 int getT() const {
42 return T;
43 }
44
51 static bool tryDecode(const IrReader& irReader, Stream& stream);
52
53 const char *getDecode() const;
54
55private:
56 char decode[13];
57 const static microseconds_t timebase = 889U;
58 const static microseconds_t timebaseLower = 800U;
59 const static microseconds_t timebaseUpper = 1000U;
60 static bool getDuration(microseconds_t duration, unsigned int time) {
61 return duration <= time * timebaseUpper
62 && duration >= time * timebaseLower;
63 }
64 int F;
65 int D;
66 int T;
67
68 enum Length {
69 invalid = 0,
70 half = 1,
71 full = 2
72 };
73
74 static constexpr const char *format = "RC5 %d %d %d";
75
76 static Length decodeDuration(microseconds_t t);
77 static unsigned int decodeFlashGap(microseconds_t flash, microseconds_t gap);
78};
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 RC5 signals.
Definition: Rc5Decoder.h:9
int getF() const
Returns the F parameter, or -1 if invalid.
Definition: Rc5Decoder.h:25
int getD() const
Returns the D parameter, or -1 if invalid.
Definition: Rc5Decoder.h:33
static bool tryDecode(const IrReader &irReader, Stream &stream)
Convenience function; constructs an Rc5Decoder and calls its printDecode.
Definition: Rc5Decoder.cpp:22
virtual ~Rc5Decoder()
Definition: Rc5Decoder.h:18
const char * getDecode() const
Returns a textual description the decode for human consumption.
Definition: Rc5Decoder.cpp:55
int getT() const
Returns the T parameter, or -1 if invalid.
Definition: Rc5Decoder.h:41