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
157 if ((aAddress & 0xFF00) == 0) {
168 return tRawData.
ULong;
176 void IRsend::sendNEC(uint16_t aAddress, uint8_t aCommand, int_fast8_t aNumberOfRepeats) {
267 #if defined(LOCAL_DEBUG)
268 Serial.print(F(
"NEC: "));
269 Serial.println(F(
"Header space length is wrong"));
276 #if defined(LOCAL_DEBUG)
277 Serial.print(F(
"NEC: "));
278 Serial.println(F(
"Decode failed"));
289 #if defined(DECODE_ONKYO)
340 unsigned int offset = 1;
352 aResults->
value = 0xFFFFFFFF;
369 #if defined(LOCAL_DEBUG)
370 Serial.print(F(
"NEC MSB: "));
371 Serial.println(F(
"Header space length is wrong"));
378 #if defined(LOCAL_DEBUG)
379 Serial.print(F(
"NEC MSB: "));
380 Serial.println(F(
"Decode failed"));
387 #if defined(LOCAL_DEBUG)
388 Serial.print(F(
"NEC MSB: "));
389 Serial.println(F(
"Stop bit mark length is wrong"));
418 if (data == 0xFFFFFFFF || repeat) {
432 #if defined(LOCAL_DEBUG)
435 #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 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.
uint_fast8_t rawlen
counter of entries in rawbuf
#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 and enables receiver again.
uint16_t rawbuf[RAW_BUFFER_LENGTH]
raw data / tick counts per mark/space, first entry is the length of the gap between previous and curr...
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.
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)
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.
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.
uint32_t computeNECRawDataAndChecksum(uint16_t aAddress, uint16_t aCommand)
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
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.
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
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!