IRremote
IRProtocol.h
Go to the documentation of this file.
1 
32 #ifndef _IR_PROTOCOL_H
33 #define _IR_PROTOCOL_H
34 
35 /*
36  * If activated, BANG_OLUFSEN, BOSEWAVE, MAGIQUEST, WHYNTER, FAST and LEGO_PF are excluded in decoding and in sending with IrSender.write
37  */
38 //#define EXCLUDE_EXOTIC_PROTOCOLS
39 
40 /*
41  * Supported IR protocols
42  * Each protocol you include costs memory and, during decode, costs time
43  * Copy the lines with the protocols you need in your program before the #include <IRremote.hpp> line
44  * See also SimpleReceiver example
45  */
46 
47 #if !defined(NO_DECODER) // for sending raw only
48 # if (!(defined(DECODE_DENON) || defined(DECODE_JVC) || defined(DECODE_KASEIKYO) \
49 || defined(DECODE_PANASONIC) || defined(DECODE_LG) || defined(DECODE_NEC) || defined(DECODE_ONKYO) || defined(DECODE_SAMSUNG) \
50 || defined(DECODE_SONY) || defined(DECODE_RC5) || defined(DECODE_RC6) \
51 || defined(DECODE_DISTANCE_WIDTH) || defined(DECODE_HASH) || defined(DECODE_BOSEWAVE) \
52 || defined(DECODE_LEGO_PF) || defined(DECODE_MAGIQUEST) || defined(DECODE_FAST) || defined(DECODE_WHYNTER)))
53 /*
54  * If no protocol is explicitly enabled, we enable all protocols
55  */
56 #define DECODE_DENON // Includes Sharp
57 #define DECODE_JVC
58 #define DECODE_KASEIKYO
59 #define DECODE_PANASONIC // alias for DECODE_KASEIKYO
60 #define DECODE_LG
61 #define DECODE_NEC // Includes Apple and Onkyo
62 #define DECODE_SAMSUNG
63 #define DECODE_SONY
64 #define DECODE_RC5
65 #define DECODE_RC6
66 
67 # if !defined(EXCLUDE_EXOTIC_PROTOCOLS) // saves around 2000 bytes program memory
68 #define DECODE_BOSEWAVE
69 #define DECODE_LEGO_PF
70 #define DECODE_MAGIQUEST
71 #define DECODE_WHYNTER
72 #define DECODE_FAST
73 # endif
74 
75 # if !defined(EXCLUDE_UNIVERSAL_PROTOCOLS)
76 #define DECODE_DISTANCE_WIDTH // universal decoder for pulse distance width protocols - requires up to 750 bytes additional program memory
77 #define DECODE_HASH // special decoder for all protocols - requires up to 250 bytes additional program memory
78 # endif
79 # endif
80 #endif // !defined(NO_DECODER)
81 
82 //#define DECODE_BEO // Bang & Olufsen protocol always must be enabled explicitly. It prevents decoding of SONY!
83 
84 #if defined(DECODE_NEC) && !(~(~DECODE_NEC + 0) == 0 && ~(~DECODE_NEC + 1) == 1)
85 #warning "The macros DECODE_XXX no longer require a value. Decoding is now switched by defining / non defining the macro."
86 #endif
87 
93 typedef enum {
94  UNKNOWN = 0,
99  JVC,
100  LG,
103  NEC2, /* 10 NEC with full frame as repeat */
113  RC6A, /*31 bit + 3 fixed 0b110 mode bits*/
114  SAMSUNG, /* 20*/
119  /* Now the exotic protocols */
124  WHYNTER, /* 30 */
126  OTHER
128 extern const char *const ProtocolNames[]; // The array of name strings for the decode_type_t enum
129 
130 #define SIRCS_12_PROTOCOL 12
131 #define SIRCS_15_PROTOCOL 15
132 #define SIRCS_20_PROTOCOL 20
133 
137  uint16_t OneMarkMicros;
138  uint16_t OneSpaceMicros;
139  uint16_t ZeroMarkMicros;
140  uint16_t ZeroSpaceMicros;
141 };
142 
143 /*
144  * Definitions for member IRData.flags
145  */
146 #define IRDATA_FLAGS_EMPTY 0x00
147 #define IRDATA_FLAGS_IS_REPEAT 0x01
148 #define IRDATA_FLAGS_IS_AUTO_REPEAT 0x02
149 #define IRDATA_FLAGS_PARITY_FAILED 0x04
150 #define IRDATA_FLAGS_TOGGLE_BIT 0x08
151 #define IRDATA_TOGGLE_BIT_MASK 0x08
152 #define IRDATA_FLAGS_EXTRA_INFO 0x10
153 #define IRDATA_FLAGS_IS_PROTOCOL_WITH_DIFFERENT_REPEAT 0x20
154 #define IRDATA_FLAGS_WAS_OVERFLOW 0x40
155 #define IRDATA_FLAGS_IS_MSB_FIRST 0x80
156 #define IRDATA_FLAGS_IS_LSB_FIRST 0x00
157 #define IRDATA_FLAGS_LSB_MSB_FIRST_MASK IRDATA_FLAGS_IS_MSB_FIRST
158 
159 extern uint8_t sLastSendToggleValue; // Currently used by RC5 + RC6
160 
163  uint_fast8_t FrequencyKHz;
165  uint8_t Flags;
166  unsigned int RepeatPeriodMillis;
167  void (*SpecialSendRepeatFunction)(); // using non member functions here saves up to 250 bytes for send demo
168 // void (IRsend::*SpecialSendRepeatFunction)();
169 };
170 /*
171  * Definitions for member PulseDistanceWidthProtocolConstants.Flags
172  */
173 #define PROTOCOL_IS_PULSE_DISTANCE 0x00
174 #define PROTOCOL_IS_PULSE_DISTANCE_WIDTH 0x00 // can often successfully be decoded as pulse distance
175 #define PROTOCOL_IS_PULSE_WIDTH 0x10
176 #define PROTOCOL_IS_PULSE_WIDTH_MASK PROTOCOL_IS_PULSE_WIDTH
177 #define SUPPRESS_STOP_BIT 0x20 // Stop bit is otherwise sent for all pulse distance protocols, i.e. aOneSpaceMicros != aZeroSpaceMicros.
178 #define PROTOCOL_IS_MSB_FIRST IRDATA_FLAGS_IS_MSB_FIRST
179 #define PROTOCOL_IS_LSB_FIRST IRDATA_FLAGS_IS_LSB_FIRST
180 #define PROTOCOL_IS_MSB_MASK IRDATA_FLAGS_IS_MSB_FIRST
181 
182 /*
183  * Carrier frequencies for various protocols
184  */
185 #if !defined(BEO_KHZ) // guard used for unit test, which sends and receive Bang&Olufsen with 38 kHz.
186 #define BEO_KHZ 455
187 #endif
188 #define SONY_KHZ 40
189 #define BOSEWAVE_KHZ 38
190 #define DENON_KHZ 38
191 #define JVC_KHZ 38
192 #define LG_KHZ 38
193 #define NEC_KHZ 38
194 #define SAMSUNG_KHZ 38
195 #define KASEIKYO_KHZ 37
196 #define RC5_RC6_KHZ 36
197 
198 #if defined(__AVR__)
199 const __FlashStringHelper* getProtocolString(decode_type_t aProtocol);
200 #else
201 const char* getProtocolString(decode_type_t aProtocol);
202 #endif
203 
204 /*
205  * Convenience functions to convert MSB to LSB values
206  */
207 uint8_t bitreverseOneByte(uint8_t aValue);
208 uint32_t bitreverse32Bit(uint32_t aInput);
209 
210 #endif // _IR_PROTOCOL_H
ONKYO
@ ONKYO
Definition: IRProtocol.h:104
DistanceWidthTimingInfoStruct::HeaderMarkMicros
uint16_t HeaderMarkMicros
Definition: IRProtocol.h:135
KASEIKYO_DENON
@ KASEIKYO_DENON
Definition: IRProtocol.h:107
JVC
@ JVC
Definition: IRProtocol.h:99
KASEIKYO_SHARP
@ KASEIKYO_SHARP
Definition: IRProtocol.h:108
FAST
@ FAST
Definition: IRProtocol.h:125
SONY
@ SONY
Definition: IRProtocol.h:118
KASEIKYO_JVC
@ KASEIKYO_JVC
Definition: IRProtocol.h:109
PULSE_WIDTH
@ PULSE_WIDTH
Definition: IRProtocol.h:95
PulseDistanceWidthProtocolConstants::SpecialSendRepeatFunction
void(* SpecialSendRepeatFunction)()
Definition: IRProtocol.h:167
decode_type_t
decode_type_t
An enum consisting of all supported formats.
Definition: IRProtocol.h:93
sLastSendToggleValue
uint8_t sLastSendToggleValue
Definition: ir_RC5_RC6.hpp:44
PulseDistanceWidthProtocolConstants::ProtocolIndex
decode_type_t ProtocolIndex
Definition: IRProtocol.h:162
SAMSUNG
@ SAMSUNG
Definition: IRProtocol.h:114
BOSEWAVE
@ BOSEWAVE
Definition: IRProtocol.h:121
DistanceWidthTimingInfoStruct::OneSpaceMicros
uint16_t OneSpaceMicros
Definition: IRProtocol.h:138
PULSE_DISTANCE
@ PULSE_DISTANCE
Definition: IRProtocol.h:96
DistanceWidthTimingInfoStruct::ZeroMarkMicros
uint16_t ZeroMarkMicros
Definition: IRProtocol.h:139
MAGIQUEST
@ MAGIQUEST
Definition: IRProtocol.h:123
NEC2
@ NEC2
Definition: IRProtocol.h:103
PulseDistanceWidthProtocolConstants::Flags
uint8_t Flags
Definition: IRProtocol.h:165
DistanceWidthTimingInfoStruct
Definition: IRProtocol.h:134
ProtocolNames
const char *const ProtocolNames[]
Definition: IRProtocol.hpp:83
PulseDistanceWidthProtocolConstants
Definition: IRProtocol.h:161
PANASONIC
@ PANASONIC
Definition: IRProtocol.h:105
DistanceWidthTimingInfoStruct::OneMarkMicros
uint16_t OneMarkMicros
Definition: IRProtocol.h:137
NEC
@ NEC
Definition: IRProtocol.h:102
BANG_OLUFSEN
@ BANG_OLUFSEN
Definition: IRProtocol.h:120
bitreverse32Bit
uint32_t bitreverse32Bit(uint32_t aInput)
Definition: IRProtocol.hpp:174
APPLE
@ APPLE
Definition: IRProtocol.h:97
LEGO_PF
@ LEGO_PF
Definition: IRProtocol.h:122
DistanceWidthTimingInfoStruct::ZeroSpaceMicros
uint16_t ZeroSpaceMicros
Definition: IRProtocol.h:140
KASEIKYO_MITSUBISHI
@ KASEIKYO_MITSUBISHI
Definition: IRProtocol.h:110
KASEIKYO
@ KASEIKYO
Definition: IRProtocol.h:106
DENON
@ DENON
Definition: IRProtocol.h:98
RC6A
@ RC6A
Definition: IRProtocol.h:113
RC5
@ RC5
Definition: IRProtocol.h:111
LG2
@ LG2
Definition: IRProtocol.h:101
PulseDistanceWidthProtocolConstants::DistanceWidthTimingInfo
DistanceWidthTimingInfoStruct DistanceWidthTimingInfo
Definition: IRProtocol.h:164
RC6
@ RC6
Definition: IRProtocol.h:112
bitreverseOneByte
uint8_t bitreverseOneByte(uint8_t aValue)
Definition: IRProtocol.hpp:161
UNKNOWN
@ UNKNOWN
Definition: IRProtocol.h:94
WHYNTER
@ WHYNTER
Definition: IRProtocol.h:124
PulseDistanceWidthProtocolConstants::RepeatPeriodMillis
unsigned int RepeatPeriodMillis
Definition: IRProtocol.h:166
SAMSUNGLG
@ SAMSUNGLG
Definition: IRProtocol.h:115
SAMSUNG48
@ SAMSUNG48
Definition: IRProtocol.h:116
PulseDistanceWidthProtocolConstants::FrequencyKHz
uint_fast8_t FrequencyKHz
Definition: IRProtocol.h:163
DistanceWidthTimingInfoStruct::HeaderSpaceMicros
uint16_t HeaderSpaceMicros
Definition: IRProtocol.h:136
LG
@ LG
Definition: IRProtocol.h:100
OTHER
@ OTHER
Definition: IRProtocol.h:126
getProtocolString
const char * getProtocolString(decode_type_t aProtocol)
Definition: IRProtocol.hpp:98
SHARP
@ SHARP
Definition: IRProtocol.h:117