IRremote
IRProtocol.h
Go to the documentation of this file.
1 
32 #ifndef _IR_PROTOCOL_H
33 #define _IR_PROTOCOL_H
34 
40 typedef enum {
41  UNKNOWN = 0,
46  JVC,
47  LG,
48  LG2,
49  NEC,
50  NEC2, /* 10 NEC with full frame as repeat */
58  RC5,
59  RC6,
60  SAMSUNG, /* 20*/
65  /* Now the exotic protocols */
70  WHYNTER, /* 30 */
71  FAST
73 extern const char *const ProtocolNames[]; // The array of name strings for the decode_type_t enum
74 
75 #define SIRCS_12_PROTOCOL 12
76 #define SIRCS_15_PROTOCOL 15
77 #define SIRCS_20_PROTOCOL 20
78 
80  uint16_t HeaderMarkMicros;
82  uint16_t OneMarkMicros;
83  uint16_t OneSpaceMicros;
84  uint16_t ZeroMarkMicros;
85  uint16_t ZeroSpaceMicros;
86 };
87 
88 /*
89  * Definitions for member IRData.flags
90  */
91 #define IRDATA_FLAGS_EMPTY 0x00
92 #define IRDATA_FLAGS_IS_REPEAT 0x01
93 #define IRDATA_FLAGS_IS_AUTO_REPEAT 0x02
94 #define IRDATA_FLAGS_PARITY_FAILED 0x04
95 #define IRDATA_FLAGS_TOGGLE_BIT 0x08
96 #define IRDATA_TOGGLE_BIT_MASK 0x08
97 #define IRDATA_FLAGS_EXTRA_INFO 0x10
98 #define IRDATA_FLAGS_IS_PROTOCOL_WITH_DIFFERENT_REPEAT 0x20
99 #define IRDATA_FLAGS_WAS_OVERFLOW 0x40
100 #define IRDATA_FLAGS_IS_MSB_FIRST 0x80
101 #define IRDATA_FLAGS_IS_LSB_FIRST 0x00
102 
103 #define RAW_DATA_ARRAY_SIZE ((((RAW_BUFFER_LENGTH - 2) - 1) / (2 * BITS_IN_RAW_DATA_TYPE)) + 1) // The -2 is for initial gap + stop bit mark, 128 mark + spaces for 64 bit.
104 
108 struct IRData {
110  uint16_t address;
111  uint16_t command;
112  uint16_t extra;
114 #if defined(DECODE_DISTANCE_WIDTH)
115  // This replaces the address, command, extra and decodedRawData in case of protocol == PULSE_DISTANCE or -rather seldom- protocol == PULSE_WIDTH.
116  DistanceWidthTimingInfoStruct DistanceWidthTimingInfo; // 12 bytes
117  IRRawDataType decodedRawDataArray[RAW_DATA_ARRAY_SIZE];
118 #endif
119  uint16_t numberOfBits;
120  uint8_t flags;
121 
122  /*
123  * These 2 variables allow to call resume() directly after decode.
124  * After resume(), decodedIRData.rawDataPtr->initialGapTicks and decodedIRData.rawDataPtr->rawlen are
125  * the first variables, which are overwritten by the next received frame.
126  * since 4.3.0.
127  */
129  uint16_t initialGapTicks;
130 
132 };
133 
136  uint_fast8_t FrequencyKHz;
138  uint8_t Flags;
139  unsigned int RepeatPeriodMillis;
140  void (*SpecialSendRepeatFunction)(); // using non member functions here saves up to 250 bytes for send demo
141 // void (IRsend::*SpecialSendRepeatFunction)();
142 };
143 /*
144  * Definitions for member PulseDistanceWidthProtocolConstants.Flags
145  */
146 #define SUPPRESS_STOP_BIT 0x20 // Stop bit is otherwise sent for all pulse distance protocols, i.e. aOneSpaceMicros != aZeroSpaceMicros.
147 #define PROTOCOL_IS_MSB_FIRST IRDATA_FLAGS_IS_MSB_FIRST
148 #define PROTOCOL_IS_LSB_FIRST IRDATA_FLAGS_IS_LSB_FIRST
149 
150 /*
151  * Carrier frequencies for various protocols
152  */
153 #if !defined(BEO_KHZ) // guard used for unit test, which sends and receive Bang&Olufsen with 38 kHz.
154 #define BEO_KHZ 455
155 #endif
156 #define SONY_KHZ 40
157 #define BOSEWAVE_KHZ 38
158 #define DENON_KHZ 38
159 #define JVC_KHZ 38
160 #define LG_KHZ 38
161 #define NEC_KHZ 38
162 #define SAMSUNG_KHZ 38
163 #define KASEIKYO_KHZ 37
164 #define RC5_RC6_KHZ 36
165 
166 #if defined(__AVR__)
167 const __FlashStringHelper* getProtocolString(decode_type_t aProtocol);
168 #else
169 const char* getProtocolString(decode_type_t aProtocol);
170 #endif
171 void printIRResultShort(Print *aSerial, IRData *aIRDataPtr, bool aPrintGap); // A static function to be able to print send or copied received data.
172 
173 /*
174  * Convenience functions to convert MSB to LSB values
175  */
176 uint8_t bitreverseOneByte(uint8_t aValue);
177 uint32_t bitreverse32Bit(uint32_t aInput);
178 
179 #endif // _IR_PROTOCOL_H
IRData::address
uint16_t address
Decoded address, Distance protocol (tMarkTicksLong (if tMarkTicksLong == 0, then tMarkTicksShort) << ...
Definition: IRProtocol.h:110
ONKYO
@ ONKYO
Definition: IRProtocol.h:51
DistanceWidthTimingInfoStruct::HeaderMarkMicros
uint16_t HeaderMarkMicros
Definition: IRProtocol.h:80
KASEIKYO_DENON
@ KASEIKYO_DENON
Definition: IRProtocol.h:54
JVC
@ JVC
Definition: IRProtocol.h:46
IRData::numberOfBits
uint16_t numberOfBits
Number of bits received for data (address + command + parity) - to determine protocol length if diffe...
Definition: IRProtocol.h:119
bitreverse32Bit
uint32_t bitreverse32Bit(uint32_t aInput)
Definition: IRProtocol.hpp:274
KASEIKYO_SHARP
@ KASEIKYO_SHARP
Definition: IRProtocol.h:55
FAST
@ FAST
Definition: IRProtocol.h:71
IRRawlenType
unsigned int IRRawlenType
Definition: IRremoteInt.h:91
SONY
@ SONY
Definition: IRProtocol.h:64
KASEIKYO_JVC
@ KASEIKYO_JVC
Definition: IRProtocol.h:56
PULSE_WIDTH
@ PULSE_WIDTH
Definition: IRProtocol.h:42
PulseDistanceWidthProtocolConstants::SpecialSendRepeatFunction
void(* SpecialSendRepeatFunction)()
Definition: IRProtocol.h:140
decode_type_t
decode_type_t
An enum consisting of all supported formats.
Definition: IRProtocol.h:40
PulseDistanceWidthProtocolConstants::ProtocolIndex
decode_type_t ProtocolIndex
Definition: IRProtocol.h:135
SAMSUNG
@ SAMSUNG
Definition: IRProtocol.h:60
BOSEWAVE
@ BOSEWAVE
Definition: IRProtocol.h:67
DistanceWidthTimingInfoStruct::OneSpaceMicros
uint16_t OneSpaceMicros
Definition: IRProtocol.h:83
IRData::rawDataPtr
irparams_struct * rawDataPtr
Pointer of the raw timing data to be decoded. Mainly the OverflowFlag and the data buffer filled by r...
Definition: IRProtocol.h:131
IRData::decodedRawData
IRRawDataType decodedRawData
Up to 32/64 bit decoded raw data, to be used for send functions.
Definition: IRProtocol.h:113
PULSE_DISTANCE
@ PULSE_DISTANCE
Definition: IRProtocol.h:43
irparams_struct
This struct contains the data and control used for receiver static functions and the ISR (interrupt s...
Definition: IRremoteInt.h:129
DistanceWidthTimingInfoStruct::ZeroMarkMicros
uint16_t ZeroMarkMicros
Definition: IRProtocol.h:84
MAGIQUEST
@ MAGIQUEST
Definition: IRProtocol.h:69
NEC2
@ NEC2
Definition: IRProtocol.h:50
PulseDistanceWidthProtocolConstants::Flags
uint8_t Flags
Definition: IRProtocol.h:138
printIRResultShort
void printIRResultShort(Print *aSerial, IRData *aIRDataPtr, bool aPrintGap)
Function to print decoded result and flags in one line.
Definition: IRProtocol.hpp:162
DistanceWidthTimingInfoStruct
Definition: IRProtocol.h:79
ProtocolNames
const char *const ProtocolNames[]
Definition: IRProtocol.hpp:81
PulseDistanceWidthProtocolConstants
Definition: IRProtocol.h:134
PANASONIC
@ PANASONIC
Definition: IRProtocol.h:52
IRData
Data structure for the user application, available as decodedIRData.
Definition: IRProtocol.h:108
RAW_DATA_ARRAY_SIZE
#define RAW_DATA_ARRAY_SIZE
Definition: IRProtocol.h:103
IRData::flags
uint8_t flags
IRDATA_FLAGS_IS_REPEAT, IRDATA_FLAGS_WAS_OVERFLOW etc. See IRDATA_FLAGS_* definitions above.
Definition: IRProtocol.h:120
DistanceWidthTimingInfoStruct::OneMarkMicros
uint16_t OneMarkMicros
Definition: IRProtocol.h:82
bitreverseOneByte
uint8_t bitreverseOneByte(uint8_t aValue)
Definition: IRProtocol.hpp:261
IRData::command
uint16_t command
Decoded command, Distance protocol (tMarkTicksShort << 8) | tSpaceTicksShort.
Definition: IRProtocol.h:111
NEC
@ NEC
Definition: IRProtocol.h:49
BANG_OLUFSEN
@ BANG_OLUFSEN
Definition: IRProtocol.h:66
APPLE
@ APPLE
Definition: IRProtocol.h:44
LEGO_PF
@ LEGO_PF
Definition: IRProtocol.h:68
DistanceWidthTimingInfoStruct::ZeroSpaceMicros
uint16_t ZeroSpaceMicros
Definition: IRProtocol.h:85
IRRawDataType
uint32_t IRRawDataType
Definition: IRremoteInt.h:109
KASEIKYO_MITSUBISHI
@ KASEIKYO_MITSUBISHI
Definition: IRProtocol.h:57
KASEIKYO
@ KASEIKYO
Definition: IRProtocol.h:53
DENON
@ DENON
Definition: IRProtocol.h:45
RC5
@ RC5
Definition: IRProtocol.h:58
LG2
@ LG2
Definition: IRProtocol.h:48
IRData::extra
uint16_t extra
Contains upper 16 bit of Magiquest WandID, Kaseikyo unknown vendor ID and Distance protocol (HeaderMa...
Definition: IRProtocol.h:112
PulseDistanceWidthProtocolConstants::DistanceWidthTimingInfo
DistanceWidthTimingInfoStruct DistanceWidthTimingInfo
Definition: IRProtocol.h:137
IRData::rawlen
IRRawlenType rawlen
counter of entries in rawbuf of last received frame.
Definition: IRProtocol.h:128
RC6
@ RC6
Definition: IRProtocol.h:59
UNKNOWN
@ UNKNOWN
Definition: IRProtocol.h:41
WHYNTER
@ WHYNTER
Definition: IRProtocol.h:70
PulseDistanceWidthProtocolConstants::RepeatPeriodMillis
unsigned int RepeatPeriodMillis
Definition: IRProtocol.h:139
SAMSUNGLG
@ SAMSUNGLG
Definition: IRProtocol.h:61
IRData::protocol
decode_type_t protocol
UNKNOWN, NEC, SONY, RC5, PULSE_DISTANCE, ...
Definition: IRProtocol.h:109
SAMSUNG48
@ SAMSUNG48
Definition: IRProtocol.h:62
PulseDistanceWidthProtocolConstants::FrequencyKHz
uint_fast8_t FrequencyKHz
Definition: IRProtocol.h:136
DistanceWidthTimingInfoStruct::HeaderSpaceMicros
uint16_t HeaderSpaceMicros
Definition: IRProtocol.h:81
LG
@ LG
Definition: IRProtocol.h:47
IRData::initialGapTicks
uint16_t initialGapTicks
contains the initial gap (pre 4.4: the value in rawbuf[0]) of the last received frame.
Definition: IRProtocol.h:129
getProtocolString
const char * getProtocolString(decode_type_t aProtocol)
Definition: IRProtocol.hpp:96
SHARP
@ SHARP
Definition: IRProtocol.h:63