Go to the documentation of this file.
35 #if defined(DEBUG) && !defined(LOCAL_DEBUG)
36 #define LOCAL_DEBUG // IR_DEBUG_PRINT is a real print function here. Add local debug output.
94 #define NEC_ADDRESS_BITS 16 // 16 bit address or 8 bit address and 8 bit inverted address
95 #define NEC_COMMAND_BITS 16 // Command and inverted command
97 #define NEC_BITS (NEC_ADDRESS_BITS + NEC_COMMAND_BITS)
98 #define NEC_UNIT 560 // 21.28 periods of 38 kHz, 11.2 ticks TICKS_LOW = 8.358 TICKS_HIGH = 15.0
100 #define NEC_HEADER_MARK (16 * NEC_UNIT) // 9000 | 180
101 #define NEC_HEADER_SPACE (8 * NEC_UNIT) // 4500 | 90
103 #define NEC_BIT_MARK NEC_UNIT
104 #define NEC_ONE_SPACE (3 * NEC_UNIT) // 1690 | 33.8 TICKS_LOW = 25.07 TICKS_HIGH = 45.0
105 #define NEC_ZERO_SPACE NEC_UNIT
107 #define NEC_REPEAT_HEADER_SPACE (4 * NEC_UNIT) // 2250
109 #define NEC_AVERAGE_DURATION 62000 // NEC_HEADER_MARK + NEC_HEADER_SPACE + 32 * 2,5 * NEC_UNIT + NEC_UNIT // 2.5 because we assume more zeros than ones
110 #define NEC_MINIMAL_DURATION 49900 // NEC_HEADER_MARK + NEC_HEADER_SPACE + 32 * 2 * NEC_UNIT + NEC_UNIT // 2.5 because we assume more zeros than ones
111 #define NEC_REPEAT_DURATION (NEC_HEADER_MARK + NEC_REPEAT_HEADER_SPACE + NEC_BIT_MARK) // 12 ms
112 #define NEC_REPEAT_PERIOD 110000 // Commands are repeated every 110 ms (measured from start to start) for as long as the key on the remote control is held down.
113 #define NEC_REPEAT_DISTANCE (NEC_REPEAT_PERIOD - NEC_AVERAGE_DURATION) // 48 ms
114 #define NEC_MAXIMUM_REPEAT_DISTANCE (NEC_REPEAT_PERIOD - NEC_MINIMAL_DURATION + 10000) // 70 ms
116 #define APPLE_ADDRESS 0x87EE
164 if ((aAddress & 0xFF00) == 0) {
175 return tRawData.
ULong;
183 void IRsend::sendNEC(uint16_t aAddress, uint16_t aCommand, int_fast8_t aNumberOfRepeats) {
201 void IRsend::sendNEC2(uint16_t aAddress, uint16_t aCommand, int_fast8_t aNumberOfRepeats) {
273 #if defined(LOCAL_DEBUG)
274 Serial.print(F(
"NEC: "));
275 Serial.println(F(
"Header space length is wrong"));
282 #if defined(LOCAL_DEBUG)
283 Serial.print(F(
"NEC: "));
284 Serial.println(F(
"Decode failed"));
295 #if defined(DECODE_ONKYO)
346 unsigned int offset = 1;
358 aResults->
value = 0xFFFFFFFF;
375 #if defined(LOCAL_DEBUG)
376 Serial.print(F(
"NEC MSB: "));
377 Serial.println(F(
"Header space length is wrong"));
384 #if defined(LOCAL_DEBUG)
385 Serial.print(F(
"NEC MSB: "));
386 Serial.println(F(
"Decode failed"));
393 #if defined(LOCAL_DEBUG)
394 Serial.print(F(
"NEC MSB: "));
395 Serial.println(F(
"Stop bit mark length is wrong"));
424 if (data == 0xFFFFFFFF || repeat) {
438 #if defined(LOCAL_DEBUG)
441 #endif // _IR_NEC_HPP
uint16_t address
Decoded address, Distance protocol (tMarkTicksLong (if tMarkTicksLong == 0, then tMarkTicksShort) << ...
#define MICROS_PER_TICK
microseconds per clock interrupt tick
Union to specify parts / manifestations of a 32 bit Long without casts and shifts.
Results returned from old decoders !!!deprecated!!!
void sendApple(uint8_t aAddress, uint8_t aCommand, int_fast8_t aNumberOfRepeats)
Apple: Send NEC with fixed 16 bit Apple address 0x87EE.
#define PROTOCOL_IS_MSB_FIRST
void sendNECRaw(uint32_t aRawData, int_fast8_t aNumberOfRepeats=NO_REPEATS)
Sends NEC protocol.
decode_type_t lastDecodedProtocol
uint16_t numberOfBits
Number of bits received for data (address + command + parity) - to determine protocol length if diffe...
void int_fast8_t aNumberOfRepeats
#define MICROS_IN_ONE_MILLI
struct LongUnion::@4 UByte
struct PulseDistanceWidthProtocolConstants NEC2ProtocolConstants
void mark(uint16_t aMarkMicros)
Sends an IR mark for the specified number of microseconds.
#define IRDATA_FLAGS_IS_REPEAT
The gap between the preceding frame is as smaller than the maximum gap expected for a repeat....
void sendPulseDistanceWidth(PulseDistanceWidthProtocolConstants *aProtocolConstants, IRRawDataType aData, uint_fast8_t aNumberOfBits, int_fast8_t aNumberOfRepeats)
Sends PulseDistance frames and repeats.
irparams_struct * rawDataPtr
Pointer of the raw timing data to be decoded. Mainly the OverflowFlag and the data buffer filled by r...
decode_type_t decode_type
IRRawDataType decodedRawData
Up to 32/64 bit decoded raw data, to be used for send functions.
void checkForRepeatSpaceTicksAndSetFlag(uint16_t aMaximumRepeatSpaceTicks)
#define IR_DEBUG_PRINT(...)
If DEBUG, print the arguments, otherwise do nothing.
bool matchSpace(uint16_t aMeasuredTicks, uint16_t aMatchValueMicros)
Compensate for spaces shortened by demodulator hardware.
uint8_t flags
IRDATA_FLAGS_IS_REPEAT, IRDATA_FLAGS_WAS_OVERFLOW etc. See IRDATA_FLAGS_* definitions above.
#define PROTOCOL_IS_LSB_FIRST
#define IRDATA_FLAGS_IS_PROTOCOL_WITH_DIFFERENT_REPEAT
Here we have a repeat of type NEC2 or SamsungLG.
bool decodePulseDistanceWidthData(PulseDistanceWidthProtocolConstants *aProtocolConstants, uint_fast8_t aNumberOfBits, IRRawlenType aStartOffset=3)
Decode pulse distance protocols for PulseDistanceWidthProtocolConstants.
void sendNECMSB(uint32_t data, uint8_t nbits, bool repeat=false)
With Send sendNECMSB() you can send your old 32 bit codes.
void sendNEC(uint16_t aAddress, uint16_t aCommand, int_fast8_t aNumberOfRepeats)
NEC Send frame and special repeats There is NO delay after the last sent repeat!
uint16_t command
Decoded command, Distance protocol (tMarkTicksShort << 8) | tSpaceTicksShort.
bool matchMark(uint16_t aMeasuredTicks, uint16_t aMatchValueMicros)
Compensate for marks exceeded by demodulator hardware.
IRRawbufType rawbuf[RAW_BUFFER_LENGTH]
raw data / tick counts per mark/space. With 8 bit we can only store up to 12.7 ms....
uint32_t computeNECRawDataAndChecksum(uint16_t aAddress, uint16_t aCommand)
Convert 16 bit address and 16 bit command to 32 bit NECRaw data If we get a command < 0x100,...
uint32_t lastDecodedCommand
#define IRDATA_FLAGS_IS_LSB_FIRST
static void space(uint16_t aSpaceMicros)
Sends an IR space for the specified number of microseconds.
#define NEC_REPEAT_HEADER_SPACE
void sendNEC2(uint16_t aAddress, uint16_t aCommand, int_fast8_t aNumberOfRepeats)
NEC2 Send frame !!! and repeat the frame for each requested repeat !!! There is NO delay after the la...
IRRawlenType rawlen
counter of entries in rawbuf of last received frame.
bool decodeNECMSB(decode_results *aResults)
bool decodeNEC()
Decodes also Onkyo and Apple.
void sendNECRepeat()
Send special NEC repeat frame Repeat commands should be sent in a 110 ms raster.
#define NEC_REPEAT_PERIOD
struct LongUnion::@6 UWord
void sendPulseDistanceWidthData(PulseDistanceWidthProtocolConstants *aProtocolConstants, IRRawDataType aData, uint_fast8_t aNumberOfBits)
Sends PulseDistance from data contained in parameter using ProtocolConstants structure for timing etc...
uint32_t lastDecodedAddress
void sendOnkyo(uint16_t aAddress, uint16_t aCommand, int_fast8_t aNumberOfRepeats)
There is NO delay after the last sent repeat!
struct PulseDistanceWidthProtocolConstants NECProtocolConstants
#define IR_DEBUG_PRINTLN(...)
If DEBUG, print the arguments as a line, otherwise do nothing.
decode_type_t protocol
UNKNOWN, NEC, SONY, RC5, PULSE_DISTANCE, ...
void enableIROut(uint_fast8_t aFrequencyKHz)
Enables IR output.
void sendNECSpecialRepeat()
Static function variant of IRsend::sendNECRepeat For use in ProtocolConstants.
#define NEC_MAXIMUM_REPEAT_DISTANCE