Infrared4Arduino 1.2.3
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
IrReader Class Referenceabstract

Abstract base class for all IR readers, capturing or receiving. More...

#include <IrReader.h>

Inheritance diagram for IrReader:
Inheritance graph
[legend]

Public Member Functions

virtual void reset ()
 
virtual frequency_t getFrequency () const =0
 Returns frequency of received signal. More...
 
virtual void enable ()
 Start reception of IR data. More...
 
virtual void disable ()
 Stop reception of IR data. More...
 
virtual void receive ()=0
 Convenience function: enable, wait until data is collected or timeout has occured, disable. More...
 
virtual bool isReady () const =0
 Returns true if there is collected data. More...
 
 operator bool () const
 Same as isReady() More...
 
virtual size_t getDataLength () const =0
 Returns the number of collected durations. More...
 
virtual microseconds_t getDuration (unsigned int index) const =0
 Returns the index-th duration, if possible. More...
 
virtual void dump (Stream &stream) const
 Prints a textual representation of the received data to the Stream supplied. More...
 
IrSequencetoIrSequence () const
 Generates an IrSequence from the IrReader. More...
 
virtual bool isEmpty () const
 
virtual void setEndingTimeout (milliseconds_t timeOut)
 
virtual milliseconds_t getEndingTimeout () const
 
virtual void setBeginningTimeout (milliseconds_t timeOut)
 
virtual milliseconds_t getBeginningTimeout () const
 
unsigned int getBufferSize () const
 
void setMarkExcess (int16_t markExcess_)
 Sets the markExcess, a number (possibly negative) to be subtracted from the on-durations and added to the off.durations. More...
 
int16_t getMarkExcess () const
 Gets the markExcess, a number (possibly negative) to be subtracted from the on-durations and added to the off.durations. More...
 

Static Public Attributes

static constexpr milliseconds_t defaultBeginningTimeout = 2000U
 
static constexpr milliseconds_t defaultEndingTimeout = 30U
 
static constexpr size_t defaultCaptureLength = 100U
 

Protected Member Functions

 IrReader (size_t bufSize_)
 Constructs an IrReader with buffersize bufSize_, possibly increased to be even. More...
 
 IrReader ()
 
virtual ~IrReader ()
 

Static Protected Member Functions

static unsigned int forceEven (unsigned int x)
 

Protected Attributes

milliseconds_t beginningTimeout
 
milliseconds_t endingTimeout
 
size_t bufferSize
 
int16_t markExcess
 Microseconds subtracted from pulses and added to gaps. More...
 
bool timeouted
 True if last receive ended with a timeout. More...
 

Detailed Description

Abstract base class for all IR readers, capturing or receiving.

It should also serve as an interface description, allowing for received data to be printed and decoded.

Definition at line 30 of file IrReader.h.

Constructor & Destructor Documentation

◆ IrReader() [1/2]

IrReader::IrReader ( size_t  bufSize_)
inlineprotected

Constructs an IrReader with buffersize bufSize_, possibly increased to be even.

Parameters
bufSize_

Definition at line 57 of file IrReader.h.

◆ IrReader() [2/2]

IrReader::IrReader ( )
inlineprotected

Definition at line 60 of file IrReader.h.

◆ ~IrReader()

virtual IrReader::~IrReader ( )
inlineprotectedvirtual

Definition at line 70 of file IrReader.h.

Member Function Documentation

◆ disable()

virtual void IrReader::disable ( )
inlinevirtual

Stop reception of IR data.

Reimplemented in IrReceiverPoll, and IrReceiverSampler.

Definition at line 94 of file IrReader.h.

◆ dump()

void IrReader::dump ( Stream &  stream) const
virtual

Prints a textual representation of the received data to the Stream supplied.

Parameters
streamStream to which to print

Reimplemented in IrWidget.

Definition at line 21 of file IrReader.cpp.

◆ enable()

virtual void IrReader::enable ( )
inlinevirtual

Start reception of IR data.

Reimplemented in IrReceiverPoll, and IrReceiverSampler.

Definition at line 88 of file IrReader.h.

◆ forceEven()

static unsigned int IrReader::forceEven ( unsigned int  x)
inlinestaticprotected

Definition at line 49 of file IrReader.h.

◆ getBeginningTimeout()

virtual milliseconds_t IrReader::getBeginningTimeout ( ) const
inlinevirtual

Reimplemented in IrReceiverPoll, and IrReceiverSampler.

Definition at line 157 of file IrReader.h.

◆ getBufferSize()

unsigned int IrReader::getBufferSize ( ) const
inline

Definition at line 161 of file IrReader.h.

◆ getDataLength()

virtual size_t IrReader::getDataLength ( ) const
pure virtual

Returns the number of collected durations.

Returns
number durations

Implemented in IrReceiverPoll, IrReceiverSampler, IrSequenceReader, and IrWidget.

◆ getDuration()

virtual microseconds_t IrReader::getDuration ( unsigned int  index) const
pure virtual

Returns the index-th duration, if possible.

Parameters
indexindex of duration
Returns
requested duration

Implemented in IrReceiverPoll, IrReceiverSampler, IrWidget, and IrSequenceReader.

◆ getEndingTimeout()

virtual milliseconds_t IrReader::getEndingTimeout ( ) const
inlinevirtual

Reimplemented in IrReceiverPoll, IrReceiverSampler, and IrWidget.

Definition at line 149 of file IrReader.h.

◆ getFrequency()

virtual frequency_t IrReader::getFrequency ( ) const
pure virtual

Returns frequency of received signal.

This is a dumb default implementation, to be overridden when meaningful.

Returns
frequency

Implemented in IrReceiver, IrSequenceReader, and IrWidget.

◆ getMarkExcess()

int16_t IrReader::getMarkExcess ( ) const
inline

Gets the markExcess, a number (possibly negative) to be subtracted from the on-durations and added to the off.durations.

Returns
markExcess

Definition at line 179 of file IrReader.h.

◆ isEmpty()

virtual bool IrReader::isEmpty ( ) const
inlinevirtual

Definition at line 141 of file IrReader.h.

◆ isReady()

virtual bool IrReader::isReady ( ) const
pure virtual

Returns true if there is collected data.

Returns
status

Implemented in IrReceiverPoll, IrReceiverSampler, IrSequenceReader, and IrWidget.

◆ operator bool()

IrReader::operator bool ( ) const
inline

Same as isReady()

Returns

Definition at line 112 of file IrReader.h.

◆ receive()

virtual void IrReader::receive ( )
pure virtual

Convenience function: enable, wait until data is collected or timeout has occured, disable.

Implemented in IrReceiver, IrSequenceReader, and IrWidget.

◆ reset()

virtual void IrReader::reset ( )
inlinevirtual

Reimplemented in IrReceiverPoll, IrReceiverSampler, and IrWidget.

Definition at line 74 of file IrReader.h.

◆ setBeginningTimeout()

virtual void IrReader::setBeginningTimeout ( milliseconds_t  timeOut)
inlinevirtual

Reimplemented in IrReceiverPoll, and IrReceiverSampler.

Definition at line 153 of file IrReader.h.

◆ setEndingTimeout()

virtual void IrReader::setEndingTimeout ( milliseconds_t  timeOut)
inlinevirtual

Reimplemented in IrReceiverPoll, IrReceiverSampler, and IrWidget.

Definition at line 145 of file IrReader.h.

◆ setMarkExcess()

void IrReader::setMarkExcess ( int16_t  markExcess_)
inline

Sets the markExcess, a number (possibly negative) to be subtracted from the on-durations and added to the off.durations.

Parameters
markExcess_possibly negative new value

Definition at line 170 of file IrReader.h.

◆ toIrSequence()

IrSequence * IrReader::toIrSequence ( ) const

Generates an IrSequence from the IrReader.

Returns
IrSequence. The user must delete this to avoid memory leaks.

Definition at line 31 of file IrReader.cpp.

Member Data Documentation

◆ beginningTimeout

milliseconds_t IrReader::beginningTimeout
protected

Definition at line 38 of file IrReader.h.

◆ bufferSize

size_t IrReader::bufferSize
protected

Definition at line 41 of file IrReader.h.

◆ defaultBeginningTimeout

constexpr milliseconds_t IrReader::defaultBeginningTimeout = 2000U
staticconstexpr

Definition at line 33 of file IrReader.h.

◆ defaultCaptureLength

constexpr size_t IrReader::defaultCaptureLength = 100U
staticconstexpr

Definition at line 35 of file IrReader.h.

◆ defaultEndingTimeout

constexpr milliseconds_t IrReader::defaultEndingTimeout = 30U
staticconstexpr

Definition at line 34 of file IrReader.h.

◆ endingTimeout

milliseconds_t IrReader::endingTimeout
protected

Definition at line 39 of file IrReader.h.

◆ markExcess

int16_t IrReader::markExcess
protected

Microseconds subtracted from pulses and added to gaps.

May be negative.

Definition at line 44 of file IrReader.h.

◆ timeouted

bool IrReader::timeouted
protected

True if last receive ended with a timeout.

Definition at line 47 of file IrReader.h.


The documentation for this class was generated from the following files: