IRrecvDump.ino 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * IRremoteESP8266: IRrecvDump - dump details of IR codes with IRrecv
  3. * Copyright 2009 Ken Shirriff, http://arcfn.com
  4. *
  5. ***** DEPRECATED - DO NOT USE *****
  6. * Unless you know what you are doing, you should be using the
  7. * IRrecvDumpV2.ino sketch/example instead for capturing & decoding IR messages.
  8. * In almost ALL ways it is BETTER, FASTER, and MORE DETAILED.
  9. *
  10. * This code is left only for legacy reasons, and as another simple example of
  11. * how to use the IRremoteESP8266 library.
  12. *
  13. * As of November 2017 it will no longer be updated or supported.
  14. * You have been warned.
  15. ***** DEPRECATED - DO NOT USE *****
  16. *
  17. * An IR detector/demodulator must be connected to the input RECV_PIN.
  18. * Version 0.2 Oct 2017
  19. * Based on Ken Shirriff's IrsendDemo Version 0.1 July, 2009,
  20. * JVC and Panasonic protocol added by Kristian Lauszus
  21. * (Thanks to zenwheel and other people at the original blog post)
  22. * LG added by Darryl Smith (based on the JVC protocol)
  23. */
  24. #ifndef UNIT_TEST
  25. #include <Arduino.h>
  26. #endif
  27. #include <IRremoteESP8266.h>
  28. #include <IRrecv.h>
  29. #include <IRutils.h>
  30. // an IR detector/demodulator is connected to GPIO pin 2
  31. uint16_t RECV_PIN = 2;
  32. IRrecv irrecv(RECV_PIN);
  33. decode_results results;
  34. void setup() {
  35. Serial.begin(115200);
  36. irrecv.enableIRIn(); // Start the receiver
  37. }
  38. void dump(decode_results *results) {
  39. // Dumps out the decode_results structure.
  40. // Call this after IRrecv::decode()
  41. uint16_t count = results->rawlen;
  42. if (results->decode_type == UNKNOWN) {
  43. Serial.print("Unknown encoding: ");
  44. } else if (results->decode_type == NEC) {
  45. Serial.print("Decoded NEC: ");
  46. } else if (results->decode_type == SONY) {
  47. Serial.print("Decoded SONY: ");
  48. } else if (results->decode_type == RC5) {
  49. Serial.print("Decoded RC5: ");
  50. } else if (results->decode_type == RC5X) {
  51. Serial.print("Decoded RC5X: ");
  52. } else if (results->decode_type == RC6) {
  53. Serial.print("Decoded RC6: ");
  54. } else if (results->decode_type == RCMM) {
  55. Serial.print("Decoded RCMM: ");
  56. } else if (results->decode_type == PANASONIC) {
  57. Serial.print("Decoded PANASONIC - Address: ");
  58. Serial.print(results->address, HEX);
  59. Serial.print(" Value: ");
  60. } else if (results->decode_type == LG) {
  61. Serial.print("Decoded LG: ");
  62. } else if (results->decode_type == JVC) {
  63. Serial.print("Decoded JVC: ");
  64. } else if (results->decode_type == AIWA_RC_T501) {
  65. Serial.print("Decoded AIWA RC T501: ");
  66. } else if (results->decode_type == WHYNTER) {
  67. Serial.print("Decoded Whynter: ");
  68. } else if (results->decode_type == NIKAI) {
  69. Serial.print("Decoded Nikai: ");
  70. }
  71. serialPrintUint64(results->value, 16);
  72. Serial.print(" (");
  73. Serial.print(results->bits, DEC);
  74. Serial.println(" bits)");
  75. Serial.print("Raw (");
  76. Serial.print(count, DEC);
  77. Serial.print("): {");
  78. for (uint16_t i = 1; i < count; i++) {
  79. if (i % 100 == 0)
  80. yield(); // Preemptive yield every 100th entry to feed the WDT.
  81. if (i & 1) {
  82. Serial.print(results->rawbuf[i] * kRawTick, DEC);
  83. } else {
  84. Serial.print(", ");
  85. Serial.print((uint32_t) results->rawbuf[i] * kRawTick, DEC);
  86. }
  87. }
  88. Serial.println("};");
  89. }
  90. void loop() {
  91. if (irrecv.decode(&results)) {
  92. dump(&results);
  93. Serial.println("DEPRECATED: Please use IRrecvDumpV2.ino instead!");
  94. irrecv.resume(); // Receive the next value
  95. }
  96. }