Go to the documentation of this file.
92 #define NEC_ADDRESS_BITS 16 // 16 bit address or 8 bit address and 8 bit inverted address
93 #define NEC_COMMAND_BITS 16 // Command and inverted command
95 #define NEC_BITS (NEC_ADDRESS_BITS + NEC_COMMAND_BITS)
96 #define NEC_UNIT 560 // 21.28 periods of 38 kHz, 11.2 ticks TICKS_LOW = 8.358 TICKS_HIGH = 15.0
98 #define NEC_HEADER_MARK (16 * NEC_UNIT) // 9000 | 180
99 #define NEC_HEADER_SPACE (8 * NEC_UNIT) // 4500 | 90
101 #define NEC_BIT_MARK NEC_UNIT
102 #define NEC_ONE_SPACE (3 * NEC_UNIT) // 1690 | 33.8 TICKS_LOW = 25.07 TICKS_HIGH = 45.0
103 #define NEC_ZERO_SPACE NEC_UNIT
105 #define NEC_REPEAT_HEADER_SPACE (4 * NEC_UNIT) // 2250
107 #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
108 #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
109 #define NEC_REPEAT_DURATION (NEC_HEADER_MARK + NEC_REPEAT_HEADER_SPACE + NEC_BIT_MARK) // 12 ms
110 #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.
111 #define NEC_REPEAT_DISTANCE (NEC_REPEAT_PERIOD - NEC_AVERAGE_DURATION) // 48 ms
112 #define NEC_MAXIMUM_REPEAT_DISTANCE (NEC_REPEAT_PERIOD - NEC_MINIMAL_DURATION + 10000) // 70 ms
114 #define APPLE_ADDRESS 0x87EE
161 if ((aAddress & 0xFF00) == 0) {
172 return tRawData.
ULong;
180 void IRsend::sendNEC(uint16_t aAddress, uint16_t aCommand, int_fast8_t aNumberOfRepeats) {
198 void IRsend::sendNEC2(uint16_t aAddress, uint16_t aCommand, int_fast8_t aNumberOfRepeats) {
282 #if defined(DECODE_ONKYO)
333 unsigned int offset = 1;
345 aResults->
value = 0xFFFFFFFF;
398 if (data == 0xFFFFFFFF || repeat) {
414 #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.
void decodePulseDistanceWidthData(PulseDistanceWidthProtocolConstants *aProtocolConstants, uint_fast8_t aNumberOfBits, IRRawlenType aStartOffset=3)
Decode pulse distance protocols for PulseDistanceWidthProtocolConstants.
#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
void decodePulseDistanceWidthData_P(PulseDistanceWidthProtocolConstants const *aProtocolConstantsPGM, uint_fast8_t aNumberOfBits, IRRawlenType aStartOffset=3)
#define MICROS_IN_ONE_MILLI
struct LongUnion::@4 UByte
#define PROTOCOL_IS_PULSE_DISTANCE
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....
decode_type_t decode_type
void checkForRepeatSpaceTicksAndSetFlag(uint16_t aMaximumRepeatSpaceTicks)
bool matchSpace(uint16_t aMeasuredTicks, uint16_t aMatchValueMicros)
Compensate for spaces shortened by demodulator hardware.
void sendPulseDistanceWidth_P(PulseDistanceWidthProtocolConstants const *aProtocolConstantsPGM, IRDecodedRawDataType aData, uint_fast8_t aNumberOfBits, int_fast8_t aNumberOfRepeats)
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.
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.
IRDecodedRawDataType decodedRawData
Up to 32/64 bit decoded raw data, to be used for send<protocol>Raw functions.
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,...
uint16_t lastDecodedCommand
#define DEBUG_PRINTLN(...)
#define IRDATA_FLAGS_IS_LSB_FIRST
static void space(uint16_t aSpaceMicros)
Sends an IR space for the specified number of microseconds.
struct PulseDistanceWidthProtocolConstants const NECProtocolConstants PROGMEM
#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.
void sendPulseDistanceWidthData(PulseDistanceWidthProtocolConstants *aProtocolConstants, IRDecodedRawDataType aData, uint_fast8_t aNumberOfBits)
Sends PulseDistance from data contained in parameter using ProtocolConstants structure for timing etc...
#define NEC_REPEAT_PERIOD
struct LongUnion::@6 UWord
void sendOnkyo(uint16_t aAddress, uint16_t aCommand, int_fast8_t aNumberOfRepeats)
There is NO delay after the last sent repeat!
decode_type_t protocol
UNKNOWN, NEC, SONY, RC5, PULSE_DISTANCE, ...
uint16_t lastDecodedAddress
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