Go to the documentation of this file.
33 #ifndef _IR_RECEIVE_HPP
34 #define _IR_RECEIVE_HPP
36 #if defined(DEBUG) && !defined(LOCAL_DEBUG)
42 #if defined(TRACE) && !defined(LOCAL_TRACE)
73 #if !defined(NO_LED_FEEDBACK_CODE)
81 #if !defined(NO_LED_FEEDBACK_CODE)
94 #if !defined(NO_LED_FEEDBACK_CODE)
97 (void) aFeedbackLEDPin;
121 #if defined(TIMER_INTR_NAME)
122 ISR (TIMER_INTR_NAME)
128 #if defined(_IR_MEASURE_TIMING) && defined(_IR_TIMING_TEST_PIN)
133 #if defined(TIMER_REQUIRES_RESET_INTR_PENDING)
139 uint8_t tIRInputLevel = *
irparams.IRReceivePinPortInputRegister &
irparams.IRReceivePinMask;
164 #if defined(_IR_MEASURE_TIMING) && defined(_IR_TIMING_TEST_PIN)
181 #if defined(_IR_MEASURE_TIMING) && defined(_IR_TIMING_TEST_PIN)
195 #if !IR_REMOTE_DISABLE_RECEIVE_COMPLETE_CALLBACK
204 #if defined(_IR_MEASURE_TIMING) && defined(_IR_TIMING_TEST_PIN)
220 #if !IR_REMOTE_DISABLE_RECEIVE_COMPLETE_CALLBACK
234 #if defined(_IR_MEASURE_TIMING) && defined(_IR_TIMING_TEST_PIN)
243 #if !defined(NO_LED_FEEDBACK_CODE)
249 #ifdef _IR_MEASURE_TIMING
263 void IRrecv::begin(uint_fast8_t aReceivePin,
bool aEnableLEDFeedback, uint_fast8_t aFeedbackLEDPin) {
266 #if !defined(NO_LED_FEEDBACK_CODE)
268 if (aEnableLEDFeedback) {
273 (void) aEnableLEDFeedback;
274 (void) aFeedbackLEDPin;
277 #if defined(_IR_MEASURE_TIMING) && defined(_IR_TIMING_TEST_PIN)
289 irparams.IRReceivePinMask = digitalPinToBitMask(aReceivePinNumber);
290 irparams.IRReceivePinPortInputRegister = portInputRegister(digitalPinToPort(aReceivePinNumber));
293 pinMode(aReceivePinNumber, INPUT);
318 #ifdef _IR_MEASURE_TIMING
347 #if defined(SEND_PWM_BY_TIMER) && !defined(SEND_PWM_DOES_NOT_USE_RECEIVE_TIMER)
387 #if defined(SEND_PWM_BY_TIMER)
403 #if defined(LOCAL_DEBUG)
404 Serial.print(F(
"Overflow happened, try to increase the \"RAW_BUFFER_LENGTH\" value of "));
406 Serial.println(F(
" with #define RAW_BUFFER_LENGTH=<biggerValue>"));
466 #if defined(DECODE_NEC)
473 #if defined(DECODE_PANASONIC) || defined(DECODE_KASEIKYO)
480 #if defined(DECODE_DENON)
487 #if defined(DECODE_SONY)
494 #if defined(DECODE_RC5)
501 #if defined(DECODE_RC6)
508 #if defined(DECODE_LG)
515 #if defined(DECODE_JVC)
522 #if defined(DECODE_SAMSUNG)
532 #if defined(DECODE_BEO)
539 #if defined(DECODE_WHYNTER)
546 #if defined(DECODE_LEGO_PF)
553 #if defined(DECODE_BOSEWAVE)
560 #if defined(DECODE_MAGIQUEST)
570 #if defined(DECODE_DISTANCE_WIDTH)
580 #if defined(DECODE_HASH)
623 unsigned int aZeroMarkMicros,
unsigned int aOneSpaceMicros,
unsigned int aZeroSpaceMicros,
bool aMSBfirst) {
627 bool isPulseDistanceProtocol = (aOneMarkMicros == aZeroMarkMicros);
632 for (uint_fast8_t i = aNumberOfBits; i > 0; i--) {
634 unsigned int tMarkTicks;
635 unsigned int tSpaceTicks;
637 if (isPulseDistanceProtocol) {
641 #if defined DECODE_STRICT_CHECKS
642 tMarkTicks = *tRawBufPointer++;
644 (void) aZeroSpaceMicros;
647 tSpaceTicks = *tRawBufPointer++;
649 #if defined DECODE_STRICT_CHECKS
651 if (!
matchMark(tMarkTicks, aOneMarkMicros)) {
652 # if defined(LOCAL_DEBUG)
653 Serial.print(F(
"Mark="));
655 Serial.print(F(
" is not "));
656 Serial.print(aOneMarkMicros);
657 Serial.print(F(
". Index="));
658 Serial.print(aNumberOfBits - i);
669 tMarkTicks = *tRawBufPointer++;
670 #if defined DECODE_STRICT_CHECKS
671 tSpaceTicks = *tRawBufPointer++;
673 (void) aZeroMarkMicros;
674 (void) aZeroSpaceMicros;
684 if (isPulseDistanceProtocol) {
686 tBitValue =
matchSpace(tSpaceTicks, aOneSpaceMicros);
689 tBitValue =
matchMark(tMarkTicks, aOneMarkMicros);
696 tDecodedData |= tMask;
700 #if defined DECODE_STRICT_CHECKS
704 if (isPulseDistanceProtocol) {
705 if (!
matchSpace(tSpaceTicks, aZeroSpaceMicros)) {
706 # if defined(LOCAL_DEBUG)
707 Serial.print(F(
"Space="));
709 Serial.print(F(
" is not "));
710 Serial.print(aOneSpaceMicros);
711 Serial.print(F(
" or "));
712 Serial.print(aZeroSpaceMicros);
713 Serial.print(F(
". Index="));
714 Serial.print(aNumberOfBits - i);
720 if (!
matchMark(tMarkTicks, aZeroMarkMicros)) {
721 # if defined(LOCAL_DEBUG)
722 Serial.print(F(
"Mark="));
724 Serial.print(F(
" is not "));
725 Serial.print(aOneMarkMicros);
726 Serial.print(F(
" or "));
727 Serial.print(aZeroMarkMicros);
728 Serial.print(F(
". Index="));
729 Serial.print(aNumberOfBits - i);
739 #if defined DECODE_STRICT_CHECKS
741 if (aZeroSpaceMicros == aOneSpaceMicros
744 if (!
matchSpace(tSpaceTicks, aOneSpaceMicros)) {
745 # if defined(LOCAL_DEBUG)
746 Serial.print(F(
"Space="));
748 Serial.print(F(
" is not "));
749 Serial.print(aOneSpaceMicros);
750 Serial.print(F(
". Index="));
751 Serial.print(aNumberOfBits - i);
769 uint_fast8_t aStartOffset) {
807 uint_fast8_t tLevelOfCurrentInterval;
845 return tLevelOfCurrentInterval;
848 #if defined(DECODE_HASH)
857 uint_fast8_t
IRrecv::compare(
unsigned int oldval,
unsigned int newval) {
858 if (newval * 10 < oldval * 8) {
861 if (oldval * 10 < newval * 8) {
867 #define FNV_PRIME_32 16777619
868 #define FNV_BASIS_32 2166136261
889 unsigned long hash = FNV_BASIS_32;
895 #if RAW_BUFFER_LENGTH <= 254 // saves around 75 bytes program memory and speeds up ISR
903 hash = (hash * FNV_PRIME_32) ^ value;
914 unsigned long hash = FNV_BASIS_32;
917 if (aResults->
rawlen < 6) {
921 for (uint8_t i = 3; i < aResults->
rawlen; i++) {
924 hash = (hash * FNV_PRIME_32) ^ value;
927 aResults->
value = hash;
934 #endif // DECODE_HASH
946 #if defined(LOCAL_TRACE)
948 Serial.println(F(
": Header mark length is wrong"));
953 #if defined(LOCAL_TRACE)
955 Serial.println(F(
": Header space length is wrong"));
964 < ((aMediumRepeatSpaceMillis + (aMediumRepeatSpaceMillis / 4)) * (1000 /
MICROS_PER_TICK))) {
973 bool matchTicks(
unsigned int aMeasuredTicks,
unsigned int aMatchValueMicros) {
974 #if defined(LOCAL_TRACE)
975 Serial.print(F(
"Testing: "));
976 Serial.print(
TICKS_LOW(aMatchValueMicros), DEC);
977 Serial.print(F(
" <= "));
978 Serial.print(aMeasuredTicks, DEC);
979 Serial.print(F(
" <= "));
980 Serial.print(
TICKS_HIGH(aMatchValueMicros), DEC);
982 bool passed = ((aMeasuredTicks >=
TICKS_LOW(aMatchValueMicros)) && (aMeasuredTicks <=
TICKS_HIGH(aMatchValueMicros)));
983 #if defined(LOCAL_TRACE)
985 Serial.println(F(
" => passed"));
987 Serial.println(F(
" => FAILED"));
993 bool MATCH(
unsigned int measured_ticks,
unsigned int desired_us) {
994 return matchTicks(measured_ticks, desired_us);
1000 bool matchMark(
unsigned int aMeasuredTicks,
unsigned int aMatchValueMicros) {
1001 #if defined(LOCAL_TRACE)
1002 Serial.print(F(
"Testing mark (actual vs desired): "));
1004 Serial.print(F(
"us vs "));
1005 Serial.print(aMatchValueMicros, DEC);
1006 Serial.print(F(
"us: "));
1008 Serial.print(F(
" <= "));
1010 Serial.print(F(
" <= "));
1016 #if defined(LOCAL_TRACE)
1018 Serial.println(F(
" => passed"));
1020 Serial.println(F(
" => FAILED"));
1026 bool MATCH_MARK(
unsigned int measured_ticks,
unsigned int desired_us) {
1027 return matchMark(measured_ticks, desired_us);
1033 bool matchSpace(
unsigned int aMeasuredTicks,
unsigned int aMatchValueMicros) {
1034 #if defined(LOCAL_TRACE)
1035 Serial.print(F(
"Testing space (actual vs desired): "));
1037 Serial.print(F(
"us vs "));
1038 Serial.print(aMatchValueMicros, DEC);
1039 Serial.print(F(
"us: "));
1041 Serial.print(F(
" <= "));
1043 Serial.print(F(
" <= "));
1049 #if defined(LOCAL_TRACE)
1051 Serial.println(F(
" => passed"));
1053 Serial.println(F(
" => FAILED"));
1059 bool MATCH_SPACE(
unsigned int measured_ticks,
unsigned int desired_us) {
1060 return matchSpace(measured_ticks, desired_us);
1083 aSerial->print(F(
"Space of "));
1085 aSerial->print(F(
" us between two detected transmission is smaller than the minimal gap of "));
1087 aSerial->println(F(
" us known for implemented protocols like NEC, Sony, RC% etc.."));
1088 aSerial->println(F(
"But it can be OK for some yet unsupported protocols, and especially for repeats."));
1089 aSerial->println(F(
"If you get unexpected results, try to increase the RECORD_GAP_MICROS in IRremote.h."));
1105 #if defined(DECODE_NEC)
1106 aSerial->print(F(
"NEC/NEC2/Onkyo/Apple, "));
1108 #if defined(DECODE_PANASONIC) || defined(DECODE_KASEIKYO)
1109 aSerial->print(F(
"Panasonic/Kaseikyo, "));
1111 #if defined(DECODE_DENON)
1112 aSerial->print(F(
"Denon/Sharp, "));
1114 #if defined(DECODE_SONY)
1115 aSerial->print(F(
"Sony, "));
1117 #if defined(DECODE_RC5)
1118 aSerial->print(F(
"RC5, "));
1120 #if defined(DECODE_RC6)
1121 aSerial->print(F(
"RC6, "));
1123 #if defined(DECODE_LG)
1124 aSerial->print(F(
"LG, "));
1126 #if defined(DECODE_JVC)
1127 aSerial->print(F(
"JVC, "));
1129 #if defined(DECODE_SAMSUNG)
1130 aSerial->print(F(
"Samsung, "));
1135 #if defined(DECODE_BEO)
1136 aSerial->print(F(
"Bang & Olufsen, "));
1138 #if defined(DECODE_WHYNTER)
1139 aSerial->print(F(
"Whynter, "));
1141 #if defined(DECODE_LEGO_PF)
1142 aSerial->print(F(
"Lego Power Functions, "));
1144 #if defined(DECODE_BOSEWAVE)
1145 aSerial->print(F(
"Bosewave , "));
1147 #if defined(DECODE_MAGIQUEST)
1148 aSerial->print(F(
"MagiQuest, "));
1150 #if defined(DECODE_DISTANCE_WIDTH)
1151 aSerial->print(F(
"Universal Pulse Distance Width, "));
1153 #if defined(DECODE_HASH)
1154 aSerial->print(F(
"Hash "));
1156 #if defined(NO_DECODER) // for sending raw only
1189 #if defined(DECODE_DISTANCE_WIDTH)
1190 aSerial->print(F(
"Send with:"));
1191 uint_fast8_t tNumberOfArrayData = 0;
1193 # if __INT_WIDTH__ < 32
1195 if(tNumberOfArrayData > 1) {
1197 aSerial->print(F(
" uint32_t tRawData[]={0x"));
1200 if(tNumberOfArrayData > 1) {
1202 aSerial->print(F(
" uint64_t tRawData[]={0x"));
1204 for (uint_fast8_t i = 0; i < tNumberOfArrayData; ++i) {
1205 # if (__INT_WIDTH__ < 32)
1208 PrintULL::print(aSerial,
decodedIRData.decodedRawDataArray[i], HEX);
1210 if (i != tNumberOfArrayData - 1) {
1211 aSerial->print(F(
", 0x"));
1214 aSerial->println(F(
"};"));
1215 aSerial->print(F(
" "));
1218 aSerial->print(F(
" IrSender.send"));
1220 aSerial->print(F(
"Send with: IrSender.send"));
1223 #if defined(DECODE_DISTANCE_WIDTH)
1227 aSerial->print(F(
"(0x"));
1228 #if defined(DECODE_MAGIQUEST)
1230 # if (__INT_WIDTH__ < 32)
1245 aSerial->print(F(
", 0x"));
1248 aSerial->print(F(
", 2, "));
1251 aSerial->print(F(
", <numberOfRepeats>"));
1254 #if defined(DECODE_DISTANCE_WIDTH)
1256 if(tNumberOfArrayData > 1) {
1257 aSerial->print(
"PulseDistanceWidthFromArray(38, ");
1259 aSerial->print(
"PulseDistanceWidth(38, ");
1261 aSerial->print(
"PulseDistanceWidthFromArray(38, ");
1263 aSerial->print(F(
", "));
1265 aSerial->print(F(
", "));
1270 aSerial->print(F(
", "));
1276 aSerial->print(F(
", "));
1278 aSerial->print(F(
", "));
1284 if(tNumberOfArrayData > 1) {
1285 aSerial->print(F(
", &tRawData[0], "));
1287 aSerial->print(F(
", 0x"));
1288 # if (__INT_WIDTH__ < 32)
1293 aSerial->print(F(
", "));
1297 aSerial->print(F(
", PROTOCOL_IS_MSB_FIRST"));
1299 aSerial->print(F(
", PROTOCOL_IS_LSB_FIRST"));
1302 aSerial->print(F(
", SEND_STOP_BIT"));
1304 aSerial->print(F(
", SEND_NO_STOP_BIT"));
1306 aSerial->print(F(
", <millisofRepeatPeriod>, <numberOfRepeats>"));
1309 aSerial->print(F(
");"));
1313 " Because we have non standard extra data, you may have to use the send function, which accepts raw data like sendNECRaw() or sendRC6Raw(). Extra=0x"));
1327 aSerial->print(F(
"P="));
1330 #if defined(DECODE_HASH)
1331 aSerial->print(F(
" #=0x"));
1332 # if (__INT_WIDTH__ < 32)
1338 aSerial->print(
' ');
1340 aSerial->println(F(
" bits received"));
1345 aSerial->print(F(
" A=0x"));
1348 aSerial->print(F(
" C=0x"));
1351 aSerial->print(F(
" Raw=0x"));
1352 #if (__INT_WIDTH__ < 32)
1359 aSerial->print(F(
" R"));
1372 aSerial->print(F(
"rawData["));
1374 aSerial->println(F(
"]: "));
1379 aSerial->print(F(
" -"));
1380 if (aOutputMicrosecondsInsteadOfTicks) {
1385 #if RAW_BUFFER_LENGTH <= 254 // saves around 75 bytes program memory and speeds up ISR
1392 uint_fast8_t tCounterForNewline = 6;
1395 #if defined(DECODE_DENON) || defined(DECODE_MAGIQUEST)
1404 tCounterForNewline = 0;
1409 uint16_t tSumOfDurationTicks = 0;
1412 if (aOutputMicrosecondsInsteadOfTicks) {
1415 tDuration = tCurrentTicks;
1417 tSumOfDurationTicks += tCurrentTicks;
1420 aSerial->print(
'-');
1422 aSerial->print(F(
" +"));
1426 if (aOutputMicrosecondsInsteadOfTicks && tDuration < 1000) {
1427 aSerial->print(
' ');
1429 if (aOutputMicrosecondsInsteadOfTicks && tDuration < 100) {
1430 aSerial->print(
' ');
1432 if (tDuration < 10) {
1433 aSerial->print(
' ');
1435 aSerial->print(tDuration, DEC);
1438 aSerial->print(
',');
1441 tCounterForNewline++;
1442 if ((tCounterForNewline % 8) == 0) {
1448 aSerial->print(
"Sum: ");
1449 if (aOutputMicrosecondsInsteadOfTicks) {
1450 aSerial->println((uint32_t) tSumOfDurationTicks *
MICROS_PER_TICK, DEC);
1452 aSerial->println(tSumOfDurationTicks, DEC);
1469 if (aOutputMicrosecondsInsteadOfTicks) {
1470 aSerial->print(F(
"uint16_t rawData["));
1472 aSerial->print(F(
"uint8_t rawTicks["));
1476 aSerial->print(F(
"] = {"));
1479 #if RAW_BUFFER_LENGTH <= 254 // saves around 75 bytes program memory and speeds up ISR
1494 if (aOutputMicrosecondsInsteadOfTicks) {
1495 aSerial->print(tDuration);
1498 tTicks = (tTicks > UINT8_MAX) ? UINT8_MAX : tTicks;
1499 aSerial->print(tTicks);
1502 aSerial->print(
',');
1504 aSerial->print(
' ');
1508 aSerial->print(F(
"};"));
1511 aSerial->print(F(
" // "));
1515 aSerial->println(
"");
1530 #if RAW_BUFFER_LENGTH <= 254 // saves around 75 bytes program memory and speeds up ISR
1545 *aArrayPtr = (tTicks > UINT8_MAX) ? UINT8_MAX : tTicks;
1561 aSerial->print(F(
"uint16_t"));
1562 aSerial->print(F(
" address = 0x"));
1564 aSerial->println(
';');
1566 aSerial->print(F(
"uint16_t"));
1567 aSerial->print(F(
" command = 0x"));
1569 aSerial->println(
';');
1572 #if __INT_WIDTH__ < 32
1573 aSerial->print(F(
"uint32_t rawData = 0x"));
1575 aSerial->print(F(
"uint64_t rawData = 0x"));
1577 #if (__INT_WIDTH__ < 32)
1582 aSerial->println(
';');
1587 #if defined(__AVR__)
1607 static bool sDeprecationMessageSent =
false;
1613 if (!sDeprecationMessageSent) {
1614 #if !(defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) || defined(__AVR_ATtiny87__) || defined(__AVR_ATtiny167__))
1616 "The function decode(&results)) is deprecated and may not work as expected! Just use decode() without a parameter and IrReceiver.decodedIRData.<fieldname> .");
1618 sDeprecationMessageSent =
true;
1631 aResults->
value = 0;
1635 #if defined(DECODE_NEC)
1642 #if defined(DECODE_SONY)
1649 #if defined(DECODE_RC5)
1660 #if defined(DECODE_RC6)
1672 #if defined(DECODE_LG)
1677 #if defined(DECODE_JVC)
1684 #if defined(DECODE_SAMSUNG)
1691 #if defined(DECODE_DENON)
1710 #if defined(LOCAL_TRACE)
1713 #if defined(LOCAL_DEBUG)
1716 #endif // _IR_RECEIVE_HPP
uint16_t address
Decoded address, Distance protocol (tMarkTicksLong (if tMarkTicksLong == 0, then tMarkTicksShort) << ...
void timerConfigForReceive()
Configures the timer to be able to generate the receive sample interrupt, which consumes a small amou...
#define MICROS_PER_TICK
microseconds per clock interrupt tick
Results returned from old decoders !!!deprecated!!!
void setFeedbackLED(bool aSwitchLedOn)
Flash LED while receiving or sending IR data.
void stop()
Disables the timer for IR reception.
decode_type_t lastDecodedProtocol
uint16_t numberOfBits
Number of bits received for data (address + command + parity) - to determine protocol length if diffe...
#define RECORD_GAP_TICKS
Minimum gap between IR transmissions, in MICROS_PER_TICK.
void disableIRIn()
Alias for stop().
void enableIRIn()
Alias for start().
#define MARK_EXCESS_MICROS
MARK_EXCESS_MICROS is subtracted from all marks and added to all spaces before decoding,...
bool checkForRecordGapsMicros(Print *aSerial)
uint_fast8_t compare(unsigned int oldval, unsigned int newval)
void registerReceiveCompleteCallback(void(*aReceiveCompleteCallbackFunction)(void))
Sets the function to call if a protocol message has arrived.
Main class for receiving IR signals.
bool decodeDistanceWidth()
unsigned int sBiphaseCurrentTimingIntervals
#define IRDATA_FLAGS_IS_REPEAT
decode_type_t ProtocolIndex
void restartAfterSend()
Restarts receiver after send.
bool MATCH(unsigned int measured_ticks, unsigned int desired_us)
IRrecv()
Instantiate the IRrecv class.
uint_fast8_t sBiphaseDecodeRawbuffOffset
void printIRResultAsCVariables(Print *aSerial)
Print results as C variables to be used for sendXXX()
bool MATCH_SPACE(unsigned int measured_ticks, unsigned int desired_us)
irparams_struct * rawDataPtr
Pointer of the raw timing data to be decoded. Mainly the OverflowFlag and the data buffer filled by r...
#define IRDATA_FLAGS_IS_AUTO_REPEAT
void initBiphaselevel(uint_fast8_t aRCDecodeRawbuffOffset, unsigned int aBiphaseTimeUnit)
decode_type_t decode_type
IRRawDataType decodedRawData
Up to 32/64 bit decoded raw data, to be used for send functions.
void(* ReceiveCompleteCallbackFunction)(void)
The function to call if a protocol message has arrived, i.e. StateForISR changed to IR_REC_STATE_STOP...
void begin(uint_fast8_t aReceivePin, bool aEnableLEDFeedback=false, uint_fast8_t aFeedbackLEDPin=USE_DEFAULT_FEEDBACK_LED_PIN)
Initializes the receive and feedback pin.
#define RECORD_GAP_MICROS_WARNING_THRESHOLD
Threshold for warnings at printIRResult*() to report about changing the RECORD_GAP_MICROS value to a ...
bool decodeSonyMSB(decode_results *aResults)
This struct contains the data and control used for receiver static functions and the ISR (interrupt s...
IRData * read()
If IR receiver data is available, returns pointer to IrReceiver.decodedIRData, else NULL.
uint_fast8_t getBiphaselevel()
Gets the level of one time interval (aBiphaseTimeUnit) at a time from the raw buffer.
uint_fast8_t rawlen
counter of entries in rawbuf
bool decodeHashOld(decode_results *aResults)
void timerDisableReceiveInterrupt()
Disables the receive sample timer interrupt.
bool decodePulseDistanceWidthData(PulseDistanceWidthProtocolConstants *aProtocolConstants, uint_fast8_t aNumberOfBits, uint_fast8_t aStartOffset=3)
Decode pulse distance protocols for PulseDistanceWidthProtocolConstants.
bool decodeLGMSB(decode_results *aResults)
struct irparams_struct irparams
bool decodeSAMSUNG(decode_results *aResults)
bool decodeLegoPowerFunctions()
bool OverflowFlag
Raw buffer OverflowFlag occurred.
uint8_t LedFeedbackEnabled
LED_FEEDBACK_ENABLED_FOR_RECEIVE or LED_FEEDBACK_ENABLED_FOR_SEND -> enable blinking of pin on IR pro...
Data structure for the user application, available as decodedIRData.
#define IRDATA_FLAGS_EXTRA_INFO
There is extra info not contained in address and data (e.g. Kaseikyo unknown vendor ID,...
bool matchSpace(unsigned int aMeasuredTicks, unsigned int aMatchValueMicros)
Compensate for spaces shortened by demodulator hardware.
unsigned int ZeroMarkMicros
uint8_t flags
See IRDATA_FLAGS_* definitions above.
bool MATCH_MARK(unsigned int measured_ticks, unsigned int desired_us)
unsigned int sBiphaseTimeUnit
bool printIRResultShort(Print *aSerial, bool aPrintRepeatGap=true, bool aCheckForRecordGapsMicros=true)
Function to print values and flags of IrReceiver.decodedIRData in one line.
#define IRDATA_FLAGS_WAS_OVERFLOW
irparams.rawlen is set to 0 in this case to avoid endless OverflowFlag
#define DO_NOT_ENABLE_LED_FEEDBACK
void checkForRepeatSpaceAndSetFlag(unsigned int aMediumRepeatSpaceMicros)
bool checkHeader(PulseDistanceWidthProtocolConstants *aProtocolConstants)
uint_fast8_t sBiphaseUsedTimingIntervals
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...
unsigned int HeaderSpaceMicros
static void printActiveIRProtocols(Print *aSerial)
void printActiveIRProtocols(Print *aSerial)
uint16_t command
Decoded command, Distance protocol (tMarkTicksShort << 8) | tSpaceTicksShort.
#define IR_REC_STATE_STOP
#define IR_REC_STATE_MARK
bool isIdle()
Returns status of reception.
void timerResetInterruptPending()
void timerEnableReceiveInterrupt()
Enables the receive sample timer interrupt, which consumes a small amount of CPU every 50 us.
int getMarkExcessMicros()
Getter function for MARK_EXCESS_MICROS.
#define LED_FEEDBACK_ENABLED_FOR_RECEIVE
void compensateAndPrintIRResultAsCArray(Print *aSerial, bool aOutputMicrosecondsInsteadOfTicks=true)
Dump out the IrReceiver.decodedIRData.rawDataPtr->rawbuf[] to be used as C definition for sendRaw().
bool matchTicks(unsigned int aMeasuredTicks, unsigned int aMatchValueMicros)
Match function without compensating for marks exceeded or spaces shortened by demodulator hardware Cu...
volatile uint_fast16_t TickCounterForISR
Counts 50uS ticks. The value is copied into the rawbuf array on every transition.
volatile uint8_t StateForISR
State Machine state.
void setReceivePin(uint_fast8_t aReceivePinNumber)
Sets / changes the receiver pin number.
bool decodeDenonOld(decode_results *aResults)
void start()
Start the receiving process.
void compensateAndStoreIRResultInArray(uint8_t *aArrayPtr)
Store the decodedIRData to be used for sendRaw().
void printIRResultMinimal(Print *aSerial)
Function to print protocol number, address, command, raw data and repeat flag of IrReceiver....
#define IR_TRACE_PRINTLN(...)
void initDecodedIRData()
Is internally called by decode before calling decoders.
#define IRDATA_FLAGS_IS_MSB_FIRST
Value is mainly determined by the (known) protocol.
uint32_t lastDecodedCommand
unsigned int OneMarkMicros
bool decodeRC5()
Try to decode data as RC5 protocol.
#define IRDATA_FLAGS_EMPTY
bool available()
Returns true if IR receiver data is available.
uint16_t extra
Contains upper 16 bit of Magiquest WandID, Kaseikyo unknown vendor ID and Distance protocol (HeaderMa...
unsigned int HeaderMarkMicros
#define INPUT_MARK
Sensor output for a mark ("flash")
struct FeedbackLEDControlStruct FeedbackLEDControl
The feedback LED control instance.
void end()
Alias for stop().
bool decodeNECMSB(decode_results *aResults)
bool decodeNEC()
Decodes also Onkyo and Apple.
unsigned int OneSpaceMicros
void printIRSendUsage(Print *aSerial)
Function to print values and flags of IrReceiver.decodedIRData in one line.
bool decode()
The main decode function, attempts to decode the recently receive IR signal.
#define RAW_BUFFER_LENGTH
The length of the buffer where the IR timing data is stored before decoding 100 is sufficient for mos...
uint32_t lastDecodedAddress
#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.
unsigned int ZeroSpaceMicros
decode_type_t protocol
UNKNOWN, NEC, SONY, RC5, PULSE_DISTANCE, ...
bool decodeRC6()
Try to decode data as RC6 protocol.
#define IR_REC_STATE_SPACE
const char * getProtocolString()
void resume()
Restart the ISR (Interrupt Service Routine) state machine, to enable receiving of the next IR frame.
void startWithTicksToAdd(uint16_t aTicksToAddToGapCounter)
IRrecv IrReceiver
The receiver instance.
void printIRResultRawFormatted(Print *aSerial, bool aOutputMicrosecondsInsteadOfTicks=true)
Dump out the timings in IrReceiver.decodedIRData.rawDataPtr->rawbuf[] array 8 values per line.
#define IR_REC_STATE_IDLE
const char * getProtocolString(decode_type_t aProtocol)
bool decodeJVCMSB(decode_results *aResults)
void setLEDFeedback(uint8_t aFeedbackLEDPin, uint8_t aEnableLEDFeedback)
Enable blinking of feedback LED (LED_BUILTIN is taken as default) on IR sending and receiving Cannot ...
uint_fast8_t IRReceivePin
Pin connected to IR data from detector.