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_copy
ir_Sanyo.cpp@8:9d9b1e1f9b1b, 2019-06-16 (annotated)
- Committer:
- eunmango
- Date:
- Sun Jun 16 04:49:45 2019 +0000
- Revision:
- 8:9d9b1e1f9b1b
- Parent:
- 5:a4dfe2bb80b9
s
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 | // SSSS AAA N N Y Y OOO |
yuhki50 | 0:70c8e56bac45 | 6 | // S A A NN N Y Y O O |
yuhki50 | 0:70c8e56bac45 | 7 | // SSS AAAAA N N N Y O O |
yuhki50 | 0:70c8e56bac45 | 8 | // S A A N NN Y O O |
yuhki50 | 0:70c8e56bac45 | 9 | // SSSS A A N N Y OOO |
yuhki50 | 0:70c8e56bac45 | 10 | //============================================================================== |
yuhki50 | 0:70c8e56bac45 | 11 | |
yuhki50 | 0:70c8e56bac45 | 12 | // I think this is a Sanyo decoder: Serial = SA 8650B |
yuhki50 | 0:70c8e56bac45 | 13 | // Looks like Sony except for timings, 48 chars of data and time/space different |
yuhki50 | 0:70c8e56bac45 | 14 | |
yuhki50 | 0:70c8e56bac45 | 15 | #define SANYO_BITS 12 |
yuhki50 | 0:70c8e56bac45 | 16 | #define SANYO_HDR_MARK 3500 // seen range 3500 |
yuhki50 | 0:70c8e56bac45 | 17 | #define SANYO_HDR_SPACE 950 // seen 950 |
yuhki50 | 0:70c8e56bac45 | 18 | #define SANYO_ONE_MARK 2400 // seen 2400 |
yuhki50 | 0:70c8e56bac45 | 19 | #define SANYO_ZERO_MARK 700 // seen 700 |
yuhki50 | 0:70c8e56bac45 | 20 | #define SANYO_DOUBLE_SPACE_USECS 800 // usually ssee 713 - not using ticks as get number wrapround |
yuhki50 | 0:70c8e56bac45 | 21 | #define SANYO_RPT_LENGTH 45000 |
yuhki50 | 0:70c8e56bac45 | 22 | |
yuhki50 | 0:70c8e56bac45 | 23 | //+============================================================================= |
yuhki50 | 0:70c8e56bac45 | 24 | #if DECODE_SANYO |
yuhki50 | 0:70c8e56bac45 | 25 | bool IRrecv::decodeSanyo (decode_results *results) |
yuhki50 | 0:70c8e56bac45 | 26 | { |
yuhki50 | 0:70c8e56bac45 | 27 | long data = 0; |
yuhki50 | 0:70c8e56bac45 | 28 | int offset = 0; // Skip first space <-- CHECK THIS! |
yuhki50 | 0:70c8e56bac45 | 29 | |
yuhki50 | 0:70c8e56bac45 | 30 | if (irparams.rawlen < (2 * SANYO_BITS) + 2) return false ; |
yuhki50 | 0:70c8e56bac45 | 31 | |
yuhki50 | 0:70c8e56bac45 | 32 | #if 0 |
yuhki50 | 0:70c8e56bac45 | 33 | // 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 | 34 | printf("IR Gap: %d\n", results->rawbuf[offset]); |
yuhki50 | 5:a4dfe2bb80b9 | 35 | printf("test against: %d\n", results->rawbuf[offset]); |
yuhki50 | 0:70c8e56bac45 | 36 | #endif |
yuhki50 | 0:70c8e56bac45 | 37 | |
yuhki50 | 0:70c8e56bac45 | 38 | // Initial space |
yuhki50 | 0:70c8e56bac45 | 39 | if (results->rawbuf[offset] < SANYO_DOUBLE_SPACE_USECS) { |
yuhki50 | 0:70c8e56bac45 | 40 | //Serial.print("IR Gap found: "); |
yuhki50 | 0:70c8e56bac45 | 41 | results->bits = 0; |
yuhki50 | 0:70c8e56bac45 | 42 | results->value = REPEAT; |
yuhki50 | 0:70c8e56bac45 | 43 | results->decode_type = SANYO; |
yuhki50 | 0:70c8e56bac45 | 44 | return true; |
yuhki50 | 0:70c8e56bac45 | 45 | } |
yuhki50 | 0:70c8e56bac45 | 46 | offset++; |
yuhki50 | 0:70c8e56bac45 | 47 | |
yuhki50 | 0:70c8e56bac45 | 48 | // Initial mark |
yuhki50 | 0:70c8e56bac45 | 49 | if (!MATCH_MARK(results->rawbuf[offset++], SANYO_HDR_MARK)) return false ; |
yuhki50 | 0:70c8e56bac45 | 50 | |
yuhki50 | 0:70c8e56bac45 | 51 | // Skip Second Mark |
yuhki50 | 0:70c8e56bac45 | 52 | if (!MATCH_MARK(results->rawbuf[offset++], SANYO_HDR_MARK)) return false ; |
yuhki50 | 0:70c8e56bac45 | 53 | |
yuhki50 | 0:70c8e56bac45 | 54 | while (offset + 1 < irparams.rawlen) { |
yuhki50 | 0:70c8e56bac45 | 55 | if (!MATCH_SPACE(results->rawbuf[offset++], SANYO_HDR_SPACE)) break ; |
yuhki50 | 0:70c8e56bac45 | 56 | |
yuhki50 | 0:70c8e56bac45 | 57 | if (MATCH_MARK(results->rawbuf[offset], SANYO_ONE_MARK)) data = (data << 1) | 1 ; |
yuhki50 | 0:70c8e56bac45 | 58 | else if (MATCH_MARK(results->rawbuf[offset], SANYO_ZERO_MARK)) data = (data << 1) | 0 ; |
yuhki50 | 0:70c8e56bac45 | 59 | else return false ; |
yuhki50 | 0:70c8e56bac45 | 60 | offset++; |
yuhki50 | 0:70c8e56bac45 | 61 | } |
yuhki50 | 0:70c8e56bac45 | 62 | |
yuhki50 | 0:70c8e56bac45 | 63 | // Success |
yuhki50 | 0:70c8e56bac45 | 64 | results->bits = (offset - 1) / 2; |
yuhki50 | 0:70c8e56bac45 | 65 | if (results->bits < 12) { |
yuhki50 | 0:70c8e56bac45 | 66 | results->bits = 0; |
yuhki50 | 0:70c8e56bac45 | 67 | return false; |
yuhki50 | 0:70c8e56bac45 | 68 | } |
yuhki50 | 0:70c8e56bac45 | 69 | |
yuhki50 | 0:70c8e56bac45 | 70 | results->value = data; |
yuhki50 | 0:70c8e56bac45 | 71 | results->decode_type = SANYO; |
yuhki50 | 0:70c8e56bac45 | 72 | return true; |
yuhki50 | 0:70c8e56bac45 | 73 | } |
yuhki50 | 0:70c8e56bac45 | 74 | #endif |