PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

ir_Mitsubishi.cpp 3.0KB

pirms 3 gadiem
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #include "IRremote.h"
  2. #include "IRremoteInt.h"
  3. //==============================================================================
  4. // MMMMM IIIII TTTTT SSSS U U BBBB IIIII SSSS H H IIIII
  5. // M M M I T S U U B B I S H H I
  6. // M M M I T SSS U U BBBB I SSS HHHHH I
  7. // M M I T S U U B B I S H H I
  8. // M M IIIII T SSSS UUU BBBBB IIIII SSSS H H IIIII
  9. //==============================================================================
  10. // Looks like Sony except for timings, 48 chars of data and time/space different
  11. #define MITSUBISHI_BITS 16
  12. // Mitsubishi RM 75501
  13. // 14200 7 41 7 42 7 42 7 17 7 17 7 18 7 41 7 18 7 17 7 17 7 18 7 41 8 17 7 17 7 18 7 17 7
  14. // #define MITSUBISHI_HDR_MARK 250 // seen range 3500
  15. #define MITSUBISHI_HDR_SPACE 350 // 7*50+100
  16. #define MITSUBISHI_ONE_MARK 1950 // 41*50-100
  17. #define MITSUBISHI_ZERO_MARK 750 // 17*50-100
  18. // #define MITSUBISHI_DOUBLE_SPACE_USECS 800 // usually ssee 713 - not using ticks as get number wrapround
  19. // #define MITSUBISHI_RPT_LENGTH 45000
  20. //+=============================================================================
  21. #if DECODE_MITSUBISHI
  22. bool IRrecv::decodeMitsubishi (decode_results *results)
  23. {
  24. // Serial.print("?!? decoding Mitsubishi:");Serial.print(irparams.rawlen); Serial.print(" want "); Serial.println( 2 * MITSUBISHI_BITS + 2);
  25. long data = 0;
  26. if (irparams.rawlen < 2 * MITSUBISHI_BITS + 2) return false ;
  27. int offset = 0; // Skip first space
  28. // Initial space
  29. #if 0
  30. // Put this back in for debugging - note can't use #DEBUG as if Debug on we don't see the repeat cos of the delay
  31. Serial.print("IR Gap: ");
  32. Serial.println( results->rawbuf[offset]);
  33. Serial.println( "test against:");
  34. Serial.println(results->rawbuf[offset]);
  35. #endif
  36. #if 0
  37. // Not seeing double keys from Mitsubishi
  38. if (results->rawbuf[offset] < MITSUBISHI_DOUBLE_SPACE_USECS) {
  39. // Serial.print("IR Gap found: ");
  40. results->bits = 0;
  41. results->value = REPEAT;
  42. results->decode_type = MITSUBISHI;
  43. return true;
  44. }
  45. #endif
  46. offset++;
  47. // Typical
  48. // 14200 7 41 7 42 7 42 7 17 7 17 7 18 7 41 7 18 7 17 7 17 7 18 7 41 8 17 7 17 7 18 7 17 7
  49. // Initial Space
  50. if (!MATCH_MARK(results->rawbuf[offset], MITSUBISHI_HDR_SPACE)) return false ;
  51. offset++;
  52. while (offset + 1 < irparams.rawlen) {
  53. if (MATCH_MARK(results->rawbuf[offset], MITSUBISHI_ONE_MARK)) data = (data << 1) | 1 ;
  54. else if (MATCH_MARK(results->rawbuf[offset], MITSUBISHI_ZERO_MARK)) data <<= 1 ;
  55. else return false ;
  56. offset++;
  57. if (!MATCH_SPACE(results->rawbuf[offset], MITSUBISHI_HDR_SPACE)) break ;
  58. offset++;
  59. }
  60. // Success
  61. results->bits = (offset - 1) / 2;
  62. if (results->bits < MITSUBISHI_BITS) {
  63. results->bits = 0;
  64. return false;
  65. }
  66. results->value = data;
  67. results->decode_type = MITSUBISHI;
  68. return true;
  69. }
  70. #endif