Go to the documentation of this file.
35 #if defined(DEBUG) && !defined(LOCAL_DEBUG)
80 #define NEC_ADDRESS_BITS 16 // 16 bit address or 8 bit address and 8 bit inverted address
81 #define NEC_COMMAND_BITS 16 // Command and inverted command
83 #define NEC_BITS (NEC_ADDRESS_BITS + NEC_COMMAND_BITS)
84 #define NEC_UNIT 560 // 21.28 periods of 38 kHz, 11.2 ticks TICKS_LOW = 8.358 TICKS_HIGH = 15.0
86 #define NEC_HEADER_MARK (16 * NEC_UNIT) // 9000 | 180
87 #define NEC_HEADER_SPACE (8 * NEC_UNIT) // 4500 | 90
89 #define NEC_BIT_MARK NEC_UNIT
90 #define NEC_ONE_SPACE (3 * NEC_UNIT) // 1690 | 33.8 TICKS_LOW = 25.07 TICKS_HIGH = 45.0
91 #define NEC_ZERO_SPACE NEC_UNIT
93 #define NEC_REPEAT_HEADER_SPACE (4 * NEC_UNIT) // 2250
95 #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
96 #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
97 #define NEC_REPEAT_DURATION (NEC_HEADER_MARK + NEC_REPEAT_HEADER_SPACE + NEC_BIT_MARK) // 12 ms
98 #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.
99 #define NEC_REPEAT_DISTANCE (NEC_REPEAT_PERIOD - NEC_AVERAGE_DURATION) // 48 ms
100 #define NEC_MAXIMUM_REPEAT_DISTANCE (NEC_REPEAT_PERIOD - NEC_MINIMAL_DURATION + 5) // 65 ms
102 #define APPLE_ADDRESS 0x87EE
125 #if !defined(DISABLE_CODE_FOR_RECEIVER)
139 #if !defined(DISABLE_CODE_FOR_RECEIVER)
148 if ((aAddress & 0xFF00) == 0) {
159 return tRawData.
ULong;
168 void IRsend::sendNEC(uint16_t aAddress, uint8_t aCommand, int_fast8_t aNumberOfRepeats) {
260 #if defined(LOCAL_DEBUG)
261 Serial.print(F(
"NEC: "));
262 Serial.println(F(
"Header space length is wrong"));
269 #if defined(LOCAL_DEBUG)
270 Serial.print(F(
"NEC: "));
271 Serial.println(F(
"Decode failed"));
324 unsigned int offset = 1;
336 aResults->
value = 0xFFFFFFFF;
353 #if defined(LOCAL_DEBUG)
354 Serial.print(F(
"NEC MSB: "));
355 Serial.println(F(
"Header space length is wrong"));
362 #if defined(LOCAL_DEBUG)
363 Serial.print(F(
"NEC MSB: "));
364 Serial.println(F(
"Decode failed"));
371 #if defined(LOCAL_DEBUG)
372 Serial.print(F(
"NEC MSB: "));
373 Serial.println(F(
"Stop bit mark length is wrong"));
401 if (data == 0xFFFFFFFF || repeat) {
413 #if !defined(DISABLE_CODE_FOR_RECEIVER)
419 #if defined(LOCAL_DEBUG)
422 #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)
#define PROTOCOL_IS_MSB_FIRST
void sendNECRaw(uint32_t aRawData, int_fast8_t aNumberOfRepeats=NO_REPEATS)
decode_type_t lastDecodedProtocol
uint16_t numberOfBits
Number of bits received for data (address + command + parity) - to determine protocol length if diffe...
void uint8_t int_fast8_t aNumberOfRepeats
#define MICROS_IN_ONE_MILLI
struct LongUnion::@4 UByte
struct PulseDistanceWidthProtocolConstants NEC2ProtocolConstants
void mark(unsigned int aMarkMicros)
Sends an IR mark for the specified number of microseconds.
#define IRDATA_FLAGS_IS_REPEAT
void restartAfterSend()
Restarts receiver after send.
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.
#define IR_DEBUG_PRINT(...)
If DEBUG, print the arguments, otherwise do nothing.
uint_fast8_t rawlen
counter of entries in rawbuf
bool decodePulseDistanceWidthData(PulseDistanceWidthProtocolConstants *aProtocolConstants, uint_fast8_t aNumberOfBits, uint_fast8_t aStartOffset=3)
Decode pulse distance protocols for PulseDistanceWidthProtocolConstants.
void sendNEC2(uint16_t aAddress, uint8_t aCommand, int_fast8_t aNumberOfRepeats)
bool matchSpace(unsigned int aMeasuredTicks, unsigned int aMatchValueMicros)
Compensate for spaces shortened by demodulator hardware.
uint8_t flags
See IRDATA_FLAGS_* definitions above.
#define PROTOCOL_IS_LSB_FIRST
unsigned int rawbuf[RAW_BUFFER_LENGTH]
raw data / tick counts per mark/space, first entry is the length of the gap between previous and curr...
void sendNECMSB(uint32_t data, uint8_t nbits, bool repeat=false)
With Send sendNECMSB() you can send your old 32 bit codes.
uint16_t command
Decoded command, Distance protocol (tMarkTicksShort << 8) | tSpaceTicksShort.
uint32_t computeNECRawDataAndChecksum(uint16_t aAddress, uint16_t aCommand)
uint32_t lastDecodedCommand
static void space(unsigned int aSpaceMicros)
Sends an IR space for the specified number of microseconds.
#define IRDATA_FLAGS_IS_LSB_FIRST
#define NEC_REPEAT_HEADER_SPACE
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 data The output always ends with a space Each additional call costs 16 bytes prog...
uint32_t lastDecodedAddress
void sendOnkyo(uint16_t aAddress, uint16_t aCommand, int_fast8_t aNumberOfRepeats)
struct PulseDistanceWidthProtocolConstants NECProtocolConstants
#define IR_DEBUG_PRINTLN(...)
If DEBUG, print the arguments as a line, otherwise do nothing.
bool matchMark(unsigned int aMeasuredTicks, unsigned int aMatchValueMicros)
Compensate for marks exceeded by demodulator hardware.
decode_type_t protocol
UNKNOWN, NEC, SONY, RC5, PULSE_DISTANCE, ...
IRrecv IrReceiver
The receiver instance.
void enableIROut(uint_fast8_t aFrequencyKHz)
Enables IR output.
void sendNECSpecialRepeat()
Static function for sending special repeat frame.
#define NEC_MAXIMUM_REPEAT_DISTANCE
void sendNEC(uint16_t aAddress, uint8_t aCommand, int_fast8_t aNumberOfRepeats)
NEC Send frame and special repeats There is NO delay after the last sent repeat!