PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

102 lines
2.9KB

  1. #include "IRremote.h"
  2. #include "IRremoteInt.h"
  3. //==============================================================================
  4. // JJJJJ V V CCCC
  5. // J V V C
  6. // J V V C
  7. // J J V V C
  8. // J V CCCC
  9. //==============================================================================
  10. #define JVC_BITS 16
  11. #define JVC_HDR_MARK 8000
  12. #define JVC_HDR_SPACE 4000
  13. #define JVC_BIT_MARK 600
  14. #define JVC_ONE_SPACE 1600
  15. #define JVC_ZERO_SPACE 550
  16. #define JVC_RPT_LENGTH 60000
  17. //+=============================================================================
  18. // JVC does NOT repeat by sending a separate code (like NEC does).
  19. // The JVC protocol repeats by skipping the header.
  20. // To send a JVC repeat signal, send the original code value
  21. // and set 'repeat' to true
  22. //
  23. #if SEND_JVC
  24. void IRsend::sendJVC (unsigned long data, int nbits, bool repeat)
  25. {
  26. // Set IR carrier frequency
  27. enableIROut(38);
  28. // Only send the Header if this is NOT a repeat command
  29. if (!repeat){
  30. mark(JVC_HDR_MARK);
  31. space(JVC_HDR_SPACE);
  32. }
  33. // Data
  34. for (unsigned long mask = 1UL << (nbits - 1); mask; mask >>= 1) {
  35. if (data & mask) {
  36. mark(JVC_BIT_MARK);
  37. space(JVC_ONE_SPACE);
  38. } else {
  39. mark(JVC_BIT_MARK);
  40. space(JVC_ZERO_SPACE);
  41. }
  42. }
  43. // Footer
  44. mark(JVC_BIT_MARK);
  45. space(0); // Always end with the LED off
  46. }
  47. #endif
  48. //+=============================================================================
  49. #if DECODE_JVC
  50. bool IRrecv::decodeJVC (decode_results *results)
  51. {
  52. long data = 0;
  53. int offset = 1; // Skip first space
  54. // Check for repeat
  55. if ( (irparams.rawlen - 1 == 33)
  56. && MATCH_MARK(results->rawbuf[offset], JVC_BIT_MARK)
  57. && MATCH_MARK(results->rawbuf[irparams.rawlen-1], JVC_BIT_MARK)
  58. ) {
  59. results->bits = 0;
  60. results->value = REPEAT;
  61. results->decode_type = JVC;
  62. return true;
  63. }
  64. // Initial mark
  65. if (!MATCH_MARK(results->rawbuf[offset++], JVC_HDR_MARK)) return false ;
  66. if (irparams.rawlen < (2 * JVC_BITS) + 1 ) return false ;
  67. // Initial space
  68. if (!MATCH_SPACE(results->rawbuf[offset++], JVC_HDR_SPACE)) return false ;
  69. for (int i = 0; i < JVC_BITS; i++) {
  70. if (!MATCH_MARK(results->rawbuf[offset++], JVC_BIT_MARK)) return false ;
  71. if (MATCH_SPACE(results->rawbuf[offset], JVC_ONE_SPACE)) data = (data << 1) | 1 ;
  72. else if (MATCH_SPACE(results->rawbuf[offset], JVC_ZERO_SPACE)) data = (data << 1) | 0 ;
  73. else return false ;
  74. offset++;
  75. }
  76. // Stop bit
  77. if (!MATCH_MARK(results->rawbuf[offset], JVC_BIT_MARK)) return false ;
  78. // Success
  79. results->bits = JVC_BITS;
  80. results->value = data;
  81. results->decode_type = JVC;
  82. return true;
  83. }
  84. #endif