static constexpr microseconds_t MICROSECONDS_T_MAX
Largest microseconds_t number possible.
uint16_t microseconds_t
Type for durations in micro seconds.
uint16_t milliseconds_t
Type for durations in milli seconds.
uint8_t pin_t
Type for GPIO pin, compatible with Arduino libs.
static const unsigned long microsPerTick
static constexpr size_t defaultCaptureLength
int16_t markExcess
Microseconds subtracted from pulses and added to gaps.
milliseconds_t beginningTimeout
static constexpr milliseconds_t defaultEndingTimeout
static constexpr milliseconds_t defaultBeginningTimeout
milliseconds_t endingTimeout
This receiving class samples the input pin every 50 microseconds using a timer interrupt.
void enable()
Start reception of IR data.
milliseconds_t getBeginningTimeout() const
size_t getDataLength() const
Returns the number of collected durations.
ReceiverState_t
State space for the receiver state machine.
@ STATE_IDLE
Between signals; waiting for first mark.
@ STATE_STOP
Complete signal has been read.
@ STATE_MARK
Last read a mark.
@ STATE_SPACE
Last read a space.
uint32_t beginningTimeoutInTicks
milliseconds_t getEndingTimeout() const
volatile microseconds_t * durationData
Data buffer.
static IrReceiverSampler * newIrReceiverSampler(size_t captureLength=defaultCaptureLength, pin_t pin=defaultPin, bool pullup=false, microseconds_t markExcess=defaultMarkExcess, milliseconds_t beginningTimeout=defaultBeginningTimeout, milliseconds_t endingTimeout=defaultEndingTimeout)
This factory method replaces public constructors.
virtual ~IrReceiverSampler()
volatile ReceiverState_t receiverState
State of the state machine.
static IrReceiverSampler * getInstance()
Returns a pointer to the instance, or nullptr.
void setBeginningTimeout(milliseconds_t timeOut)
microseconds_t getDuration(unsigned int i) const
Returns the index-th duration, if possible.
volatile size_t dataLength
Number of entries in durationData.
volatile uint32_t timer
state timer, counts 50uS ticks.
static void deleteInstance()
Deletes the instance, thereby freeing up the resources it occupied, and allowing for another instance...
bool isReady() const
Returns true if there is collected data.
void disable()
Stop reception of IR data.
uint32_t endingTimeoutInTicks
void setEndingTimeout(milliseconds_t timeOut)
Abstract base class for demodulating IR receivers.
static constexpr microseconds_t defaultMarkExcess
static constexpr pin_t defaultPin