BrickUp API Service for Docker version.

ir_Panasonic.cpp 2.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #include "IRremote.h"
  2. #include "IRremoteInt.h"
  3. //==============================================================================
  4. // PPPP AAA N N AAA SSSS OOO N N IIIII CCCC
  5. // P P A A NN N A A S O O NN N I C
  6. // PPPP AAAAA N N N AAAAA SSS O O N N N I C
  7. // P A A N NN A A S O O N NN I C
  8. // P A A N N A A SSSS OOO N N IIIII CCCC
  9. //==============================================================================
  10. #define PANASONIC_BITS 48
  11. #define PANASONIC_HDR_MARK 3502
  12. #define PANASONIC_HDR_SPACE 1750
  13. #define PANASONIC_BIT_MARK 502
  14. #define PANASONIC_ONE_SPACE 1244
  15. #define PANASONIC_ZERO_SPACE 400
  16. //+=============================================================================
  17. #if SEND_PANASONIC
  18. void IRsend::sendPanasonic (unsigned int address, unsigned long data)
  19. {
  20. // Set IR carrier frequency
  21. enableIROut(35);
  22. // Header
  23. mark(PANASONIC_HDR_MARK);
  24. space(PANASONIC_HDR_SPACE);
  25. // Address
  26. for (unsigned long mask = 1UL << (16 - 1); mask; mask >>= 1) {
  27. mark(PANASONIC_BIT_MARK);
  28. if (address & mask) space(PANASONIC_ONE_SPACE) ;
  29. else space(PANASONIC_ZERO_SPACE) ;
  30. }
  31. // Data
  32. for (unsigned long mask = 1UL << (32 - 1); mask; mask >>= 1) {
  33. mark(PANASONIC_BIT_MARK);
  34. if (data & mask) space(PANASONIC_ONE_SPACE) ;
  35. else space(PANASONIC_ZERO_SPACE) ;
  36. }
  37. // Footer
  38. mark(PANASONIC_BIT_MARK);
  39. space(0); // Always end with the LED off
  40. }
  41. #endif
  42. //+=============================================================================
  43. #if DECODE_PANASONIC
  44. bool IRrecv::decodePanasonic (decode_results *results)
  45. {
  46. unsigned long long data = 0;
  47. int offset = 1;
  48. if (!MATCH_MARK(results->rawbuf[offset++], PANASONIC_HDR_MARK )) return false ;
  49. if (!MATCH_MARK(results->rawbuf[offset++], PANASONIC_HDR_SPACE)) return false ;
  50. // decode address
  51. for (int i = 0; i < PANASONIC_BITS; i++) {
  52. if (!MATCH_MARK(results->rawbuf[offset++], PANASONIC_BIT_MARK)) return false ;
  53. if (MATCH_SPACE(results->rawbuf[offset],PANASONIC_ONE_SPACE )) data = (data << 1) | 1 ;
  54. else if (MATCH_SPACE(results->rawbuf[offset],PANASONIC_ZERO_SPACE)) data = (data << 1) | 0 ;
  55. else return false ;
  56. offset++;
  57. }
  58. results->value = (unsigned long)data;
  59. results->address = (unsigned int)(data >> 32);
  60. results->decode_type = PANASONIC;
  61. results->bits = PANASONIC_BITS;
  62. return true;
  63. }
  64. #endif