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