IRremote
Minimal receiver for NEC and FAST protocol

Classes

struct  TinyIRReceiverStruct
 Control and data variables of the state machine for TinyReceiver. More...
 
struct  TinyIRReceiverCallbackDataStruct
 Is filled before calling the user callback to transfer received data to main loop for further processing. More...
 

Macros

#define VERSION_TINYIR   "2.1.0"
 
#define VERSION_TINYIR_MAJOR   2
 
#define VERSION_TINYIR_MINOR   1
 
#define VERSION_TINYIR_PATCH   0
 
#define NEC_ADDRESS_BITS   16
 Timing for NEC protocol. More...
 
#define NEC_COMMAND_BITS   16
 
#define NEC_BITS   (NEC_ADDRESS_BITS + NEC_COMMAND_BITS)
 
#define NEC_UNIT   560
 
#define NEC_HEADER_MARK   (16 * NEC_UNIT)
 
#define NEC_HEADER_SPACE   (8 * NEC_UNIT)
 
#define NEC_BIT_MARK   NEC_UNIT
 
#define NEC_ONE_SPACE   (3 * NEC_UNIT)
 
#define NEC_ZERO_SPACE   NEC_UNIT
 
#define NEC_REPEAT_HEADER_SPACE   (4 * NEC_UNIT)
 
#define NEC_REPEAT_PERIOD   110000
 
#define NEC_MINIMAL_DURATION   49900
 
#define NEC_MAXIMUM_REPEAT_DISTANCE   (NEC_REPEAT_PERIOD - NEC_MINIMAL_DURATION + 10000)
 
#define FAST_KHZ   38
 The FAST protocol is a proprietary modified JVC protocol without address, with parity and with a shorter header. More...
 
#define FAST_ADDRESS_BITS   0
 
#define FAST_COMMAND_BITS   16
 
#define FAST_BITS   (FAST_ADDRESS_BITS + FAST_COMMAND_BITS)
 
#define FAST_UNIT   526
 
#define FAST_BIT_MARK   FAST_UNIT
 
#define FAST_ONE_SPACE   (3 * FAST_UNIT)
 
#define FAST_ZERO_SPACE   FAST_UNIT
 
#define FAST_HEADER_MARK   (4 * FAST_UNIT)
 
#define FAST_HEADER_SPACE   (2 * FAST_UNIT)
 
#define FAST_REPEAT_PERIOD   50000
 
#define FAST_REPEAT_DISTANCE   (FAST_REPEAT_PERIOD - (55 * FAST_UNIT))
 
#define FAST_MAXIMUM_REPEAT_DISTANCE   (FAST_REPEAT_DISTANCE + 10000)
 
#define TINY_RECEIVER_ADDRESS_BITS   NEC_ADDRESS_BITS
 
#define TINY_RECEIVER_ADDRESS_HAS_8_BIT_PARITY   true
 
#define TINY_RECEIVER_COMMAND_BITS   NEC_COMMAND_BITS
 
#define TINY_RECEIVER_COMMAND_HAS_8_BIT_PARITY   true
 
#define TINY_RECEIVER_BITS   NEC_BITS
 
#define TINY_RECEIVER_UNIT   NEC_UNIT
 
#define TINY_RECEIVER_HEADER_MARK   NEC_HEADER_MARK
 
#define TINY_RECEIVER_HEADER_SPACE   NEC_HEADER_SPACE
 
#define TINY_RECEIVER_BIT_MARK   NEC_BIT_MARK
 
#define TINY_RECEIVER_ONE_SPACE   NEC_ONE_SPACE
 
#define TINY_RECEIVER_ZERO_SPACE   NEC_ZERO_SPACE
 
#define TINY_RECEIVER_MAXIMUM_REPEAT_DISTANCE   NEC_MAXIMUM_REPEAT_DISTANCE
 
#define MICROS_IN_ONE_SECOND   1000000L
 
#define MICROS_IN_ONE_MILLI   1000L
 
#define lowerValue25Percent(aDuration)   (aDuration - (aDuration / 4))
 
#define upperValue25Percent(aDuration)   (aDuration + (aDuration / 4))
 
#define lowerValue50Percent(aDuration)   (aDuration / 2)
 
#define upperValue50Percent(aDuration)   (aDuration + (aDuration / 2))
 
#define IR_RECEIVER_STATE_WAITING_FOR_START_MARK   0
 
#define IR_RECEIVER_STATE_WAITING_FOR_START_SPACE   1
 
#define IR_RECEIVER_STATE_WAITING_FOR_FIRST_DATA_MARK   2
 
#define IR_RECEIVER_STATE_WAITING_FOR_DATA_SPACE   3
 
#define IR_RECEIVER_STATE_WAITING_FOR_DATA_MARK   4
 
#define IR_RECEIVER_STATE_WAITING_FOR_STOP_MARK   5
 
#define IRDATA_FLAGS_EMPTY   0x00
 
#define IRDATA_FLAGS_IS_REPEAT   0x01
 
#define IRDATA_FLAGS_IS_AUTO_REPEAT   0x02
 
#define IRDATA_FLAGS_PARITY_FAILED   0x04
 the current (autorepeat) frame violated parity check More...
 
#define IR_RECEIVE_PIN   2
 
#define TINY_RECEIVER_USE_ARDUINO_ATTACH_INTERRUPT
 
#define USE_ATTACH_INTERRUPT
 

Functions

bool isIRReceiverAttachedForTinyReceiver ()
 
bool initPCIInterruptForTinyReceiver ()
 Sets IR_RECEIVE_PIN mode to INPUT, and if IR_FEEDBACK_LED_PIN is defined, sets feedback LED output mode. More...
 
bool enablePCIInterruptForTinyReceiver ()
 Initializes hardware interrupt generation according to IR_RECEIVE_PIN or use attachInterrupt() function. More...
 
void disablePCIInterruptForTinyReceiver ()
 
bool isTinyReceiverIdle ()
 
void printTinyReceiverResultMinimal (Print *aSerial)
 
void sendFAST (uint8_t aSendPin, uint16_t aCommand, uint_fast8_t aNumberOfRepeats=0)
 
void sendFast8BitAndParity (uint8_t aSendPin, uint8_t aCommand, uint_fast8_t aNumberOfRepeats=0)
 
void sendONKYO (uint8_t aSendPin, uint16_t aAddress, uint16_t aCommand, uint_fast8_t aNumberOfRepeats=0, bool aSendNEC2Repeats=false)
 
void sendNECMinimal (uint8_t aSendPin, uint16_t aAddress, uint16_t aCommand, uint_fast8_t aNumberOfRepeats=0) __attribute__((deprecated("Renamed to sendNEC().")))
 
void sendNEC (uint8_t aSendPin, uint16_t aAddress, uint16_t aCommand, uint_fast8_t aNumberOfRepeats=0, bool aSendNEC2Repeats=false)
 
void sendExtendedNEC (uint8_t aSendPin, uint16_t aAddress, uint16_t aCommand, uint_fast8_t aNumberOfRepeats=0, bool aSendNEC2Repeats=false)
 
void handleTinyReceivedIRData ()
 Declaration of the callback function provided by the user application. More...
 
void IRPinChangeInterruptHandler (void)
 The ISR (Interrupt Service Routine) of TinyIRRreceiver. More...
 

Variables

volatile TinyIRReceiverCallbackDataStruct TinyIRReceiverData
 
TinyIRReceiverStruct TinyIRReceiverControl
 
volatile TinyIRReceiverCallbackDataStruct TinyIRReceiverData
 

Detailed Description

Macro Definition Documentation

◆ FAST_ADDRESS_BITS

#define FAST_ADDRESS_BITS   0

Definition at line 91 of file TinyIR.h.

◆ FAST_BIT_MARK

#define FAST_BIT_MARK   FAST_UNIT

Definition at line 97 of file TinyIR.h.

◆ FAST_BITS

#define FAST_BITS   (FAST_ADDRESS_BITS + FAST_COMMAND_BITS)

Definition at line 93 of file TinyIR.h.

◆ FAST_COMMAND_BITS

#define FAST_COMMAND_BITS   16

Definition at line 92 of file TinyIR.h.

◆ FAST_HEADER_MARK

#define FAST_HEADER_MARK   (4 * FAST_UNIT)

Definition at line 101 of file TinyIR.h.

◆ FAST_HEADER_SPACE

#define FAST_HEADER_SPACE   (2 * FAST_UNIT)

Definition at line 102 of file TinyIR.h.

◆ FAST_KHZ

#define FAST_KHZ   38

The FAST protocol is a proprietary modified JVC protocol without address, with parity and with a shorter header.

FAST protocol characteristics:

  • Bit timing is like NEC or JVC
  • The header is shorter, 3156 vs. 12500
  • No address and 16 bit data, interpreted as 8 bit command and 8 bit inverted command, leading to a fixed protocol length of (6 + (16 * 3) + 1) * 526 = 55 * 526 = 28930 microseconds or 29 ms.
  • Repeats are sent as complete frames but in a 50 ms period / with a 21 ms distance.

Definition at line 90 of file TinyIR.h.

◆ FAST_MAXIMUM_REPEAT_DISTANCE

#define FAST_MAXIMUM_REPEAT_DISTANCE   (FAST_REPEAT_DISTANCE + 10000)

Definition at line 106 of file TinyIR.h.

◆ FAST_ONE_SPACE

#define FAST_ONE_SPACE   (3 * FAST_UNIT)

Definition at line 98 of file TinyIR.h.

◆ FAST_REPEAT_DISTANCE

#define FAST_REPEAT_DISTANCE   (FAST_REPEAT_PERIOD - (55 * FAST_UNIT))

Definition at line 105 of file TinyIR.h.

◆ FAST_REPEAT_PERIOD

#define FAST_REPEAT_PERIOD   50000

Definition at line 104 of file TinyIR.h.

◆ FAST_UNIT

#define FAST_UNIT   526

Definition at line 95 of file TinyIR.h.

◆ FAST_ZERO_SPACE

#define FAST_ZERO_SPACE   FAST_UNIT

Definition at line 99 of file TinyIR.h.

◆ IR_RECEIVE_PIN

#define IR_RECEIVE_PIN   2

Definition at line 128 of file TinyIRReceiver.hpp.

◆ IR_RECEIVER_STATE_WAITING_FOR_DATA_MARK

#define IR_RECEIVER_STATE_WAITING_FOR_DATA_MARK   4

Definition at line 195 of file TinyIR.h.

◆ IR_RECEIVER_STATE_WAITING_FOR_DATA_SPACE

#define IR_RECEIVER_STATE_WAITING_FOR_DATA_SPACE   3

Definition at line 194 of file TinyIR.h.

◆ IR_RECEIVER_STATE_WAITING_FOR_FIRST_DATA_MARK

#define IR_RECEIVER_STATE_WAITING_FOR_FIRST_DATA_MARK   2

Definition at line 193 of file TinyIR.h.

◆ IR_RECEIVER_STATE_WAITING_FOR_START_MARK

#define IR_RECEIVER_STATE_WAITING_FOR_START_MARK   0

Definition at line 191 of file TinyIR.h.

◆ IR_RECEIVER_STATE_WAITING_FOR_START_SPACE

#define IR_RECEIVER_STATE_WAITING_FOR_START_SPACE   1

Definition at line 192 of file TinyIR.h.

◆ IR_RECEIVER_STATE_WAITING_FOR_STOP_MARK

#define IR_RECEIVER_STATE_WAITING_FOR_STOP_MARK   5

Definition at line 196 of file TinyIR.h.

◆ IRDATA_FLAGS_EMPTY

#define IRDATA_FLAGS_EMPTY   0x00

Definition at line 224 of file TinyIR.h.

◆ IRDATA_FLAGS_IS_AUTO_REPEAT

#define IRDATA_FLAGS_IS_AUTO_REPEAT   0x02

Definition at line 226 of file TinyIR.h.

◆ IRDATA_FLAGS_IS_REPEAT

#define IRDATA_FLAGS_IS_REPEAT   0x01

Definition at line 225 of file TinyIR.h.

◆ IRDATA_FLAGS_PARITY_FAILED

#define IRDATA_FLAGS_PARITY_FAILED   0x04

the current (autorepeat) frame violated parity check

Definition at line 227 of file TinyIR.h.

◆ lowerValue25Percent

#define lowerValue25Percent (   aDuration)    (aDuration - (aDuration / 4))

Definition at line 183 of file TinyIR.h.

◆ lowerValue50Percent

#define lowerValue50Percent (   aDuration)    (aDuration / 2)

Definition at line 185 of file TinyIR.h.

◆ MICROS_IN_ONE_MILLI

#define MICROS_IN_ONE_MILLI   1000L

Definition at line 177 of file TinyIR.h.

◆ MICROS_IN_ONE_SECOND

#define MICROS_IN_ONE_SECOND   1000000L

Definition at line 173 of file TinyIR.h.

◆ NEC_ADDRESS_BITS

#define NEC_ADDRESS_BITS   16

Timing for NEC protocol.

see: https://www.sbprojects.net/knowledge/ir/nec.php LSB first, 1 start bit + 16 bit address + 8 bit data + 8 bit inverted data + 1 stop bit.

Definition at line 51 of file TinyIR.h.

◆ NEC_BIT_MARK

#define NEC_BIT_MARK   NEC_UNIT

Definition at line 60 of file TinyIR.h.

◆ NEC_BITS

#define NEC_BITS   (NEC_ADDRESS_BITS + NEC_COMMAND_BITS)

Definition at line 53 of file TinyIR.h.

◆ NEC_COMMAND_BITS

#define NEC_COMMAND_BITS   16

Definition at line 52 of file TinyIR.h.

◆ NEC_HEADER_MARK

#define NEC_HEADER_MARK   (16 * NEC_UNIT)

Definition at line 57 of file TinyIR.h.

◆ NEC_HEADER_SPACE

#define NEC_HEADER_SPACE   (8 * NEC_UNIT)

Definition at line 58 of file TinyIR.h.

◆ NEC_MAXIMUM_REPEAT_DISTANCE

#define NEC_MAXIMUM_REPEAT_DISTANCE   (NEC_REPEAT_PERIOD - NEC_MINIMAL_DURATION + 10000)

Definition at line 68 of file TinyIR.h.

◆ NEC_MINIMAL_DURATION

#define NEC_MINIMAL_DURATION   49900

Definition at line 67 of file TinyIR.h.

◆ NEC_ONE_SPACE

#define NEC_ONE_SPACE   (3 * NEC_UNIT)

Definition at line 61 of file TinyIR.h.

◆ NEC_REPEAT_HEADER_SPACE

#define NEC_REPEAT_HEADER_SPACE   (4 * NEC_UNIT)

Definition at line 64 of file TinyIR.h.

◆ NEC_REPEAT_PERIOD

#define NEC_REPEAT_PERIOD   110000

Definition at line 66 of file TinyIR.h.

◆ NEC_UNIT

#define NEC_UNIT   560

Definition at line 55 of file TinyIR.h.

◆ NEC_ZERO_SPACE

#define NEC_ZERO_SPACE   NEC_UNIT

Definition at line 62 of file TinyIR.h.

◆ TINY_RECEIVER_ADDRESS_BITS

#define TINY_RECEIVER_ADDRESS_BITS   NEC_ADDRESS_BITS

Definition at line 135 of file TinyIR.h.

◆ TINY_RECEIVER_ADDRESS_HAS_8_BIT_PARITY

#define TINY_RECEIVER_ADDRESS_HAS_8_BIT_PARITY   true

Definition at line 141 of file TinyIR.h.

◆ TINY_RECEIVER_BIT_MARK

#define TINY_RECEIVER_BIT_MARK   NEC_BIT_MARK

Definition at line 157 of file TinyIR.h.

◆ TINY_RECEIVER_BITS

#define TINY_RECEIVER_BITS   NEC_BITS

Definition at line 151 of file TinyIR.h.

◆ TINY_RECEIVER_COMMAND_BITS

#define TINY_RECEIVER_COMMAND_BITS   NEC_COMMAND_BITS

Definition at line 144 of file TinyIR.h.

◆ TINY_RECEIVER_COMMAND_HAS_8_BIT_PARITY

#define TINY_RECEIVER_COMMAND_HAS_8_BIT_PARITY   true

Definition at line 148 of file TinyIR.h.

◆ TINY_RECEIVER_HEADER_MARK

#define TINY_RECEIVER_HEADER_MARK   NEC_HEADER_MARK

Definition at line 154 of file TinyIR.h.

◆ TINY_RECEIVER_HEADER_SPACE

#define TINY_RECEIVER_HEADER_SPACE   NEC_HEADER_SPACE

Definition at line 155 of file TinyIR.h.

◆ TINY_RECEIVER_MAXIMUM_REPEAT_DISTANCE

#define TINY_RECEIVER_MAXIMUM_REPEAT_DISTANCE   NEC_MAXIMUM_REPEAT_DISTANCE

Definition at line 161 of file TinyIR.h.

◆ TINY_RECEIVER_ONE_SPACE

#define TINY_RECEIVER_ONE_SPACE   NEC_ONE_SPACE

Definition at line 158 of file TinyIR.h.

◆ TINY_RECEIVER_UNIT

#define TINY_RECEIVER_UNIT   NEC_UNIT

Definition at line 152 of file TinyIR.h.

◆ TINY_RECEIVER_USE_ARDUINO_ATTACH_INTERRUPT

#define TINY_RECEIVER_USE_ARDUINO_ATTACH_INTERRUPT

Definition at line 147 of file TinyIRReceiver.hpp.

◆ TINY_RECEIVER_ZERO_SPACE

#define TINY_RECEIVER_ZERO_SPACE   NEC_ZERO_SPACE

Definition at line 159 of file TinyIR.h.

◆ upperValue25Percent

#define upperValue25Percent (   aDuration)    (aDuration + (aDuration / 4))

Definition at line 184 of file TinyIR.h.

◆ upperValue50Percent

#define upperValue50Percent (   aDuration)    (aDuration + (aDuration / 2))

Definition at line 186 of file TinyIR.h.

◆ USE_ATTACH_INTERRUPT

#define USE_ATTACH_INTERRUPT

Definition at line 490 of file TinyIRReceiver.hpp.

◆ VERSION_TINYIR

#define VERSION_TINYIR   "2.1.0"

Definition at line 38 of file TinyIR.h.

◆ VERSION_TINYIR_MAJOR

#define VERSION_TINYIR_MAJOR   2

Definition at line 39 of file TinyIR.h.

◆ VERSION_TINYIR_MINOR

#define VERSION_TINYIR_MINOR   1

Definition at line 40 of file TinyIR.h.

◆ VERSION_TINYIR_PATCH

#define VERSION_TINYIR_PATCH   0

Definition at line 41 of file TinyIR.h.

Function Documentation

◆ disablePCIInterruptForTinyReceiver()

void disablePCIInterruptForTinyReceiver ( )

Definition at line 620 of file TinyIRReceiver.hpp.

◆ enablePCIInterruptForTinyReceiver()

bool enablePCIInterruptForTinyReceiver ( )

Initializes hardware interrupt generation according to IR_RECEIVE_PIN or use attachInterrupt() function.

Returns
true if interrupt was successfully enabled

Definition at line 554 of file TinyIRReceiver.hpp.

◆ handleTinyReceivedIRData()

void handleTinyReceivedIRData ( )

Declaration of the callback function provided by the user application.

It is called every time a complete IR command or repeat was received.

◆ initPCIInterruptForTinyReceiver()

bool initPCIInterruptForTinyReceiver ( )

Sets IR_RECEIVE_PIN mode to INPUT, and if IR_FEEDBACK_LED_PIN is defined, sets feedback LED output mode.

Then call enablePCIInterruptForTinyReceiver()

Definition at line 444 of file TinyIRReceiver.hpp.

◆ IRPinChangeInterruptHandler()

void IRPinChangeInterruptHandler ( void  )

The ISR (Interrupt Service Routine) of TinyIRRreceiver.

It handles the NEC protocol decoding and calls the user callback function on complete. 5 us + 3 us for push + pop for a 16MHz ATmega

Definition at line 166 of file TinyIRReceiver.hpp.

◆ isIRReceiverAttachedForTinyReceiver()

bool isIRReceiverAttachedForTinyReceiver ( )

Definition at line 433 of file TinyIRReceiver.hpp.

◆ isTinyReceiverIdle()

bool isTinyReceiverIdle ( )

Definition at line 425 of file TinyIRReceiver.hpp.

◆ printTinyReceiverResultMinimal()

void printTinyReceiverResultMinimal ( Print *  aSerial)

Definition at line 453 of file TinyIRReceiver.hpp.

◆ sendExtendedNEC()

void sendExtendedNEC ( uint8_t  aSendPin,
uint16_t  aAddress,
uint16_t  aCommand,
uint_fast8_t  aNumberOfRepeats = 0,
bool  aSendNEC2Repeats = false 
)

Definition at line 234 of file TinyIRSender.hpp.

◆ sendFAST()

void sendFAST ( uint8_t  aSendPin,
uint16_t  aCommand,
uint_fast8_t  aNumberOfRepeats = 0 
)

Definition at line 294 of file TinyIRSender.hpp.

◆ sendFast8BitAndParity()

void sendFast8BitAndParity ( uint8_t  aSendPin,
uint8_t  aCommand,
uint_fast8_t  aNumberOfRepeats = 0 
)

Definition at line 287 of file TinyIRSender.hpp.

◆ sendNEC()

void sendNEC ( uint8_t  aSendPin,
uint16_t  aAddress,
uint16_t  aCommand,
uint_fast8_t  aNumberOfRepeats = 0,
bool  aSendNEC2Repeats = false 
)

Definition at line 168 of file TinyIRSender.hpp.

◆ sendNECMinimal()

void sendNECMinimal ( uint8_t  aSendPin,
uint16_t  aAddress,
uint16_t  aCommand,
uint_fast8_t  aNumberOfRepeats = 0 
)

Definition at line 165 of file TinyIRSender.hpp.

◆ sendONKYO()

void sendONKYO ( uint8_t  aSendPin,
uint16_t  aAddress,
uint16_t  aCommand,
uint_fast8_t  aNumberOfRepeats = 0,
bool  aSendNEC2Repeats = false 
)

Definition at line 114 of file TinyIRSender.hpp.

Variable Documentation

◆ TinyIRReceiverControl

TinyIRReceiverStruct TinyIRReceiverControl

Definition at line 108 of file TinyIRReceiver.hpp.

◆ TinyIRReceiverData [1/2]

volatile TinyIRReceiverCallbackDataStruct TinyIRReceiverData

Definition at line 109 of file TinyIRReceiver.hpp.

◆ TinyIRReceiverData [2/2]

volatile TinyIRReceiverCallbackDataStruct TinyIRReceiverData

Definition at line 109 of file TinyIRReceiver.hpp.