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ů.

před 3 roky
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #include "IRremote.h"
  2. #include "IRremoteInt.h"
  3. //==============================================================================
  4. // L GGGG
  5. // L G
  6. // L G GG
  7. // L G G
  8. // LLLLL GGG
  9. //==============================================================================
  10. #define LG_BITS 28
  11. #define LG_HDR_MARK 8000
  12. #define LG_HDR_SPACE 4000
  13. #define LG_BIT_MARK 600
  14. #define LG_ONE_SPACE 1600
  15. #define LG_ZERO_SPACE 550
  16. #define LG_RPT_LENGTH 60000
  17. //+=============================================================================
  18. #if DECODE_LG
  19. bool IRrecv::decodeLG (decode_results *results)
  20. {
  21. long data = 0;
  22. int offset = 1; // Skip first space
  23. // Check we have the right amount of data
  24. if (irparams.rawlen < (2 * LG_BITS) + 1 ) return false ;
  25. // Initial mark/space
  26. if (!MATCH_MARK(results->rawbuf[offset++], LG_HDR_MARK)) return false ;
  27. if (!MATCH_SPACE(results->rawbuf[offset++], LG_HDR_SPACE)) return false ;
  28. for (int i = 0; i < LG_BITS; i++) {
  29. if (!MATCH_MARK(results->rawbuf[offset++], LG_BIT_MARK)) return false ;
  30. if (MATCH_SPACE(results->rawbuf[offset], LG_ONE_SPACE)) data = (data << 1) | 1 ;
  31. else if (MATCH_SPACE(results->rawbuf[offset], LG_ZERO_SPACE)) data = (data << 1) | 0 ;
  32. else return false ;
  33. offset++;
  34. }
  35. // Stop bit
  36. if (!MATCH_MARK(results->rawbuf[offset], LG_BIT_MARK)) return false ;
  37. // Success
  38. results->bits = LG_BITS;
  39. results->value = data;
  40. results->decode_type = LG;
  41. return true;
  42. }
  43. #endif
  44. //+=============================================================================
  45. #if SEND_LG
  46. void IRsend::sendLG (unsigned long data, int nbits)
  47. {
  48. // Set IR carrier frequency
  49. enableIROut(38);
  50. // Header
  51. mark(LG_HDR_MARK);
  52. space(LG_HDR_SPACE);
  53. mark(LG_BIT_MARK);
  54. // Data
  55. for (unsigned long mask = 1UL << (nbits - 1); mask; mask >>= 1) {
  56. if (data & mask) {
  57. space(LG_ONE_SPACE);
  58. mark(LG_BIT_MARK);
  59. } else {
  60. space(LG_ZERO_SPACE);
  61. mark(LG_BIT_MARK);
  62. }
  63. }
  64. space(0); // Always end with the LED off
  65. }
  66. #endif