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  RC6A, /*31 bit + 3 fixed 0b110 mode bits*/
61  SAMSUNG, /* 20*/
66  /* Now the exotic protocols */
71  WHYNTER, /* 30 */
72  FAST
74 extern const char *const ProtocolNames[]; // The array of name strings for the decode_type_t enum
75 
76 #define SIRCS_12_PROTOCOL 12
77 #define SIRCS_15_PROTOCOL 15
78 #define SIRCS_20_PROTOCOL 20
79 
81  uint16_t HeaderMarkMicros;
83  uint16_t OneMarkMicros;
84  uint16_t OneSpaceMicros;
85  uint16_t ZeroMarkMicros;
86  uint16_t ZeroSpaceMicros;
87 };
88 
89 /*
90  * Definitions for member IRData.flags
91  */
92 #define IRDATA_FLAGS_EMPTY 0x00
93 #define IRDATA_FLAGS_IS_REPEAT 0x01
94 #define IRDATA_FLAGS_IS_AUTO_REPEAT 0x02
95 #define IRDATA_FLAGS_PARITY_FAILED 0x04
96 #define IRDATA_FLAGS_TOGGLE_BIT 0x08
97 #define IRDATA_TOGGLE_BIT_MASK 0x08
98 #define IRDATA_FLAGS_EXTRA_INFO 0x10
99 #define IRDATA_FLAGS_IS_PROTOCOL_WITH_DIFFERENT_REPEAT 0x20
100 #define IRDATA_FLAGS_WAS_OVERFLOW 0x40
101 #define IRDATA_FLAGS_IS_MSB_FIRST 0x80
102 #define IRDATA_FLAGS_IS_LSB_FIRST 0x00
103 
104 #define DECODED_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.
105 
109 struct IRData {
111  uint16_t address;
112  uint16_t command;
113  uint16_t extra;
115 #if defined(DECODE_DISTANCE_WIDTH)
116  // This replaces the address, command, extra and decodedRawData in case of protocol == PULSE_DISTANCE or -rather seldom- protocol == PULSE_WIDTH.
117  DistanceWidthTimingInfoStruct DistanceWidthTimingInfo; // 12 bytes
118  IRRawDataType decodedRawDataArray[DECODED_RAW_DATA_ARRAY_SIZE];
119 #endif
120  uint16_t numberOfBits;
121  uint8_t flags;
122 
123  /*
124  * These 2 variables allow to call resume() directly after decode.
125  * After resume(), decodedIRData.rawDataPtr->initialGapTicks and decodedIRData.rawDataPtr->rawlen are
126  * the first variables, which are overwritten by the next received frame.
127  * since 4.3.0.
128  */
130  uint16_t initialGapTicks;
131 
133 };
134 
135 extern uint8_t sLastSendToggleValue; // Currently used by RC5 + RC6
136 
139  uint_fast8_t FrequencyKHz;
141  uint8_t Flags;
142  unsigned int RepeatPeriodMillis;
143  void (*SpecialSendRepeatFunction)(); // using non member functions here saves up to 250 bytes for send demo
144 // void (IRsend::*SpecialSendRepeatFunction)();
145 };
146 /*
147  * Definitions for member PulseDistanceWidthProtocolConstants.Flags
148  */
149 #define SUPPRESS_STOP_BIT 0x20 // Stop bit is otherwise sent for all pulse distance protocols, i.e. aOneSpaceMicros != aZeroSpaceMicros.
150 #define PROTOCOL_IS_MSB_FIRST IRDATA_FLAGS_IS_MSB_FIRST
151 #define PROTOCOL_IS_LSB_FIRST IRDATA_FLAGS_IS_LSB_FIRST
152 
153 /*
154  * Carrier frequencies for various protocols
155  */
156 #if !defined(BEO_KHZ) // guard used for unit test, which sends and receive Bang&Olufsen with 38 kHz.
157 #define BEO_KHZ 455
158 #endif
159 #define SONY_KHZ 40
160 #define BOSEWAVE_KHZ 38
161 #define DENON_KHZ 38
162 #define JVC_KHZ 38
163 #define LG_KHZ 38
164 #define NEC_KHZ 38
165 #define SAMSUNG_KHZ 38
166 #define KASEIKYO_KHZ 37
167 #define RC5_RC6_KHZ 36
168 
169 #if defined(__AVR__)
170 const __FlashStringHelper* getProtocolString(decode_type_t aProtocol);
171 #else
172 const char* getProtocolString(decode_type_t aProtocol);
173 #endif
174 void printIRResultShort(Print *aSerial, IRData *aIRDataPtr, bool aPrintRepeatGap) __attribute__ ((deprecated ("Remove last parameter, it is not supported any more.")));
175 void printIRResultShort(Print *aSerial, IRData *aIRDataPtr); // A static function to be able to print send or copied received data.
176 
177 /*
178  * Convenience functions to convert MSB to LSB values
179  */
180 uint8_t bitreverseOneByte(uint8_t aValue);
181 uint32_t bitreverse32Bit(uint32_t aInput);
182 
183 #endif // _IR_PROTOCOL_H
IRData::address
uint16_t address
Decoded address, Distance protocol (tMarkTicksLong (if tMarkTicksLong == 0, then tMarkTicksShort) << ...
Definition: IRProtocol.h:111
ONKYO
@ ONKYO
Definition: IRProtocol.h:51
DistanceWidthTimingInfoStruct::HeaderMarkMicros
uint16_t HeaderMarkMicros
Definition: IRProtocol.h:81
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:120
bitreverse32Bit
uint32_t bitreverse32Bit(uint32_t aInput)
Definition: IRProtocol.hpp:286
KASEIKYO_SHARP
@ KASEIKYO_SHARP
Definition: IRProtocol.h:55
FAST
@ FAST
Definition: IRProtocol.h:72
IRRawlenType
unsigned int IRRawlenType
Definition: IRremoteInt.h:94
SONY
@ SONY
Definition: IRProtocol.h:65
KASEIKYO_JVC
@ KASEIKYO_JVC
Definition: IRProtocol.h:56
PULSE_WIDTH
@ PULSE_WIDTH
Definition: IRProtocol.h:42
PulseDistanceWidthProtocolConstants::SpecialSendRepeatFunction
void(* SpecialSendRepeatFunction)()
Definition: IRProtocol.h:143
decode_type_t
decode_type_t
An enum consisting of all supported formats.
Definition: IRProtocol.h:40
sLastSendToggleValue
uint8_t sLastSendToggleValue
Definition: ir_RC5_RC6.hpp:44
PulseDistanceWidthProtocolConstants::ProtocolIndex
decode_type_t ProtocolIndex
Definition: IRProtocol.h:138
SAMSUNG
@ SAMSUNG
Definition: IRProtocol.h:61
BOSEWAVE
@ BOSEWAVE
Definition: IRProtocol.h:68
DistanceWidthTimingInfoStruct::OneSpaceMicros
uint16_t OneSpaceMicros
Definition: IRProtocol.h:84
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:132
IRData::decodedRawData
IRRawDataType decodedRawData
Up to 32/64 bit decoded raw data, to be used for send functions.
Definition: IRProtocol.h:114
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:132
DistanceWidthTimingInfoStruct::ZeroMarkMicros
uint16_t ZeroMarkMicros
Definition: IRProtocol.h:85
MAGIQUEST
@ MAGIQUEST
Definition: IRProtocol.h:70
NEC2
@ NEC2
Definition: IRProtocol.h:50
PulseDistanceWidthProtocolConstants::Flags
uint8_t Flags
Definition: IRProtocol.h:141
DistanceWidthTimingInfoStruct
Definition: IRProtocol.h:80
ProtocolNames
const char *const ProtocolNames[]
Definition: IRProtocol.hpp:82
PulseDistanceWidthProtocolConstants
Definition: IRProtocol.h:137
PANASONIC
@ PANASONIC
Definition: IRProtocol.h:52
IRData
Data structure for the user application, available as decodedIRData.
Definition: IRProtocol.h:109
IRData::flags
uint8_t flags
IRDATA_FLAGS_IS_REPEAT, IRDATA_FLAGS_WAS_OVERFLOW etc. See IRDATA_FLAGS_* definitions above.
Definition: IRProtocol.h:121
DistanceWidthTimingInfoStruct::OneMarkMicros
uint16_t OneMarkMicros
Definition: IRProtocol.h:83
bitreverseOneByte
uint8_t bitreverseOneByte(uint8_t aValue)
Definition: IRProtocol.hpp:273
IRData::command
uint16_t command
Decoded command, Distance protocol (tMarkTicksShort << 8) | tSpaceTicksShort.
Definition: IRProtocol.h:112
NEC
@ NEC
Definition: IRProtocol.h:49
BANG_OLUFSEN
@ BANG_OLUFSEN
Definition: IRProtocol.h:67
APPLE
@ APPLE
Definition: IRProtocol.h:44
LEGO_PF
@ LEGO_PF
Definition: IRProtocol.h:69
DistanceWidthTimingInfoStruct::ZeroSpaceMicros
uint16_t ZeroSpaceMicros
Definition: IRProtocol.h:86
IRRawDataType
uint32_t IRRawDataType
Definition: IRremoteInt.h:112
KASEIKYO_MITSUBISHI
@ KASEIKYO_MITSUBISHI
Definition: IRProtocol.h:57
KASEIKYO
@ KASEIKYO
Definition: IRProtocol.h:53
DENON
@ DENON
Definition: IRProtocol.h:45
DECODED_RAW_DATA_ARRAY_SIZE
#define DECODED_RAW_DATA_ARRAY_SIZE
Definition: IRProtocol.h:104
printIRResultShort
void printIRResultShort(Print *aSerial, IRData *aIRDataPtr, bool aPrintRepeatGap) __attribute__((deprecated("Remove last parameter
RC6A
@ RC6A
Definition: IRProtocol.h:60
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:113
PulseDistanceWidthProtocolConstants::DistanceWidthTimingInfo
DistanceWidthTimingInfoStruct DistanceWidthTimingInfo
Definition: IRProtocol.h:140
IRData::rawlen
IRRawlenType rawlen
counter of entries in rawbuf of last received frame.
Definition: IRProtocol.h:129
RC6
@ RC6
Definition: IRProtocol.h:59
UNKNOWN
@ UNKNOWN
Definition: IRProtocol.h:41
WHYNTER
@ WHYNTER
Definition: IRProtocol.h:71
PulseDistanceWidthProtocolConstants::RepeatPeriodMillis
unsigned int RepeatPeriodMillis
Definition: IRProtocol.h:142
SAMSUNGLG
@ SAMSUNGLG
Definition: IRProtocol.h:62
IRData::protocol
decode_type_t protocol
UNKNOWN, NEC, SONY, RC5, PULSE_DISTANCE, ...
Definition: IRProtocol.h:110
SAMSUNG48
@ SAMSUNG48
Definition: IRProtocol.h:63
PulseDistanceWidthProtocolConstants::FrequencyKHz
uint_fast8_t FrequencyKHz
Definition: IRProtocol.h:139
DistanceWidthTimingInfoStruct::HeaderSpaceMicros
uint16_t HeaderSpaceMicros
Definition: IRProtocol.h:82
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:130
getProtocolString
const char * getProtocolString(decode_type_t aProtocol)
Definition: IRProtocol.hpp:97
SHARP
@ SHARP
Definition: IRProtocol.h:64