BrickUp API Service for Docker version.

ir_Whynter.cpp 2.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #include "IRremote.h"
  2. #include "IRremoteInt.h"
  3. //==============================================================================
  4. // W W H H Y Y N N TTTTT EEEEE RRRRR
  5. // W W H H Y Y NN N T E R R
  6. // W W W HHHHH Y N N N T EEE RRRR
  7. // W W W H H Y N NN T E R R
  8. // WWW H H Y N N T EEEEE R R
  9. //==============================================================================
  10. #define WHYNTER_BITS 32
  11. #define WHYNTER_HDR_MARK 2850
  12. #define WHYNTER_HDR_SPACE 2850
  13. #define WHYNTER_BIT_MARK 750
  14. #define WHYNTER_ONE_MARK 750
  15. #define WHYNTER_ONE_SPACE 2150
  16. #define WHYNTER_ZERO_MARK 750
  17. #define WHYNTER_ZERO_SPACE 750
  18. //+=============================================================================
  19. #if SEND_WHYNTER
  20. void IRsend::sendWhynter (unsigned long data, int nbits)
  21. {
  22. // Set IR carrier frequency
  23. enableIROut(38);
  24. // Start
  25. mark(WHYNTER_ZERO_MARK);
  26. space(WHYNTER_ZERO_SPACE);
  27. // Header
  28. mark(WHYNTER_HDR_MARK);
  29. space(WHYNTER_HDR_SPACE);
  30. // Data
  31. for (unsigned long mask = 1UL << (nbits - 1); mask; mask >>= 1) {
  32. if (data & mask) {
  33. mark(WHYNTER_ONE_MARK);
  34. space(WHYNTER_ONE_SPACE);
  35. } else {
  36. mark(WHYNTER_ZERO_MARK);
  37. space(WHYNTER_ZERO_SPACE);
  38. }
  39. }
  40. // Footer
  41. mark(WHYNTER_ZERO_MARK);
  42. space(WHYNTER_ZERO_SPACE); // Always end with the LED off
  43. }
  44. #endif
  45. //+=============================================================================
  46. #if DECODE_WHYNTER
  47. bool IRrecv::decodeWhynter (decode_results *results)
  48. {
  49. long data = 0;
  50. int offset = 1; // skip initial space
  51. // Check we have the right amount of data
  52. if (irparams.rawlen < (2 * WHYNTER_BITS) + 6) return false ;
  53. // Sequence begins with a bit mark and a zero space
  54. if (!MATCH_MARK (results->rawbuf[offset++], WHYNTER_BIT_MARK )) return false ;
  55. if (!MATCH_SPACE(results->rawbuf[offset++], WHYNTER_ZERO_SPACE)) return false ;
  56. // header mark and space
  57. if (!MATCH_MARK (results->rawbuf[offset++], WHYNTER_HDR_MARK )) return false ;
  58. if (!MATCH_SPACE(results->rawbuf[offset++], WHYNTER_HDR_SPACE)) return false ;
  59. // data bits
  60. for (int i = 0; i < WHYNTER_BITS; i++) {
  61. if (!MATCH_MARK(results->rawbuf[offset++], WHYNTER_BIT_MARK)) return false ;
  62. if (MATCH_SPACE(results->rawbuf[offset], WHYNTER_ONE_SPACE )) data = (data << 1) | 1 ;
  63. else if (MATCH_SPACE(results->rawbuf[offset], WHYNTER_ZERO_SPACE)) data = (data << 1) | 0 ;
  64. else return false ;
  65. offset++;
  66. }
  67. // trailing mark
  68. if (!MATCH_MARK(results->rawbuf[offset], WHYNTER_BIT_MARK)) return false ;
  69. // Success
  70. results->bits = WHYNTER_BITS;
  71. results->value = data;
  72. results->decode_type = WHYNTER;
  73. return true;
  74. }
  75. #endif