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, /* NEC with full frame as repeat */
58  RC5,
59  RC6,
65  /* Now the exotic protocols */
71  FAST
73 
74 #define SIRCS_12_PROTOCOL 12
75 #define SIRCS_15_PROTOCOL 15
76 #define SIRCS_20_PROTOCOL 20
77 
79  uint16_t HeaderMarkMicros;
81  uint16_t OneMarkMicros;
82  uint16_t OneSpaceMicros;
83  uint16_t ZeroMarkMicros;
84  uint16_t ZeroSpaceMicros;
85 };
86 
87 /*
88  * Definitions for member IRData.flags
89  */
90 #define IRDATA_FLAGS_EMPTY 0x00
91 #define IRDATA_FLAGS_IS_REPEAT 0x01
92 #define IRDATA_FLAGS_IS_AUTO_REPEAT 0x02
93 #define IRDATA_FLAGS_PARITY_FAILED 0x04
94 #define IRDATA_FLAGS_TOGGLE_BIT 0x08
95 #define IRDATA_TOGGLE_BIT_MASK 0x08
96 #define IRDATA_FLAGS_EXTRA_INFO 0x10
97 #define IRDATA_FLAGS_IS_PROTOCOL_WITH_DIFFERENT_REPEAT 0x20
98 #define IRDATA_FLAGS_WAS_OVERFLOW 0x40
99 #define IRDATA_FLAGS_IS_MSB_FIRST 0x80
100 #define IRDATA_FLAGS_IS_LSB_FIRST 0x00
101 
102 #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.
103 
107 struct IRData {
109  uint16_t address;
110  uint16_t command;
111  uint16_t extra;
113 #if defined(DECODE_DISTANCE_WIDTH)
114  // This replaces the address, command, extra and decodedRawData in case of protocol == PULSE_DISTANCE or -rather seldom- protocol == PULSE_WIDTH.
115  DistanceWidthTimingInfoStruct DistanceWidthTimingInfo; // 12 bytes
116  IRRawDataType decodedRawDataArray[RAW_DATA_ARRAY_SIZE];
117 #endif
118  uint16_t numberOfBits;
119  uint8_t flags;
120 
121  //These 2 variables allow to call resume() directly after decode, if no dump is required. Since 4.3.0.
122 #if RAW_BUFFER_LENGTH <= 254 // saves around 75 bytes program memory and speeds up ISR
123  uint_fast8_t rawlen;
124 #else
125  uint_fast16_t rawlen;
126 #endif
127  uint16_t initialGap;
128 
130 };
131 
134  uint_fast8_t FrequencyKHz;
136  uint8_t Flags;
137  unsigned int RepeatPeriodMillis;
138  void (*SpecialSendRepeatFunction)(); // using non member functions here saves up to 250 bytes for send demo
139 // void (IRsend::*SpecialSendRepeatFunction)();
140 };
141 /*
142  * Definitions for member PulseDistanceWidthProtocolConstants.Flags
143  */
144 #define SUPPRESS_STOP_BIT_FOR_THIS_DATA 0x20
145 #define PROTOCOL_IS_MSB_FIRST IRDATA_FLAGS_IS_MSB_FIRST
146 #define PROTOCOL_IS_LSB_FIRST IRDATA_FLAGS_IS_LSB_FIRST
147 // 2 definitions for deprecated parameter bool aSendStopBit
148 #define SEND_STOP_BIT true
149 #define SEND_NO_STOP_BIT false
150 
151 /*
152  * Carrier frequencies for various protocols
153  */
154 #if !defined(BEO_KHZ) // guard used for unit test, which sends and receive Bang&Olufsen with 38 kHz.
155 #define BEO_KHZ 455
156 #endif
157 #define SONY_KHZ 40
158 #define BOSEWAVE_KHZ 38
159 #define DENON_KHZ 38
160 #define JVC_KHZ 38
161 #define LG_KHZ 38
162 #define NEC_KHZ 38
163 #define SAMSUNG_KHZ 38
164 #define KASEIKYO_KHZ 37
165 #define RC5_RC6_KHZ 36
166 
167 #if defined(__AVR__)
168 const __FlashStringHelper* getProtocolString(decode_type_t aProtocol);
169 #else
170 const char* getProtocolString(decode_type_t aProtocol);
171 #endif
172 void printIRResultShort(Print *aSerial, IRData *aIRDataPtr, bool aPrintGap); // A static function to be able to print send or copied received data.
173 
174 /*
175  * Convenience functions to convert MSB to LSB values
176  */
177 uint8_t bitreverseOneByte(uint8_t aValue);
178 uint32_t bitreverse32Bit(uint32_t aInput);
179 
180 #endif // _IR_PROTOCOL_H
IRData::address
uint16_t address
Decoded address, Distance protocol (tMarkTicksLong (if tMarkTicksLong == 0, then tMarkTicksShort) << ...
Definition: IRProtocol.h:109
ONKYO
@ ONKYO
Definition: IRProtocol.h:51
DistanceWidthTimingInfoStruct::HeaderMarkMicros
uint16_t HeaderMarkMicros
Definition: IRProtocol.h:79
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:118
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
SONY
@ SONY
Definition: IRProtocol.h:64
IRData::rawlen
uint_fast8_t rawlen
counter of entries in rawbuf
Definition: IRProtocol.h:123
KASEIKYO_JVC
@ KASEIKYO_JVC
Definition: IRProtocol.h:56
PULSE_WIDTH
@ PULSE_WIDTH
Definition: IRProtocol.h:42
PulseDistanceWidthProtocolConstants::SpecialSendRepeatFunction
void(* SpecialSendRepeatFunction)()
Definition: IRProtocol.h:138
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:133
SAMSUNG
@ SAMSUNG
Definition: IRProtocol.h:60
BOSEWAVE
@ BOSEWAVE
Definition: IRProtocol.h:67
DistanceWidthTimingInfoStruct::OneSpaceMicros
uint16_t OneSpaceMicros
Definition: IRProtocol.h:82
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:129
IRData::decodedRawData
IRRawDataType decodedRawData
Up to 32/64 bit decoded raw data, to be used for send functions.
Definition: IRProtocol.h:112
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:95
DistanceWidthTimingInfoStruct::ZeroMarkMicros
uint16_t ZeroMarkMicros
Definition: IRProtocol.h:83
MAGIQUEST
@ MAGIQUEST
Definition: IRProtocol.h:69
NEC2
@ NEC2
Definition: IRProtocol.h:50
PulseDistanceWidthProtocolConstants::Flags
uint8_t Flags
Definition: IRProtocol.h:136
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:78
PulseDistanceWidthProtocolConstants
Definition: IRProtocol.h:132
PANASONIC
@ PANASONIC
Definition: IRProtocol.h:52
IRData
Data structure for the user application, available as decodedIRData.
Definition: IRProtocol.h:107
RAW_DATA_ARRAY_SIZE
#define RAW_DATA_ARRAY_SIZE
Definition: IRProtocol.h:102
IRData::flags
uint8_t flags
IRDATA_FLAGS_IS_REPEAT, IRDATA_FLAGS_WAS_OVERFLOW etc. See IRDATA_FLAGS_* definitions above.
Definition: IRProtocol.h:119
IRData::initialGap
uint16_t initialGap
rawbuf[0] contains the initial gap of the last frame.
Definition: IRProtocol.h:127
DistanceWidthTimingInfoStruct::OneMarkMicros
uint16_t OneMarkMicros
Definition: IRProtocol.h:81
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:110
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:84
IRRawDataType
uint32_t IRRawDataType
Definition: IRremoteInt.h:117
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:111
PulseDistanceWidthProtocolConstants::DistanceWidthTimingInfo
DistanceWidthTimingInfoStruct DistanceWidthTimingInfo
Definition: IRProtocol.h:135
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:137
SAMSUNGLG
@ SAMSUNGLG
Definition: IRProtocol.h:61
IRData::protocol
decode_type_t protocol
UNKNOWN, NEC, SONY, RC5, PULSE_DISTANCE, ...
Definition: IRProtocol.h:108
SAMSUNG48
@ SAMSUNG48
Definition: IRProtocol.h:62
PulseDistanceWidthProtocolConstants::FrequencyKHz
uint_fast8_t FrequencyKHz
Definition: IRProtocol.h:134
DistanceWidthTimingInfoStruct::HeaderSpaceMicros
uint16_t HeaderSpaceMicros
Definition: IRProtocol.h:80
LG
@ LG
Definition: IRProtocol.h:47
getProtocolString
const char * getProtocolString(decode_type_t aProtocol)
Definition: IRProtocol.hpp:96
SHARP
@ SHARP
Definition: IRProtocol.h:63