Infrared4Arduino
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...
 
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 const milliseconds_t defaultBeginningTimeout = 2000U
 
static const milliseconds_t defaultEndingTimeout = 30U
 
static const 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 63 of file IrReader.h.

Member Function Documentation

◆ disable()

virtual void IrReader::disable ( )
inlinevirtual

Stop reception of IR data.

Reimplemented in IrReceiverSampler, and IrReceiverPoll.

Definition at line 87 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 IrReceiverSampler, and IrReceiverPoll.

Definition at line 81 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 IrReceiverSampler, and IrReceiverPoll.

Definition at line 142 of file IrReader.h.

◆ getBufferSize()

unsigned int IrReader::getBufferSize ( ) const
inline

Definition at line 146 of file IrReader.h.

◆ getDataLength()

virtual size_t IrReader::getDataLength ( ) const
pure virtual

Returns the number of collected durations.

Returns
number durations

Implemented in IrReceiverSampler, IrWidget, IrSequenceReader, and IrReceiverPoll.

◆ 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 IrReceiverSampler, IrWidget, IrSequenceReader, and IrReceiverPoll.

◆ getEndingTimeout()

virtual milliseconds_t IrReader::getEndingTimeout ( ) const
inlinevirtual

Reimplemented in IrReceiverSampler, IrWidget, and IrReceiverPoll.

Definition at line 134 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 IrWidget, IrReceiver, and IrSequenceReader.

◆ 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 164 of file IrReader.h.

◆ isEmpty()

virtual bool IrReader::isEmpty ( ) const
inlinevirtual

Definition at line 126 of file IrReader.h.

◆ isReady()

virtual bool IrReader::isReady ( ) const
pure virtual

Returns true if there is collected data.

Returns
status

Implemented in IrReceiverSampler, IrWidget, IrSequenceReader, and IrReceiverPoll.

◆ receive()

virtual void IrReader::receive ( )
pure virtual

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

Implemented in IrWidget, IrReceiver, and IrSequenceReader.

◆ reset()

virtual void IrReader::reset ( )
inlinevirtual

Reimplemented in IrReceiverSampler, IrWidget, and IrReceiverPoll.

Definition at line 67 of file IrReader.h.

◆ setBeginningTimeout()

virtual void IrReader::setBeginningTimeout ( milliseconds_t  timeOut)
inlinevirtual

Reimplemented in IrReceiverSampler, and IrReceiverPoll.

Definition at line 138 of file IrReader.h.

◆ setEndingTimeout()

virtual void IrReader::setEndingTimeout ( milliseconds_t  timeOut)
inlinevirtual

Reimplemented in IrReceiverSampler, IrWidget, and IrReceiverPoll.

Definition at line 130 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 155 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 32 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

const milliseconds_t IrReader::defaultBeginningTimeout = 2000U
static

Definition at line 33 of file IrReader.h.

◆ defaultCaptureLength

const size_t IrReader::defaultCaptureLength = 100U
static

Definition at line 35 of file IrReader.h.

◆ defaultEndingTimeout

const milliseconds_t IrReader::defaultEndingTimeout = 30U
static

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: