PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

ir_Denon.cpp 3.2KB

3 lat temu
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #include "IRremote.h"
  2. #include "IRremoteInt.h"
  3. // Reverse Engineered by looking at RAW dumps generated by IRremote
  4. // I have since discovered that Denon publish all their IR codes:
  5. // https://www.google.co.uk/search?q=DENON+MASTER+IR+Hex+Command+Sheet
  6. // -> http://assets.denon.com/documentmaster/us/denon%20master%20ir%20hex.xls
  7. // Having looked at the official Denon Pronto sheet and reverse engineered
  8. // the timing values from it, it is obvious that Denon have a range of
  9. // different timings and protocols ...the values here work for my AVR-3801 Amp!
  10. //==============================================================================
  11. // DDDD EEEEE N N OOO N N
  12. // D D E NN N O O NN N
  13. // D D EEE N N N O O N N N
  14. // D D E N NN O O N NN
  15. // DDDD EEEEE N N OOO N N
  16. //==============================================================================
  17. #define BITS 14 // The number of bits in the command
  18. #define HDR_MARK 300 // The length of the Header:Mark
  19. #define HDR_SPACE 750 // The lenght of the Header:Space
  20. #define BIT_MARK 300 // The length of a Bit:Mark
  21. #define ONE_SPACE 1800 // The length of a Bit:Space for 1's
  22. #define ZERO_SPACE 750 // The length of a Bit:Space for 0's
  23. //+=============================================================================
  24. //
  25. #if SEND_DENON
  26. void IRsend::sendDenon (unsigned long data, int nbits)
  27. {
  28. // Set IR carrier frequency
  29. enableIROut(38);
  30. // Header
  31. mark (HDR_MARK);
  32. space(HDR_SPACE);
  33. // Data
  34. for (unsigned long mask = 1UL << (nbits - 1); mask; mask >>= 1) {
  35. if (data & mask) {
  36. mark (BIT_MARK);
  37. space(ONE_SPACE);
  38. } else {
  39. mark (BIT_MARK);
  40. space(ZERO_SPACE);
  41. }
  42. }
  43. // Footer
  44. mark(BIT_MARK);
  45. space(0); // Always end with the LED off
  46. }
  47. #endif
  48. //+=============================================================================
  49. //
  50. #if DECODE_DENON
  51. bool IRrecv::decodeDenon (decode_results *results)
  52. {
  53. unsigned long data = 0; // Somewhere to build our code
  54. int offset = 1; // Skip the Gap reading
  55. // Check we have the right amount of data
  56. if (irparams.rawlen != 1 + 2 + (2 * BITS) + 1) return false ;
  57. // Check initial Mark+Space match
  58. if (!MATCH_MARK (results->rawbuf[offset++], HDR_MARK )) return false ;
  59. if (!MATCH_SPACE(results->rawbuf[offset++], HDR_SPACE)) return false ;
  60. // Read the bits in
  61. for (int i = 0; i < BITS; i++) {
  62. // Each bit looks like: MARK + SPACE_1 -> 1
  63. // or : MARK + SPACE_0 -> 0
  64. if (!MATCH_MARK(results->rawbuf[offset++], BIT_MARK)) return false ;
  65. // IR data is big-endian, so we shuffle it in from the right:
  66. if (MATCH_SPACE(results->rawbuf[offset], ONE_SPACE)) data = (data << 1) | 1 ;
  67. else if (MATCH_SPACE(results->rawbuf[offset], ZERO_SPACE)) data = (data << 1) | 0 ;
  68. else return false ;
  69. offset++;
  70. }
  71. // Success
  72. results->bits = BITS;
  73. results->value = data;
  74. results->decode_type = DENON;
  75. return true;
  76. }
  77. #endif