IRremote
Receiving IR data for multiple protocols

Functions

bool matchTicks (unsigned int aMeasuredTicks, unsigned int aMatchValueMicros)
 Match function without compensating for marks exceeded or spaces shortened by demodulator hardware Currently not used. More...
 
bool MATCH (unsigned int measured_ticks, unsigned int desired_us)
 
bool matchMark (unsigned int aMeasuredTicks, unsigned int aMatchValueMicros)
 Compensate for marks exceeded by demodulator hardware. More...
 
bool MATCH_MARK (unsigned int measured_ticks, unsigned int desired_us)
 
bool matchSpace (unsigned int aMeasuredTicks, unsigned int aMatchValueMicros)
 Compensate for spaces shortened by demodulator hardware. More...
 
bool MATCH_SPACE (unsigned int measured_ticks, unsigned int desired_us)
 
int getMarkExcessMicros ()
 Getter function for MARK_EXCESS_MICROS. More...
 
void CheckForRecordGapsMicros (Print *aSerial, IRData *aIRDataPtr)
 
void printActiveIRProtocols (Print *aSerial)
 
void printIRResultShort (Print *aSerial, IRData *aIRDataPtr, bool aPrintRepeatGap)
 Internal function to print decoded result and flags in one line. More...
 
void printIRSendUsage (Print *aSerial, IRData *aIRDataPtr)
 
const __FlashStringHelper * getProtocolString (decode_type_t aProtocol)
 
 ISR ()
 
 IRrecv::IRrecv ()
 Instantiate the IRrecv class. More...
 
 IRrecv::IRrecv (uint_fast8_t aReceivePin)
 
 IRrecv::IRrecv (uint_fast8_t aReceivePin, uint_fast8_t aFeedbackLEDPin)
 Instantiate the IRrecv class. More...
 
void IRrecv::begin (uint_fast8_t aReceivePin, bool aEnableLEDFeedback=false, uint_fast8_t aFeedbackLEDPin=USE_DEFAULT_FEEDBACK_LED_PIN)
 Initializes the receive and feedback pin. More...
 
void IRrecv::setReceivePin (uint_fast8_t aReceivePinNumber)
 Sets / changes the receiver pin number. More...
 
void IRrecv::start ()
 Configures the timer and the state machine for IR reception. More...
 
void IRrecv::enableIRIn ()
 Alias for start(). More...
 
void IRrecv::start (uint32_t aMicrosecondsToAddToGapCounter)
 Configures the timer and the state machine for IR reception. More...
 
void IRrecv::restartAfterSend ()
 Restarts receiver after send. More...
 
void IRrecv::stop ()
 Disables the timer for IR reception. More...
 
void IRrecv::disableIRIn ()
 Alias for stop(). More...
 
void IRrecv::end ()
 Alias for stop(). More...
 
bool IRrecv::isIdle ()
 Returns status of reception. More...
 
void IRrecv::resume ()
 Restart the ISR state machine Enable receiving of the next value. More...
 
void IRrecv::initDecodedIRData ()
 Is internally called by decode before calling decoders. More...
 
bool IRrecv::available ()
 Returns true if IR receiver data is available. More...
 
IRDataIRrecv::read ()
 If IR receiver data is available, returns pointer to IrReceiver.decodedIRData, else NULL. More...
 
bool IRrecv::decode ()
 The main decode function, attempts to decode the recently receive IR signal. More...
 
bool IRrecv::decodePulseWidthData (uint_fast8_t aNumberOfBits, uint_fast8_t aStartOffset, unsigned int aOneMarkMicros, unsigned int aZeroMarkMicros, unsigned int aBitSpaceMicros, bool aMSBfirst)
 Decode pulse width protocols. More...
 
bool IRrecv::decodePulseDistanceData (uint_fast8_t aNumberOfBits, uint_fast8_t aStartOffset, unsigned int aBitMarkMicros, unsigned int aOneSpaceMicros, unsigned int aZeroSpaceMicros, bool aMSBfirst)
 Decode pulse distance protocols. More...
 
void IRrecv::initBiphaselevel (uint_fast8_t aRCDecodeRawbuffOffset, unsigned int aBiphaseTimeUnit)
 
uint_fast8_t IRrecv::getBiphaselevel ()
 Gets the level of one time interval (aBiphaseTimeUnit) at a time from the raw buffer. More...
 
static void IRrecv::printActiveIRProtocols (Print *aSerial)
 
void IRrecv::printIRResultShort (Print *aSerial)
 Function to print values and flags of IrReceiver.decodedIRData in one line. More...
 
void IRrecv::printIRSendUsage (Print *aSerial)
 Function to print values and flags of IrReceiver.decodedIRData in one line. More...
 
void IRrecv::printIRResultMinimal (Print *aSerial)
 Function to print protocol number, address, command, raw data and repeat flag of IrReceiver.decodedIRData in one short line. More...
 
void IRrecv::printIRResultRawFormatted (Print *aSerial, bool aOutputMicrosecondsInsteadOfTicks=true)
 Dump out the timings in IrReceiver.decodedIRData.rawDataPtr->rawbuf[] array 8 values per line. More...
 
void IRrecv::compensateAndPrintIRResultAsCArray (Print *aSerial, bool aOutputMicrosecondsInsteadOfTicks=true)
 Dump out the IrReceiver.decodedIRData.rawDataPtr->rawbuf[] to be used as C definition for sendRaw(). More...
 
void IRrecv::compensateAndStoreIRResultInArray (uint8_t *aArrayPtr)
 Store the decodedIRData to be used for sendRaw(). More...
 
void IRrecv::printIRResultAsCVariables (Print *aSerial)
 Print results as C variables to be used for sendXXX() More...
 
const __FlashStringHelper * IRrecv::getProtocolString ()
 
bool IRrecv::decode (decode_results *aResults) __attribute__((deprecated("Please use IrReceiver.decode() without a parameter and IrReceiver.decodedIRData.<fieldname> .")))
 

Variables

IRrecv IrReceiver
 The receiver instance. More...
 
struct irparams_struct irparams
 
uint_fast8_t sBiphaseDecodeRawbuffOffset
 
unsigned int sCurrentTimingIntervals
 
uint_fast8_t sUsedTimingIntervals
 
unsigned int sBiphaseTimeUnit
 

Detailed Description

Function Documentation

◆ IRrecv() [1/3]

IRrecv::IRrecv ( )

Instantiate the IRrecv class.

Multiple instantiation is not supported.

Parameters
IRReceivePinArduino pin to use. No sanity check is made.

Definition at line 53 of file IRReceive.hpp.

◆ IRrecv() [2/3]

IRrecv::IRrecv ( uint_fast8_t  aReceivePin)

Definition at line 61 of file IRReceive.hpp.

◆ IRrecv() [3/3]

IRrecv::IRrecv ( uint_fast8_t  aReceivePin,
uint_fast8_t  aFeedbackLEDPin 
)

Instantiate the IRrecv class.

Multiple instantiation is not supported.

Parameters
aReceivePinArduino pin to use, where a demodulating IR receiver is connected.
aFeedbackLEDPinif 0, then take board specific FEEDBACK_LED_ON() and FEEDBACK_LED_OFF() functions

Definition at line 74 of file IRReceive.hpp.

◆ available()

bool IRrecv::available ( )

Returns true if IR receiver data is available.

Definition at line 239 of file IRReceive.hpp.

◆ begin()

void IRrecv::begin ( uint_fast8_t  aReceivePin,
bool  aEnableLEDFeedback = false,
uint_fast8_t  aFeedbackLEDPin = USE_DEFAULT_FEEDBACK_LED_PIN 
)

Initializes the receive and feedback pin.

Parameters
aReceivePinThe Arduino pin number, where a demodulating IR receiver is connected.
aEnableLEDFeedbackif true / ENABLE_LED_FEEDBACK, then let the feedback led blink on receiving IR signal
aFeedbackLEDPinif 0 / USE_DEFAULT_FEEDBACK_LED_PIN, then take board specific FEEDBACK_LED_ON() and FEEDBACK_LED_OFF() functions

Definition at line 93 of file IRReceive.hpp.

◆ CheckForRecordGapsMicros()

void CheckForRecordGapsMicros ( Print *  aSerial,
IRData aIRDataPtr 
)

Definition at line 860 of file IRReceive.hpp.

◆ compensateAndPrintIRResultAsCArray()

void IRrecv::compensateAndPrintIRResultAsCArray ( Print *  aSerial,
bool  aOutputMicrosecondsInsteadOfTicks = true 
)

Dump out the IrReceiver.decodedIRData.rawDataPtr->rawbuf[] to be used as C definition for sendRaw().

Compensate received values by MARK_EXCESS_MICROS, like it is done for decoding! Print ticks in 8 bit format to save space. Maximum is 255*50 microseconds = 12750 microseconds = 12.75 ms, which hardly ever occurs inside an IR sequence. Recording of IRremote anyway stops at a gap of RECORD_GAP_MICROS (5 ms).

Parameters
aSerialThe Print object on which to write, for Arduino you can use &Serial.
aOutputMicrosecondsInsteadOfTicksOutput the (rawbuf_values * MICROS_PER_TICK) for better readability.

Definition at line 1253 of file IRReceive.hpp.

◆ compensateAndStoreIRResultInArray()

void IRrecv::compensateAndStoreIRResultInArray ( uint8_t *  aArrayPtr)

Store the decodedIRData to be used for sendRaw().

Compensate received values by MARK_EXCESS_MICROS, like it is done for decoding and store it in an array provided.

Maximum for uint8_t is 255*50 microseconds = 12750 microseconds = 12.75 ms, which hardly ever occurs inside an IR sequence. Recording of IRremote anyway stops at a gap of RECORD_GAP_MICROS (5 ms).

Parameters
aArrayPtrAddress of an array provided by the caller.

Definition at line 1313 of file IRReceive.hpp.

◆ decode() [1/2]

bool IRrecv::decode ( )

The main decode function, attempts to decode the recently receive IR signal.

The set of decoders used is determined by active definitions of the DECODE_<PROTOCOL> macros.

Returns
false if no IR receiver data available, true if data available. Results of decoding are stored in IrReceiver.decodedIRData.

Definition at line 262 of file IRReceive.hpp.

◆ decode() [2/2]

bool IRrecv::decode ( decode_results aResults)

Definition at line 1595 of file IRReceive.hpp.

◆ decodePulseDistanceData()

bool IRrecv::decodePulseDistanceData ( uint_fast8_t  aNumberOfBits,
uint_fast8_t  aStartOffset,
unsigned int  aBitMarkMicros,
unsigned int  aOneSpaceMicros,
unsigned int  aZeroSpaceMicros,
bool  aMSBfirst 
)

Decode pulse distance protocols.

The mark (pulse) has constant length, the length of the space determines the bit value. Each bit looks like: MARK + SPACE_1 -> 1 or : MARK + SPACE_0 -> 0

Input is IrReceiver.decodedIRData.rawDataPtr->rawbuf[] Output is IrReceiver.decodedIRData.decodedRawData

Parameters
aStartOffsetmust point to a mark
Returns
true if decoding was successful

Definition at line 514 of file IRReceive.hpp.

◆ decodePulseWidthData()

bool IRrecv::decodePulseWidthData ( uint_fast8_t  aNumberOfBits,
uint_fast8_t  aStartOffset,
unsigned int  aOneMarkMicros,
unsigned int  aZeroMarkMicros,
unsigned int  aBitSpaceMicros,
bool  aMSBfirst 
)

Decode pulse width protocols.

Currently only used for sony protocol, which is LSB first. The space (pause) has constant length, the length of the mark determines the bit value. Each bit looks like: MARK_1 + SPACE -> 1 or : MARK_0 + SPACE -> 0

Input is IrReceiver.decodedIRData.rawDataPtr->rawbuf[] Output is IrReceiver.decodedIRData.decodedRawData

Parameters
aStartOffsetmust point to a mark
Returns
true if decoding was successful

Definition at line 414 of file IRReceive.hpp.

◆ disableIRIn()

void IRrecv::disableIRIn ( )

Alias for stop().

Definition at line 176 of file IRReceive.hpp.

◆ enableIRIn()

void IRrecv::enableIRIn ( )

Alias for start().

Definition at line 143 of file IRReceive.hpp.

◆ end()

void IRrecv::end ( )

Alias for stop().

Definition at line 182 of file IRReceive.hpp.

◆ getBiphaselevel()

uint_fast8_t IRrecv::getBiphaselevel ( )

Gets the level of one time interval (aBiphaseTimeUnit) at a time from the raw buffer.

The RC5/6 decoding is easier if the data is broken into time intervals. E.g. if the buffer has mark for 2 time intervals and space for 1, successive calls to getBiphaselevel will return 1, 1, 0.

          _   _   _   _   _   _   _   _   _   _   _   _   _
    _____| |_| |_| |_| |_| |_| |_| |_| |_| |_| |_| |_| |_| |
           ^   ^   ^   ^   ^   ^   ^   ^   ^   ^   ^   ^   ^    Significant clock edge
          _     _   _   ___   _     ___     ___   _   - Mark

Data _____| |___| |_| |_| |_| |___| |___| |_| | - Data starts with a mark->space bit 1 0 0 0 1 1 0 1 0 1 1 - Space A mark to space at a significant clock edge results in a 1 A space to mark at a significant clock edge results in a 0 (for RC6) Returns current level [MARK or SPACE] or -1 for error (measured time interval is not a multiple of sBiphaseTimeUnit).

Definition at line 622 of file IRReceive.hpp.

◆ getMarkExcessMicros()

int getMarkExcessMicros ( )

Getter function for MARK_EXCESS_MICROS.

Definition at line 852 of file IRReceive.hpp.

◆ getProtocolString() [1/2]

const __FlashStringHelper * IRrecv::getProtocolString ( )

Definition at line 1365 of file IRReceive.hpp.

◆ getProtocolString() [2/2]

const __FlashStringHelper* getProtocolString ( decode_type_t  aProtocol)

Definition at line 1370 of file IRReceive.hpp.

◆ initBiphaselevel()

void IRrecv::initBiphaselevel ( uint_fast8_t  aRCDecodeRawbuffOffset,
unsigned int  aBiphaseTimeUnit 
)

Definition at line 600 of file IRReceive.hpp.

◆ initDecodedIRData()

void IRrecv::initDecodedIRData ( )

Is internally called by decode before calling decoders.

Must be used to setup data, if you call decoders manually.

Definition at line 212 of file IRReceive.hpp.

◆ isIdle()

bool IRrecv::isIdle ( )

Returns status of reception.

Returns
true if no reception is on-going.

Definition at line 190 of file IRReceive.hpp.

◆ ISR()

ISR ( )

Definition at line 1482 of file IRReceive.hpp.

◆ MATCH()

bool MATCH ( unsigned int  measured_ticks,
unsigned int  desired_us 
)

Definition at line 779 of file IRReceive.hpp.

◆ MATCH_MARK()

bool MATCH_MARK ( unsigned int  measured_ticks,
unsigned int  desired_us 
)

Definition at line 812 of file IRReceive.hpp.

◆ MATCH_SPACE()

bool MATCH_SPACE ( unsigned int  measured_ticks,
unsigned int  desired_us 
)

Definition at line 845 of file IRReceive.hpp.

◆ matchMark()

bool matchMark ( unsigned int  aMeasuredTicks,
unsigned int  aMatchValueMicros 
)

Compensate for marks exceeded by demodulator hardware.

Definition at line 786 of file IRReceive.hpp.

◆ matchSpace()

bool matchSpace ( unsigned int  aMeasuredTicks,
unsigned int  aMatchValueMicros 
)

Compensate for spaces shortened by demodulator hardware.

Definition at line 819 of file IRReceive.hpp.

◆ matchTicks()

bool matchTicks ( unsigned int  aMeasuredTicks,
unsigned int  aMatchValueMicros 
)

Match function without compensating for marks exceeded or spaces shortened by demodulator hardware Currently not used.

Definition at line 759 of file IRReceive.hpp.

◆ printActiveIRProtocols() [1/2]

void IRrecv::printActiveIRProtocols ( Print *  aSerial)
static

Definition at line 882 of file IRReceive.hpp.

◆ printActiveIRProtocols() [2/2]

void printActiveIRProtocols ( Print *  aSerial)

Definition at line 886 of file IRReceive.hpp.

◆ printIRResultAsCVariables()

void IRrecv::printIRResultAsCVariables ( Print *  aSerial)

Print results as C variables to be used for sendXXX()

Parameters
aSerialThe Print object on which to write, for Arduino you can use &Serial.

Definition at line 1340 of file IRReceive.hpp.

◆ printIRResultMinimal()

void IRrecv::printIRResultMinimal ( Print *  aSerial)

Function to print protocol number, address, command, raw data and repeat flag of IrReceiver.decodedIRData in one short line.

Does not print a Newline / does not end with println().

Parameters
aSerialThe Print object on which to write, for Arduino you can use &Serial.

Definition at line 1130 of file IRReceive.hpp.

◆ printIRResultRawFormatted()

void IRrecv::printIRResultRawFormatted ( Print *  aSerial,
bool  aOutputMicrosecondsInsteadOfTicks = true 
)

Dump out the timings in IrReceiver.decodedIRData.rawDataPtr->rawbuf[] array 8 values per line.

Parameters
aSerialThe Print object on which to write, for Arduino you can use &Serial.
aOutputMicrosecondsInsteadOfTicksOutput the (rawbuf_values * MICROS_PER_TICK) for better readability.

Definition at line 1166 of file IRReceive.hpp.

◆ printIRResultShort() [1/2]

void IRrecv::printIRResultShort ( Print *  aSerial)

Function to print values and flags of IrReceiver.decodedIRData in one line.

Ends with println().

Parameters
aSerialThe Print object on which to write, for Arduino you can use &Serial.

Definition at line 950 of file IRReceive.hpp.

◆ printIRResultShort() [2/2]

void printIRResultShort ( Print *  aSerial,
IRData aIRDataPtr,
bool  aPrintRepeatGap 
)

Internal function to print decoded result and flags in one line.

Ends with println().

Parameters
aSerialThe Print object on which to write, for Arduino you can use &Serial.
aIRDataPtrPointer to the data to be printed.
aPrintRepeatGapIf true also print the gap before repeats.

Definition at line 963 of file IRReceive.hpp.

◆ printIRSendUsage() [1/2]

void IRrecv::printIRSendUsage ( Print *  aSerial)

Function to print values and flags of IrReceiver.decodedIRData in one line.

Ends with println().

Parameters
aSerialThe Print object on which to write, for Arduino you can use &Serial.

Definition at line 1053 of file IRReceive.hpp.

◆ printIRSendUsage() [2/2]

void printIRSendUsage ( Print *  aSerial,
IRData aIRDataPtr 
)

Definition at line 1058 of file IRReceive.hpp.

◆ read()

IRData * IRrecv::read ( )

If IR receiver data is available, returns pointer to IrReceiver.decodedIRData, else NULL.

Definition at line 246 of file IRReceive.hpp.

◆ restartAfterSend()

void IRrecv::restartAfterSend ( )

Restarts receiver after send.

Is a NOP if sending does not require a timer

Definition at line 161 of file IRReceive.hpp.

◆ resume()

void IRrecv::resume ( )

Restart the ISR state machine Enable receiving of the next value.

Definition at line 198 of file IRReceive.hpp.

◆ setReceivePin()

void IRrecv::setReceivePin ( uint_fast8_t  aReceivePinNumber)

Sets / changes the receiver pin number.

Definition at line 118 of file IRReceive.hpp.

◆ start() [1/2]

void IRrecv::start ( )

Configures the timer and the state machine for IR reception.

Definition at line 129 of file IRReceive.hpp.

◆ start() [2/2]

void IRrecv::start ( uint32_t  aMicrosecondsToAddToGapCounter)

Configures the timer and the state machine for IR reception.

Parameters
aMicrosecondsToAddToGapCounterTo compensate for the amount of microseconds the timer was stopped / disabled.

Definition at line 151 of file IRReceive.hpp.

◆ stop()

void IRrecv::stop ( )

Disables the timer for IR reception.

Definition at line 170 of file IRReceive.hpp.

Variable Documentation

◆ irparams

struct irparams_struct irparams

Definition at line 42 of file IRReceive.hpp.

◆ IrReceiver

IRrecv IrReceiver

The receiver instance.

Definition at line 42 of file IRReceive.hpp.

◆ sBiphaseDecodeRawbuffOffset

uint_fast8_t sBiphaseDecodeRawbuffOffset

Definition at line 595 of file IRReceive.hpp.

◆ sBiphaseTimeUnit

unsigned int sBiphaseTimeUnit

Definition at line 598 of file IRReceive.hpp.

◆ sCurrentTimingIntervals

unsigned int sCurrentTimingIntervals

Definition at line 596 of file IRReceive.hpp.

◆ sUsedTimingIntervals

uint_fast8_t sUsedTimingIntervals

Definition at line 597 of file IRReceive.hpp.