Infrared remote library for Arduino: send and receive infrared signals with multiple protocols Port from Arduino-IRremote https://github.com/z3t0/Arduino-IRremote
Dependents: mbed-os-example-FinalReal mbed-os-example-FinalReal
ir_Mitsubishi.cpp@8:0650578366fd, 2019-06-16 (annotated)
- Committer:
- eunmango
- Date:
- Sun Jun 16 04:36:58 2019 +0000
- Revision:
- 8:0650578366fd
- Parent:
- 5:a4dfe2bb80b9
dd
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
yuhki50 | 0:70c8e56bac45 | 1 | #include "IRremote.h" |
yuhki50 | 0:70c8e56bac45 | 2 | #include "IRremoteInt.h" |
yuhki50 | 0:70c8e56bac45 | 3 | |
yuhki50 | 0:70c8e56bac45 | 4 | //============================================================================== |
yuhki50 | 0:70c8e56bac45 | 5 | // MMMMM IIIII TTTTT SSSS U U BBBB IIIII SSSS H H IIIII |
yuhki50 | 0:70c8e56bac45 | 6 | // M M M I T S U U B B I S H H I |
yuhki50 | 0:70c8e56bac45 | 7 | // M M M I T SSS U U BBBB I SSS HHHHH I |
yuhki50 | 0:70c8e56bac45 | 8 | // M M I T S U U B B I S H H I |
yuhki50 | 0:70c8e56bac45 | 9 | // M M IIIII T SSSS UUU BBBBB IIIII SSSS H H IIIII |
yuhki50 | 0:70c8e56bac45 | 10 | //============================================================================== |
yuhki50 | 0:70c8e56bac45 | 11 | |
yuhki50 | 0:70c8e56bac45 | 12 | // Looks like Sony except for timings, 48 chars of data and time/space different |
yuhki50 | 0:70c8e56bac45 | 13 | |
yuhki50 | 0:70c8e56bac45 | 14 | #define MITSUBISHI_BITS 16 |
yuhki50 | 0:70c8e56bac45 | 15 | |
yuhki50 | 0:70c8e56bac45 | 16 | // Mitsubishi RM 75501 |
yuhki50 | 0:70c8e56bac45 | 17 | // 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 |
yuhki50 | 0:70c8e56bac45 | 18 | // #define MITSUBISHI_HDR_MARK 250 // seen range 3500 |
yuhki50 | 0:70c8e56bac45 | 19 | #define MITSUBISHI_HDR_SPACE 350 // 7*50+100 |
yuhki50 | 0:70c8e56bac45 | 20 | #define MITSUBISHI_ONE_MARK 1950 // 41*50-100 |
yuhki50 | 0:70c8e56bac45 | 21 | #define MITSUBISHI_ZERO_MARK 750 // 17*50-100 |
yuhki50 | 0:70c8e56bac45 | 22 | // #define MITSUBISHI_DOUBLE_SPACE_USECS 800 // usually ssee 713 - not using ticks as get number wrapround |
yuhki50 | 0:70c8e56bac45 | 23 | // #define MITSUBISHI_RPT_LENGTH 45000 |
yuhki50 | 0:70c8e56bac45 | 24 | |
yuhki50 | 0:70c8e56bac45 | 25 | //+============================================================================= |
yuhki50 | 0:70c8e56bac45 | 26 | #if DECODE_MITSUBISHI |
yuhki50 | 0:70c8e56bac45 | 27 | bool IRrecv::decodeMitsubishi (decode_results *results) |
yuhki50 | 0:70c8e56bac45 | 28 | { |
yuhki50 | 5:a4dfe2bb80b9 | 29 | //printf("?!? decoding Mitsubishi:%d want %d\n", irparams.rawlen, 2 * MITSUBISHI_BITS + 2); |
yuhki50 | 0:70c8e56bac45 | 30 | long data = 0; |
yuhki50 | 0:70c8e56bac45 | 31 | if (irparams.rawlen < 2 * MITSUBISHI_BITS + 2) return false ; |
yuhki50 | 0:70c8e56bac45 | 32 | int offset = 0; // Skip first space |
yuhki50 | 0:70c8e56bac45 | 33 | // Initial space |
yuhki50 | 0:70c8e56bac45 | 34 | |
yuhki50 | 0:70c8e56bac45 | 35 | #if 0 |
yuhki50 | 0:70c8e56bac45 | 36 | // 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 |
yuhki50 | 5:a4dfe2bb80b9 | 37 | printf("IR Gap: %d\n", results->rawbuf[offset]); |
yuhki50 | 5:a4dfe2bb80b9 | 38 | printf("test against: %d\n", results->rawbuf[offset]); |
yuhki50 | 0:70c8e56bac45 | 39 | #endif |
yuhki50 | 0:70c8e56bac45 | 40 | |
yuhki50 | 0:70c8e56bac45 | 41 | #if 0 |
yuhki50 | 0:70c8e56bac45 | 42 | // Not seeing double keys from Mitsubishi |
yuhki50 | 0:70c8e56bac45 | 43 | if (results->rawbuf[offset] < MITSUBISHI_DOUBLE_SPACE_USECS) { |
yuhki50 | 0:70c8e56bac45 | 44 | // Serial.print("IR Gap found: "); |
yuhki50 | 0:70c8e56bac45 | 45 | results->bits = 0; |
yuhki50 | 0:70c8e56bac45 | 46 | results->value = REPEAT; |
yuhki50 | 0:70c8e56bac45 | 47 | results->decode_type = MITSUBISHI; |
yuhki50 | 0:70c8e56bac45 | 48 | return true; |
yuhki50 | 0:70c8e56bac45 | 49 | } |
yuhki50 | 0:70c8e56bac45 | 50 | #endif |
yuhki50 | 0:70c8e56bac45 | 51 | |
yuhki50 | 0:70c8e56bac45 | 52 | offset++; |
yuhki50 | 0:70c8e56bac45 | 53 | |
yuhki50 | 0:70c8e56bac45 | 54 | // Typical |
yuhki50 | 0:70c8e56bac45 | 55 | // 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 |
yuhki50 | 0:70c8e56bac45 | 56 | |
yuhki50 | 0:70c8e56bac45 | 57 | // Initial Space |
yuhki50 | 0:70c8e56bac45 | 58 | if (!MATCH_MARK(results->rawbuf[offset], MITSUBISHI_HDR_SPACE)) return false ; |
yuhki50 | 0:70c8e56bac45 | 59 | offset++; |
yuhki50 | 0:70c8e56bac45 | 60 | |
yuhki50 | 0:70c8e56bac45 | 61 | while (offset + 1 < irparams.rawlen) { |
yuhki50 | 0:70c8e56bac45 | 62 | if (MATCH_MARK(results->rawbuf[offset], MITSUBISHI_ONE_MARK)) data = (data << 1) | 1 ; |
yuhki50 | 0:70c8e56bac45 | 63 | else if (MATCH_MARK(results->rawbuf[offset], MITSUBISHI_ZERO_MARK)) data <<= 1 ; |
yuhki50 | 0:70c8e56bac45 | 64 | else return false ; |
yuhki50 | 0:70c8e56bac45 | 65 | offset++; |
yuhki50 | 0:70c8e56bac45 | 66 | |
yuhki50 | 0:70c8e56bac45 | 67 | if (!MATCH_SPACE(results->rawbuf[offset], MITSUBISHI_HDR_SPACE)) break ; |
yuhki50 | 0:70c8e56bac45 | 68 | offset++; |
yuhki50 | 0:70c8e56bac45 | 69 | } |
yuhki50 | 0:70c8e56bac45 | 70 | |
yuhki50 | 0:70c8e56bac45 | 71 | // Success |
yuhki50 | 0:70c8e56bac45 | 72 | results->bits = (offset - 1) / 2; |
yuhki50 | 0:70c8e56bac45 | 73 | if (results->bits < MITSUBISHI_BITS) { |
yuhki50 | 0:70c8e56bac45 | 74 | results->bits = 0; |
yuhki50 | 0:70c8e56bac45 | 75 | return false; |
yuhki50 | 0:70c8e56bac45 | 76 | } |
yuhki50 | 0:70c8e56bac45 | 77 | |
yuhki50 | 0:70c8e56bac45 | 78 | results->value = data; |
yuhki50 | 0:70c8e56bac45 | 79 | results->decode_type = MITSUBISHI; |
yuhki50 | 0:70c8e56bac45 | 80 | return true; |
yuhki50 | 0:70c8e56bac45 | 81 | } |
yuhki50 | 0:70c8e56bac45 | 82 | #endif |
yuhki50 | 0:70c8e56bac45 | 83 |