PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

ir_Aiwa.cpp 3.5KB

3 anos atrás
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. #include "IRremote.h"
  2. #include "IRremoteInt.h"
  3. //==============================================================================
  4. // AAA IIIII W W AAA
  5. // A A I W W A A
  6. // AAAAA I W W W AAAAA
  7. // A A I W W W A A
  8. // A A IIIII WWW A A
  9. //==============================================================================
  10. // Based off the RC-T501 RCU
  11. // Lirc file http://lirc.sourceforge.net/remotes/aiwa/RC-T501
  12. #define AIWA_RC_T501_HZ 38
  13. #define AIWA_RC_T501_BITS 15
  14. #define AIWA_RC_T501_PRE_BITS 26
  15. #define AIWA_RC_T501_POST_BITS 1
  16. #define AIWA_RC_T501_SUM_BITS (AIWA_RC_T501_PRE_BITS + AIWA_RC_T501_BITS + AIWA_RC_T501_POST_BITS)
  17. #define AIWA_RC_T501_HDR_MARK 8800
  18. #define AIWA_RC_T501_HDR_SPACE 4500
  19. #define AIWA_RC_T501_BIT_MARK 500
  20. #define AIWA_RC_T501_ONE_SPACE 600
  21. #define AIWA_RC_T501_ZERO_SPACE 1700
  22. //+=============================================================================
  23. #if SEND_AIWA_RC_T501
  24. void IRsend::sendAiwaRCT501 (int code)
  25. {
  26. unsigned long pre = 0x0227EEC0; // 26-bits
  27. // Set IR carrier frequency
  28. enableIROut(AIWA_RC_T501_HZ);
  29. // Header
  30. mark(AIWA_RC_T501_HDR_MARK);
  31. space(AIWA_RC_T501_HDR_SPACE);
  32. // Send "pre" data
  33. for (unsigned long mask = 1UL << (26 - 1); mask; mask >>= 1) {
  34. mark(AIWA_RC_T501_BIT_MARK);
  35. if (pre & mask) space(AIWA_RC_T501_ONE_SPACE) ;
  36. else space(AIWA_RC_T501_ZERO_SPACE) ;
  37. }
  38. //-v- THIS CODE LOOKS LIKE IT MIGHT BE WRONG - CHECK!
  39. // it only send 15bits and ignores the top bit
  40. // then uses TOPBIT which is 0x80000000 to check the bit code
  41. // I suspect TOPBIT should be changed to 0x00008000
  42. // Skip first code bit
  43. code <<= 1;
  44. // Send code
  45. for (int i = 0; i < 15; i++) {
  46. mark(AIWA_RC_T501_BIT_MARK);
  47. if (code & 0x80000000) space(AIWA_RC_T501_ONE_SPACE) ;
  48. else space(AIWA_RC_T501_ZERO_SPACE) ;
  49. code <<= 1;
  50. }
  51. //-^- THIS CODE LOOKS LIKE IT MIGHT BE WRONG - CHECK!
  52. // POST-DATA, 1 bit, 0x0
  53. mark(AIWA_RC_T501_BIT_MARK);
  54. space(AIWA_RC_T501_ZERO_SPACE);
  55. mark(AIWA_RC_T501_BIT_MARK);
  56. space(0);
  57. }
  58. #endif
  59. //+=============================================================================
  60. #if DECODE_AIWA_RC_T501
  61. bool IRrecv::decodeAiwaRCT501 (decode_results *results)
  62. {
  63. int data = 0;
  64. int offset = 1;
  65. // Check SIZE
  66. if (irparams.rawlen < 2 * (AIWA_RC_T501_SUM_BITS) + 4) return false ;
  67. // Check HDR Mark/Space
  68. if (!MATCH_MARK (results->rawbuf[offset++], AIWA_RC_T501_HDR_MARK )) return false ;
  69. if (!MATCH_SPACE(results->rawbuf[offset++], AIWA_RC_T501_HDR_SPACE)) return false ;
  70. offset += 26; // skip pre-data - optional
  71. while(offset < irparams.rawlen - 4) {
  72. if (MATCH_MARK(results->rawbuf[offset], AIWA_RC_T501_BIT_MARK)) offset++ ;
  73. else return false ;
  74. // ONE & ZERO
  75. if (MATCH_SPACE(results->rawbuf[offset], AIWA_RC_T501_ONE_SPACE)) data = (data << 1) | 1 ;
  76. else if (MATCH_SPACE(results->rawbuf[offset], AIWA_RC_T501_ZERO_SPACE)) data = (data << 1) | 0 ;
  77. else break ; // End of one & zero detected
  78. offset++;
  79. }
  80. results->bits = (offset - 1) / 2;
  81. if (results->bits < 42) return false ;
  82. results->value = data;
  83. results->decode_type = AIWA_RC_T501;
  84. return true;
  85. }
  86. #endif