Infrared4Arduino 1.2.3
Loading...
Searching...
No Matches
IrReceiverPoll.h
Go to the documentation of this file.
1#pragma once
2
3#include "IrReceiver.h"
4
11class IrReceiverPoll : public IrReceiver {
12private:
14 microseconds_t *durationData;
15
17 size_t dataLength;
18
19public:
20 IrReceiverPoll(size_t captureLength = defaultCaptureLength,
21 pin_t pin = defaultPin,
22 bool pullup = false,
26
28
29 bool isReady() const {
30 return timeouted || !isEmpty();
31 }
32
33 void reset();
34
35 size_t getDataLength() const {
36 return dataLength;
37 }
38
39 microseconds_t getDuration(unsigned int i) const {
40 return durationData[i];
41 }
42
44 endingTimeout = timeOut;
45 }
46
48 return endingTimeout;
49 }
50
52 return beginningTimeout;
53 }
54
56 beginningTimeout = timeOut;
57 }
58
64 void enable();
65
66 void disable() {};
67
68private:
69 bool searchForStart();
70
71 void collectData();
72
73 void recordDuration(unsigned long t);
74};
uint16_t microseconds_t
Type for durations in micro seconds.
Definition: InfraredTypes.h:15
uint16_t milliseconds_t
Type for durations in milli seconds.
Definition: InfraredTypes.h:24
uint8_t pin_t
Type for GPIO pin, compatible with Arduino libs.
Definition: InfraredTypes.h:41
static constexpr size_t defaultCaptureLength
Definition: IrReader.h:35
int16_t markExcess
Microseconds subtracted from pulses and added to gaps.
Definition: IrReader.h:44
milliseconds_t beginningTimeout
Definition: IrReader.h:38
static constexpr milliseconds_t defaultEndingTimeout
Definition: IrReader.h:34
static constexpr milliseconds_t defaultBeginningTimeout
Definition: IrReader.h:33
virtual bool isEmpty() const
Definition: IrReader.h:141
milliseconds_t endingTimeout
Definition: IrReader.h:39
bool timeouted
True if last receive ended with a timeout.
Definition: IrReader.h:47
An implementation of IrReceiver using polling of the input pin.
bool isReady() const
Returns true if there is collected data.
microseconds_t getDuration(unsigned int i) const
Returns the index-th duration, if possible.
void disable()
Stop reception of IR data.
void setBeginningTimeout(milliseconds_t timeOut)
void enable()
In this class, enable does the actual collection of the data.
milliseconds_t getBeginningTimeout() const
size_t getDataLength() const
Returns the number of collected durations.
milliseconds_t getEndingTimeout() const
void setEndingTimeout(milliseconds_t timeOut)
Abstract base class for demodulating IR receivers.
Definition: IrReceiver.h:12
static constexpr microseconds_t defaultMarkExcess
Definition: IrReceiver.h:20
static constexpr pin_t defaultPin
Definition: IrReceiver.h:19