MCPcopy Create free account
hub / github.com/Arduino-IRremote/Arduino-IRremote / decode_old

Method decode_old

src/IRReceive.hpp:2442–2537  ·  view source on GitHub ↗

* The OLD and DEPRECATED decode function with parameter aResults, kept for backward compatibility to old 2.0 tutorials * This function calls the old MSB first decoders and fills only the 3 variables: * aResults->value * aResults->bits * aResults->decode_type **********************************************************************************************************************/

Source from the content-addressed store, hash-verified

2440 * aResults->decode_type
2441 **********************************************************************************************************************/
2442bool IRrecv::decode_old(decode_results *aResults) {
2443
2444 if (irparams.StateForISR != IR_REC_STATE_STOP) {
2445 return false;
2446 }
2447
2448// copy for usage by legacy programs
2449 aResults->rawbuf[0] = irparams.initialGapTicks;
2450 for (int i = 1; i < RAW_BUFFER_LENGTH; ++i) {
2451 aResults->rawbuf[i] = irparams.rawbuf[i]; // copy 8 bit array into a 16 bit array
2452 }
2453 aResults->rawlen = irparams.rawlen;
2454 if (irparams.OverflowFlag) {
2455 // Copy overflow flag to decodedIRData.flags
2456 irparams.OverflowFlag = false;
2457 irparams.rawlen = 0; // otherwise we have OverflowFlag again at next ISR call
2458 DEBUG_PRINTLN(F("Overflow happened"));
2459 }
2460 aResults->overflow = irparams.OverflowFlag;
2461 aResults->value = 0;
2462
2463 decodedIRData.flags = IRDATA_FLAGS_IS_MSB_FIRST; // for print
2464
2465#if defined(DECODE_NEC)
2466 DEBUG_PRINTLN(F("Attempting old NEC decode"));
2467 if (decodeNECMSB(aResults)) {
2468 return true;
2469 }
2470#endif
2471
2472#if defined(DECODE_SONY)
2473 DEBUG_PRINTLN(F("Attempting old Sony decode"));
2474 if (decodeSonyMSB(aResults)) {
2475 return true;
2476 }
2477#endif
2478
2479#if defined(DECODE_RC5)
2480 DEBUG_PRINTLN(F("Attempting RC5 decode"));
2481 if (decodeRC5()) {
2482 aResults->bits = decodedIRData.numberOfBits;
2483 aResults->value = decodedIRData.decodedRawData;
2484 aResults->decode_type = RC5;
2485
2486 return true;
2487 }
2488#endif
2489
2490#if defined(DECODE_RC6)
2491 DEBUG_PRINTLN(F("Attempting RC6 decode"));
2492 if (decodeRC6()) {
2493 aResults->bits = decodedIRData.numberOfBits;
2494 aResults->value = decodedIRData.decodedRawData;
2495 aResults->decode_type = RC6;
2496 return true;
2497 }
2498#endif
2499

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected