PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

81 Zeilen
2.4KB

  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