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 
73 
76  uint_fast8_t FrequencyKHz;
77  unsigned int HeaderMarkMicros;
78  unsigned int HeaderSpaceMicros;
79  unsigned int OneMarkMicros;
80  unsigned int OneSpaceMicros;
81  unsigned int ZeroMarkMicros;
82  unsigned int ZeroSpaceMicros;
83  bool isMSBFirst;
84  bool hasStopBit;
85  unsigned int RepeatPeriodMillis;
86  void (*SpecialSendRepeatFunction)(); // using non member functions here saves up to 250 bytes for send demo
87 // void (IRsend::*SpecialSendRepeatFunction)();
88 };
89 
90 /*
91  * Definitions for member IRData.flags
92  */
93 #define IRDATA_FLAGS_EMPTY 0x00
94 #define IRDATA_FLAGS_IS_REPEAT 0x01
95 #define IRDATA_FLAGS_IS_AUTO_REPEAT 0x02
96 #define IRDATA_FLAGS_PARITY_FAILED 0x04
97 #define IRDATA_FLAGS_TOGGLE_BIT 0x08
98 #define IRDATA_FLAGS_EXTRA_INFO 0x10
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 // deprecated
104 #define IRDATA_TOGGLE_BIT_MASK 0x08
105 
106 #if __INT_WIDTH__ < 32
107 #define RAW_DATA_ARRAY_SIZE ((((RAW_BUFFER_LENGTH - 2) - 1) / 64) + 1) // The -2 is for initial gap + stop bit mark, 64 mark + spaces for 32 bit.
108 #else
109 #define RAW_DATA_ARRAY_SIZE ((((RAW_BUFFER_LENGTH - 2) - 1) / 128) + 1) // The -2 is for initial gap + stop bit mark, 128 mark + spaces for 64 bit.
110 #endif
111 
115 struct IRData {
117  uint16_t address;
118  uint16_t command;
119  uint16_t extra;
120  uint16_t numberOfBits;
121  uint8_t flags;
123 #if defined(DECODE_DISTANCE_WIDTH)
124  IRRawDataType decodedRawDataArray[RAW_DATA_ARRAY_SIZE];
125 #endif
127 };
128 
129 #define PROTOCOL_IS_LSB_FIRST false
130 #define PROTOCOL_IS_MSB_FIRST true
131 
132 /*
133  * Carrier frequencies for various protocols
134  */
135 #if !defined(BEO_KHZ) // guard used for unit test, which sends and receive Bang&Olufsen with 38 kHz.
136 #define BEO_KHZ 455
137 #endif
138 #define SONY_KHZ 40
139 #define BOSEWAVE_KHZ 38
140 #define DENON_KHZ 38
141 #define JVC_KHZ 38
142 #define LG_KHZ 38
143 #define NEC_KHZ 38
144 #define SAMSUNG_KHZ 38
145 #define KASEIKYO_KHZ 37
146 #define RC5_RC6_KHZ 36
147 
148 #if defined(__AVR__)
149 const __FlashStringHelper* getProtocolString(decode_type_t aProtocol);
150 #else
151 const char* getProtocolString(decode_type_t aProtocol);
152 #endif
153 void printIRResultShort(Print *aSerial, IRData *aIRDataPtr, bool aPrintGap); // A static function to be able to print send or copied received data.
154 
155 /*
156  * Convenience functions to convert MSB to LSB values
157  */
158 uint8_t bitreverseOneByte(uint8_t aValue);
159 uint32_t bitreverse32Bit(uint32_t aInput);
160 
161 #endif // _IR_PROTOCOL_H
IRData::address
uint16_t address
Decoded address, Distance protocol (tMarkTicksLong (if tMarkTicksLong == 0, then tMarkTicksShort) << ...
Definition: IRProtocol.h:117
ONKYO
@ ONKYO
Definition: IRProtocol.h:51
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:274
KASEIKYO_SHARP
@ KASEIKYO_SHARP
Definition: IRProtocol.h:55
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:86
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:75
SAMSUNG
@ SAMSUNG
Definition: IRProtocol.h:60
BOSEWAVE
@ BOSEWAVE
Definition: IRProtocol.h:67
PulseDistanceWidthProtocolConstants::hasStopBit
bool hasStopBit
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:126
IRData::decodedRawData
IRRawDataType decodedRawData
Up to 32/64 bit decoded raw data, to be used for send functions.
Definition: IRProtocol.h:122
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
MAGIQUEST
@ MAGIQUEST
Definition: IRProtocol.h:69
NEC2
@ NEC2
Definition: IRProtocol.h:50
printIRResultShort
void printIRResultShort(Print *aSerial, IRData *aIRDataPtr, bool aPrintGap)
Function to print decoded result and flags in one line.
Definition: IRProtocol.hpp:166
PulseDistanceWidthProtocolConstants
Definition: IRProtocol.h:74
PANASONIC
@ PANASONIC
Definition: IRProtocol.h:52
SAMSUNG_LG
@ SAMSUNG_LG
Definition: IRProtocol.h:62
IRData
Data structure for the user application, available as decodedIRData.
Definition: IRProtocol.h:115
PulseDistanceWidthProtocolConstants::ZeroMarkMicros
unsigned int ZeroMarkMicros
Definition: IRProtocol.h:81
RAW_DATA_ARRAY_SIZE
#define RAW_DATA_ARRAY_SIZE
Definition: IRProtocol.h:107
IRData::flags
uint8_t flags
See IRDATA_FLAGS_* definitions above.
Definition: IRProtocol.h:121
bitreverseOneByte
uint8_t bitreverseOneByte(uint8_t aValue)
Definition: IRProtocol.hpp:261
PulseDistanceWidthProtocolConstants::HeaderSpaceMicros
unsigned int HeaderSpaceMicros
Definition: IRProtocol.h:78
IRData::command
uint16_t command
Decoded command, Distance protocol (tMarkTicksShort << 8) | tSpaceTicksShort.
Definition: IRProtocol.h:118
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
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
PulseDistanceWidthProtocolConstants::OneMarkMicros
unsigned int OneMarkMicros
Definition: IRProtocol.h:79
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:119
PulseDistanceWidthProtocolConstants::HeaderMarkMicros
unsigned int HeaderMarkMicros
Definition: IRProtocol.h:77
PulseDistanceWidthProtocolConstants::OneSpaceMicros
unsigned int OneSpaceMicros
Definition: IRProtocol.h:80
RC6
@ RC6
Definition: IRProtocol.h:59
UNKNOWN
@ UNKNOWN
Definition: IRProtocol.h:41
WHYNTER
@ WHYNTER
Definition: IRProtocol.h:70
PulseDistanceWidthProtocolConstants::isMSBFirst
bool isMSBFirst
Definition: IRProtocol.h:83
PulseDistanceWidthProtocolConstants::RepeatPeriodMillis
unsigned int RepeatPeriodMillis
Definition: IRProtocol.h:85
PulseDistanceWidthProtocolConstants::ZeroSpaceMicros
unsigned int ZeroSpaceMicros
Definition: IRProtocol.h:82
IRData::protocol
decode_type_t protocol
UNKNOWN, NEC, SONY, RC5, PULSE_DISTANCE, ...
Definition: IRProtocol.h:116
SAMSUNG48
@ SAMSUNG48
Definition: IRProtocol.h:61
PulseDistanceWidthProtocolConstants::FrequencyKHz
uint_fast8_t FrequencyKHz
Definition: IRProtocol.h:76
LG
@ LG
Definition: IRProtocol.h:47
getProtocolString
const char * getProtocolString(decode_type_t aProtocol)
Definition: IRProtocol.hpp:100
SHARP
@ SHARP
Definition: IRProtocol.h:63